static IEnumerable<DependencyNode<ContributorNotification>> GetCompatibleTypes(DependencyTree<ContributorNotification> tree,
                                                                         DependencyNode<ContributorNotification> notificationNode,
                                                                         IEnumerable<Type> beforeTypes)
 {
     return from childType in beforeTypes
            from compatibleNode in tree.Nodes
            where compatibleNode != notificationNode
                  && childType.IsAssignableFrom(compatibleNode.Value.Contributor.GetType())
            select compatibleNode;
 }
        protected override void Init()
        {
            base.Init();
              changeCounter = 0;
              addressDependency = DependencyNode.Create(() => Student.School.Address);
              addressDependency.DependencyChanged += (node, e) => changeCounter++;

              //reset the base class dependency (not used here)
              ResetDependency();
        }
        public ParentChildItem(string name)
        {
            Name = name;
              var pts = DependencyNode.Create(() => Parent.Child.Name);
              pts.DependencyChanged += OnParentDependencyChanged;
              parentToSelfDependency = pts;

              var cts = DependencyNode.Create(() => Child.Parent.Name);
              cts.DependencyChanged += OnChildDependencyChanged;
              childToSelfDependency = cts;
        }
        public void Sub_Property_Tracking_Can_Be_Disabled_Through_Settings()
        {
            //create settings class
              var settings = new DependencyNodeSettings<IAddress>(() => Student.School.Address);

              //configure settings to ignore sub item changes
              settings.ObserveSubValueChanges = false;

              //dispose old dependency in order to get rid of event listener!
              addressDependency.Dispose();
              addressDependency = DependencyBuilder.CreateDependency(settings);

              //does not cause a change event:
              Student.School.Address.City = "Ethon";
              Assert.AreEqual(0, changeCounter);
        }
        public void Disabling_Collection_Observation_Should_Suppress_Event()
        {
            //clear existing dependency and let the garbage collector take care of it
              //(works thanks to weak event listeners). If we didn't change listener remained active
              dependency = null;
              GC.Collect();
              GC.WaitForPendingFinalizers();

              //create settings and disable observations
              DependencyNodeSettings<ObservableCollection<Student>> settings;
              settings = new DependencyNodeSettings<ObservableCollection<Student>>(() => course.Students);
              settings.ChangeHandler = OnDependencyChanged;
              settings.ObserveSubValueChanges = false;

              dependency = DependencyBuilder.CreateDependency(settings);

              //add student to collection
              course.Students.Add(TestUtil.CreateTestStudent());
              Assert.AreEqual(0, eventCounter);

              //remove student from collection
              course.Students.Remove(course.Students[7]);
              Assert.AreEqual(0, eventCounter);
        }
        private static void FlattenDependencyTypesUnified(
            RestoreTargetGraph targetGraph,
            Dictionary <string, LibraryIncludeFlags> result)
        {
            var            nodeQueue = new Queue <DependencyNode>(1);
            DependencyNode node      = null;

            var unifiedNodes = new Dictionary <string, GraphItem <RemoteResolveResult> >(StringComparer.OrdinalIgnoreCase);

            // Create a look up table of id -> library
            // This should contain only packages and projects. If there is a project with the
            // same name as a package, use the project.
            // Projects take precedence over packages here to match the resolver behavior.
            foreach (var item in targetGraph.Flattened
                     .OrderBy(lib => OrderType(lib)))
            {
                // Include flags only apply to packages and projects
                if (IsPackageOrProject(item) && !unifiedNodes.ContainsKey(item.Key.Name))
                {
                    unifiedNodes.Add(item.Key.Name, item);
                }
            }

            // Queue all direct references
            foreach (var graph in targetGraph.Graphs)
            {
                foreach (var root in graph.InnerNodes)
                {
                    // Walk only the projects and packages
                    GraphItem <RemoteResolveResult> unifiedRoot;
                    if (unifiedNodes.TryGetValue(root.Key.Name, out unifiedRoot))
                    {
                        // Find the initial project -> dependency flags
                        var typeIntersection = GetDependencyType(graph, root);

                        node = new DependencyNode(root.Item, typeIntersection);

                        nodeQueue.Enqueue(node);
                    }
                }
            }

            // Walk the graph using BFS
            // During the walk find the intersection of the include type flags.
            // Dependencies can only have less flags the deeper down the graph
            // we move. Using this we can no-op when a node is encountered that
            // has already been assigned at least as many flags as the current
            // node. We can also assume that all dependencies under it are
            // already correct. If the existing node has less flags then the
            // walk must continue and all new flags found combined with the
            // existing ones.
            while (nodeQueue.Count > 0)
            {
                node = nodeQueue.Dequeue();
                var rootId = node.Item.Key.Name;

                // Combine results on the way up
                LibraryIncludeFlags currentTypes;
                if (result.TryGetValue(rootId, out currentTypes))
                {
                    if ((node.DependencyType & currentTypes) == node.DependencyType)
                    {
                        // Noop, this is done
                        // Circular dependencies end up stopping here also
                        continue;
                    }

                    // Combine the results
                    result[rootId] = (currentTypes | node.DependencyType);
                }
                else
                {
                    // Add the flags we have to the results
                    result.Add(rootId, node.DependencyType);
                }

                foreach (var dependency in node.Item.Data.Dependencies)
                {
                    // Any nodes that are not in unifiedNodes are types that should be ignored
                    // We should also ignore dependencies that are excluded to match the dependency
                    // resolution phase.
                    // Note that we cannot stop here if there are no flags since we still need to mark
                    // the child nodes as having no flags. SuppressParent=all is a special case.
                    GraphItem <RemoteResolveResult> child;
                    if (unifiedNodes.TryGetValue(dependency.Name, out child) &&
                        dependency.SuppressParent != LibraryIncludeFlags.All)
                    {
                        // intersect the edges and remove any suppressParent flags
                        LibraryIncludeFlags typeIntersection =
                            (node.DependencyType
                             & dependency.IncludeType
                             & (~dependency.SuppressParent));

                        var childNode = new DependencyNode(child, typeIntersection);
                        nodeQueue.Enqueue(childNode);
                    }
                }
            }
        }
Exemple #7
0
        static DependencyNode AddResourceAsset(
            string assetPath, Dictionary <string, DependencyNode> assetPathsDict, Action <ProjectIssue> onIssueFound, DependencyNode parent)
        {
            // skip C# scripts
            if (Path.GetExtension(assetPath).Equals(".cs"))
            {
                return(null);
            }

            if (assetPathsDict.ContainsKey(assetPath))
            {
                var dep = assetPathsDict[assetPath];
                if (parent != null)
                {
                    dep.AddChild(parent);
                }
                return(dep);
            }

            var location       = new Location(assetPath);
            var dependencyNode = new AssetDependencyNode
            {
                location = new Location(assetPath)
            };

            if (parent != null)
            {
                dependencyNode.AddChild(parent);
            }

            onIssueFound(new ProjectIssue
                         (
                             k_Descriptor,
                             Path.GetFileNameWithoutExtension(location.Path),
                             IssueCategory.Assets,
                             location
                         )
            {
                dependencies = dependencyNode
            }
                         );

            assetPathsDict.Add(assetPath, dependencyNode);

            return(dependencyNode);
        }
Exemple #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean permissible(org.maltparser.parser.history.action.GuideUserAction currentAction, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override bool permissible(GuideUserAction currentAction, ParserConfiguration config)
        {
            currentAction.getAction(actionContainers);
            int                  trans             = transActionContainer.ActionCode;
            TwoPlanarConfig      planarConfig      = (TwoPlanarConfig)config;
            DependencyNode       activeStackPeek   = planarConfig.ActiveStack.Peek();
            DependencyNode       inactiveStackPeek = planarConfig.InactiveStack.Peek();
            DependencyNode       inputPeek         = planarConfig.Input.Peek();
            IDependencyStructure dg = planarConfig.DependencyGraph;
            //int rootHandling = planarConfig.getRootHandling();
            bool singleHeadConstraint     = planarConfig.requiresSingleHead();
            bool noCoveredRootsConstraint = planarConfig.requiresNoCoveredRoots();
            bool acyclicityConstraint     = planarConfig.requiresAcyclicity();

            //boolean connectednessConstraintOnReduce = planarConfig.requiresConnectednessCheckOnReduce();
            //boolean connectednessConstraintOnShift = planarConfig.requiresConnectednessCheckOnShift();
            if ((trans == LEFTARC || trans == RIGHTARC) && !ActionContainersLabeled)
            {
                return(false);
            }
            //if ((trans == LEFTARC || trans == REDUCE) && stackPeek.isRoot()) {
            //	return false;
            //}
            if (trans == LEFTARC)
            {
                //avoid making root child of something
                if (activeStackPeek.Root)
                {
                    return(false);
                }
                //enforce single-head constraint if present
                if (activeStackPeek.hasHead() && singleHeadConstraint)
                {
                    return(false);
                }
                //avoid two links being created from and to the same node
                if (activeStackPeek.hasHead() && dg.GetTokenNode(activeStackPeek.Index).Head.Index == inputPeek.Index)
                {
                    return(false);
                }
                //enforce acyclicity constraint if present
                if (acyclicityConstraint && activeStackPeek.findComponent().Index == inputPeek.findComponent().Index)
                {
                    return(false);
                }
            }
            if (trans == RIGHTARC)
            {
                //enforce single-head constraint if present
                if (inputPeek.hasHead() && singleHeadConstraint)
                {
                    return(false);
                }
                //avoid two links being created from and to the same node
                if (inputPeek.hasHead() && dg.GetTokenNode(inputPeek.Index).Head.Index == activeStackPeek.Index)
                {
                    return(false);
                }
                //enforce acyclicity constraint if present
                if (acyclicityConstraint && activeStackPeek.findComponent().Index == inputPeek.findComponent().Index)
                {
                    return(false);
                }
            }
            if (trans == REDUCE)
            {
                //do not reduce the dummy root
                if (activeStackPeek.Root)
                {
                    return(false);
                }
                //enforce no-covered-roots constraint if present
                if (!activeStackPeek.hasHead() && noCoveredRootsConstraint)
                {
                    return(false);
                }
                //TODO does this line still make sense? (from Nivre arc-eager)
                //if ( !stackPeek.hasHead() && rootHandling == PlanarConfig.STRICT )
                //	return false;
                //enforce connectedness constraint if present

                /*
                 * if ( connectednessConstraintOnReduce )
                 * {
                 *      boolean path1 = ( stackPeek.findComponent().getIndex() == inputPeek.findComponent().getIndex() );
                 *      boolean path2;
                 *      if ( planarConfig.getStack().size() < 2 ) path2=false;
                 *      else
                 *      {
                 *              DependencyNode stackPrev = planarConfig.getStack().get(planarConfig.getStack().size()-2);
                 *              path2 = stackPrev.findComponent().getIndex() == stackPeek.findComponent().getIndex();
                 *      }
                 *      return path1 || path2;
                 * }
                 */
            }
            if (trans == SHIFT)
            {
                /*
                 * if ( connectednessConstraintOnShift && planarConfig.getInput().size() == 1 ) //last word
                 * {
                 *      boolean path = ( planarConfig.getDependencyGraph().getTokenNode(1).findComponent().getIndex() == inputPeek.findComponent().getIndex() ); //require connection to 1st
                 *      return path;
                 * }
                 */
            }
            if (trans == REDUCEBOTH)
            {
                //do not reduce the dummy root
                if (activeStackPeek.Root || inactiveStackPeek.Root)
                {
                    return(false);
                }
                //enforce no-covered-roots constraint if present
                if ((!activeStackPeek.hasHead() || inactiveStackPeek.hasHead()) && noCoveredRootsConstraint)
                {
                    return(false);
                }

                //TODO remove this:
                //not using this transition at the moment, so
                return(false);
            }
            if (trans == SWITCH)
            {
                if (planarConfig.reduceAfterSwitch())
                {
                    if (inactiveStackPeek.Root)
                    {
                        return(false);
                    }
                    //enforce no-covered-roots constraint if present
                    if (!inactiveStackPeek.hasHead() && noCoveredRootsConstraint)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (planarConfig.LastAction == SWITCH)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        void RequireLinkBase_PreRender(object sender, EventArgs e)
        {
            DependencyGraph<String, RequireLinkBase> graph = GetDependencyGraph();

            DependencyNode<String, RequireLinkBase> node = new DependencyNode<String, RequireLinkBase>(Key, this, ParseDependencies(After ?? ""));
            if (!graph.Graph.Any(n => n.Key == Key))
                graph.Graph.Add(node);
            // todo: merge dependencies if it's a dupe
        }
 public ResolvableService(string serviceTypeName, DependencyNode dependencies)
 {
     ServiceTypeName = serviceTypeName;
     Dependencies    = dependencies;
 }
 public MyApplication()
 {
     //create a dependency on the city of the student's school
       dependency = DependencyNode.Create(() => MyStudent.School.Address.City);
       dependency.DependencyChanged += OnStudentCityChanged;
 }
Exemple #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean permissible(org.maltparser.parser.history.action.GuideUserAction currentAction, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override bool permissible(GuideUserAction currentAction, ParserConfiguration config)
        {
            currentAction.getAction(actionContainers);
            int                  trans        = transActionContainer.ActionCode;
            PlanarConfig         planarConfig = (PlanarConfig)config;
            DependencyNode       stackPeek    = planarConfig.Stack.Peek();
            DependencyNode       inputPeek    = planarConfig.Input.Peek();
            IDependencyStructure dg           = planarConfig.DependencyGraph;
            //int rootHandling = planarConfig.getRootHandling();
            bool singleHeadConstraint            = planarConfig.requiresSingleHead();
            bool noCoveredRootsConstraint        = planarConfig.requiresNoCoveredRoots();
            bool acyclicityConstraint            = planarConfig.requiresAcyclicity();
            bool connectednessConstraintOnReduce = planarConfig.requiresConnectednessCheckOnReduce();
            bool connectednessConstraintOnShift  = planarConfig.requiresConnectednessCheckOnShift();

            if ((trans == LEFTARC || trans == RIGHTARC) && !ActionContainersLabeled)
            {
                return(false);
            }
            //if ((trans == LEFTARC || trans == REDUCE) && stackPeek.isRoot()) {
            //	return false;
            //}
            if (trans == LEFTARC)
            {
                //avoid making root child of something
                if (stackPeek.Root)
                {
                    return(false);
                }
                //enforce single-head constraint if present
                if (stackPeek.hasHead() && singleHeadConstraint)
                {
                    return(false);
                }
                //avoid two links being created from and to the same node
                if (stackPeek.hasHead() && dg.GetTokenNode(stackPeek.Index).Head.Index == inputPeek.Index)
                {
                    return(false);
                }
                //enforce acyclicity constraint if present
                if (acyclicityConstraint && stackPeek.findComponent().Index == inputPeek.findComponent().Index)
                {
                    return(false);
                }
            }
            if (trans == RIGHTARC)
            {
                //enforce single-head constraint if present
                if (inputPeek.hasHead() && singleHeadConstraint)
                {
                    return(false);
                }
                //avoid two links being created from and to the same node
                if (inputPeek.hasHead() && dg.GetTokenNode(inputPeek.Index).Head.Index == stackPeek.Index)
                {
                    return(false);
                }
                //enforce acyclicity constraint if present
                if (acyclicityConstraint && stackPeek.findComponent().Index == inputPeek.findComponent().Index)
                {
                    return(false);
                }
            }
            if (trans == REDUCE)
            {
                //do not reduce the dummy root
                if (stackPeek.Root)
                {
                    return(false);
                }
                //enforce no-covered-roots constraint if present
                if (!stackPeek.hasHead() && noCoveredRootsConstraint)
                {
                    return(false);
                }
                //TODO does this line still make sense? (from Nivre arc-eager)
                //if ( !stackPeek.hasHead() && rootHandling == PlanarConfig.STRICT )
                //	return false;
                //enforce connectedness constraint if present
                if (connectednessConstraintOnReduce)
                {
                    bool path1 = (stackPeek.findComponent().Index == inputPeek.findComponent().Index);
                    bool path2;
                    if (planarConfig.Stack.Count < 2)
                    {
                        path2 = false;
                    }
                    else
                    {
//JAVA TO C# CONVERTER TODO TASK: There is no direct .NET Stack equivalent to Java Stack methods based on internal indexing:
                        DependencyNode stackPrev = planarConfig.Stack.get(planarConfig.Stack.Count - 2);
                        path2 = stackPrev.findComponent().Index == stackPeek.findComponent().Index;
                    }
                    return(path1 || path2);
                }
            }
            if (trans == SHIFT)
            {
                if (connectednessConstraintOnShift && planarConfig.Input.Count == 1)                                                     //last word
                {
                    bool path = (planarConfig.DependencyGraph.GetTokenNode(1).findComponent().Index == inputPeek.findComponent().Index); //require connection to 1st
                    return(path);
                }
            }
            return(true);
        }
Exemple #13
0
        private List <DependencyNode> findAllDependentsVectorSortedByDistanceToPProjNode2(IDependencyStructure dg, DependencyNode governor, DependencyNode avoid, bool percentOnly)
        {
            int i, j;
            List <DependencyNode> dependents = new List <DependencyNode>();
            DependencyNode        leftChild, rightChild;

            i          = governor.LeftDependentCount - 1;
            j          = 0;
            leftChild  = governor.getLeftDependent(i--);
            rightChild = governor.getRightDependent(j++);

            while (leftChild != null && rightChild != null)
            {
                if (leftChild == avoid)
                {
                    leftChild = governor.getLeftDependent(i--);
                }
                else if (rightChild == avoid)
                {
                    rightChild = governor.getRightDependent(j++);
                }
                else if (Math.Abs(leftChild.Index - avoid.Index) < Math.Abs(rightChild.Index - avoid.Index))
                {
                    if (!percentOnly || (percentOnly && nodePath[leftChild.Index]))
                    {
                        dependents.Add(leftChild);
                    }
                    leftChild = governor.getLeftDependent(i--);
                }
                else
                {
                    if (!percentOnly || (percentOnly && nodePath[rightChild.Index]))
                    {
                        dependents.Add(rightChild);
                    }
                    rightChild = governor.getRightDependent(j++);
                }
            }
            while (leftChild != null)
            {
                if (leftChild != avoid && (!percentOnly || (percentOnly && nodePath[leftChild.Index])))
                {
                    dependents.Add(leftChild);
                }
                leftChild = governor.getLeftDependent(i--);
            }
            while (rightChild != null)
            {
                if (rightChild != avoid && (!percentOnly || (percentOnly && nodePath[rightChild.Index])))
                {
                    dependents.Add(rightChild);
                }
                rightChild = governor.getRightDependent(j++);
            }
            return(dependents);
        }
 public void Monitoring_A_Collection_Item_Should_Work()
 {
     var dep = DependencyNode.Create(() => course.Students.FirstOrDefault(s => s.Age > 20));
 }
Exemple #15
0
 public bool Equals(DependencyNode <T, TKey> other)
 {
     return(other != null && Key.Equals(other.Key));
 }
Exemple #16
0
        private static bool Produces(DependencyNode n, ValueSpecification specToTest)
        {
            var targetMatches = n.Target.UniqueId == specToTest.TargetSpecification.Uid && n.Target.Type == specToTest.TargetSpecification.Type;

            return(targetMatches && n.OutputValues.Any(s => s.Equals(specToTest)));
        }
Exemple #17
0
 public DependencyNode(string assetBundleName, DependencyNode parent)
 {
     parentNode           = parent;
     this.assetBundleName = assetBundleName;
 }
 public ServiceConstructor(string serviceTypeName, string constructorName, DependencyNode dependencies)
 {
     ServiceTypeName = serviceTypeName;
     ConstructorName = constructorName;
     Dependencies    = dependencies;
 }
Exemple #19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.maltparser.core.syntaxgraph.edge.Edge moveDependencyEdge(org.maltparser.core.syntaxgraph.node.DependencyNode newHead, org.maltparser.core.syntaxgraph.node.DependencyNode dependent) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual Edge.Edge moveDependencyEdge(DependencyNode newHead, DependencyNode dependent)
        {
            if (dependent == null || !dependent.hasHead())
            {
                return(null);
            }
            Edge.Edge headEdge = dependent.HeadEdge;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LabelSet labels = checkOutNewLabelSet();
            LabelSet labels = CheckOutNewLabelSet();

            foreach (SymbolTable table in headEdge.LabelTypes)
            {
                labels.put(table, headEdge.getLabelCode(table));
            }
            headEdge.clear();
            headEdge.BelongsToGraph = this;
            headEdge.setEdge((Node.Node)newHead, (Node.Node)dependent, Edge_Fields.DEPENDENCY_EDGE);
            headEdge.addLabel(labels);
            labels.clear();
            CheckInLabelSet(labels);
            return(headEdge);
        }
Exemple #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void updatePhraseStructureGraph(org.maltparser.core.syntaxgraph.MappablePhraseStructureGraph graph, org.maltparser.core.syntaxgraph.edge.Edge depEdge, boolean attachHeadSpineToRoot) throws org.maltparser.core.exception.MaltChainedException
        public virtual void updatePhraseStructureGraph(MappablePhraseStructureGraph graph, Edge.Edge depEdge, bool attachHeadSpineToRoot)
        {
            PhraseStructureNode dependentSpine = (PhraseStructureNode)depEdge.Target;

            if (((PhraseStructureNode)depEdge.Target).Parent == null)
            {
                // Restore dependent spine
                string phraseSpineLabel = null;
                string edgeSpineLabel   = null;
                int    empty_label      = 0;

                if (depEdge.hasLabel(graph.SymbolTables.getSymbolTable(PHRASE)))
                {
                    phraseSpineLabel = depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(PHRASE));
                }
                if (depEdge.hasLabel(graph.SymbolTables.getSymbolTable(HEADREL)))
                {
                    edgeSpineLabel = depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(HEADREL));
                }
                if (!ReferenceEquals(phraseSpineLabel, null) && phraseSpineLabel.Length > 0 && phraseSpineLabel[0] != EMPTY_SPINE)
                {
                    int ps = 0, es = 0, i = 0, j = 0, n = phraseSpineLabel.Length - 1, m = edgeSpineLabel.Length - 1;
                    PhraseStructureNode child = (PhraseStructureNode)depEdge.Target;
                    while (true)
                    {
                        while (i <= n && phraseSpineLabel[i] != SPINE_ELEMENT_SEPARATOR)
                        {
                            if (phraseSpineLabel[i] == QUESTIONMARK)
                            {
                                empty_label++;
                            }
                            else
                            {
                                empty_label = 0;
                            }
                            i++;
                        }
                        if (depEdge.Source.Root && i >= n)
                        {
                            dependentSpine = graph.PhraseStructureRoot;
                        }
                        else
                        {
                            dependentSpine = graph.addNonTerminalNode(++nonTerminalCounter);
                        }

                        if (empty_label != 2 && ps != i)
                        {
                            dependentSpine.addLabel(graph.SymbolTables.addSymbolTable(CAT), phraseSpineLabel.Substring(ps, i - ps));
                        }

                        empty_label = 0;
                        if (!ReferenceEquals(edgeSpineLabel, null))
                        {
                            while (j <= m && edgeSpineLabel[j] != SPINE_ELEMENT_SEPARATOR)
                            {
                                if (edgeSpineLabel[j] == QUESTIONMARK)
                                {
                                    empty_label++;
                                }
                                else
                                {
                                    empty_label = 0;
                                }
                                j++;
                            }
                        }
                        lockUpdate = true;
                        Edge.Edge e = graph.addPhraseStructureEdge(dependentSpine, child);
                        if (empty_label != 2 && es != j && !ReferenceEquals(edgeSpineLabel, null) && e != null)
                        {
                            e.addLabel(graph.SymbolTables.addSymbolTable(EDGELABEL), edgeSpineLabel.Substring(es, j - es));
                        }
                        else if (es == j)
                        {
                            e.addLabel(graph.SymbolTables.addSymbolTable(EDGELABEL), EMPTY_LABEL);
                        }

                        lockUpdate = false;
                        child      = dependentSpine;
                        if (i >= n)
                        {
                            break;
                        }
                        empty_label = 0;
                        ps          = i = i + 1;
                        es          = j = j + 1;
                    }
                }

                // Recursively attach the dependent spines to target node.
                DependencyNode target = (DependencyNode)depEdge.Target;
                for (int i = 0; i < target.LeftDependentCount; i++)
                {
                    updatePhraseStructureGraph(graph, target.getLeftDependent(i).HeadEdge, attachHeadSpineToRoot);
                }
                for (int i = target.RightDependentCount - 1; i >= 0; i--)
                {
                    updatePhraseStructureGraph(graph, target.getRightDependent(i).HeadEdge, attachHeadSpineToRoot);
                }
            }
            else
            {
                // If dependent spine already exist, then set dependentSpine to the highest nonterminal
                // of the dependent spine.
                while (dependentSpine.Parent != null && !dependentSpine.Parent.Root)
                {
                    dependentSpine = dependentSpine.Parent;
                }
            }


            PhraseStructureNode headSpine = null;

            if (((PhraseStructureNode)depEdge.Source).Parent != null)
            {
                // If head spine exist, then attach dependent spine to the head spine at the attachment level a.
                int a = 0;
                headSpine = ((PhraseStructureNode)depEdge.Source).Parent;
                if (depEdge.hasLabel(graph.SymbolTables.getSymbolTable(ATTACH)))
                {
                    try
                    {
                        a = int.Parse((depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(ATTACH))));
                    }
                    catch (FormatException e)
                    {
                        throw new MaltChainedException(e.Message);
                    }
                }
                for (int i = 0; i < a && headSpine != null; i++)
                {
                    headSpine = headSpine.Parent;
                }

                if ((headSpine == null || headSpine == dependentSpine) && attachHeadSpineToRoot)
                {
                    headSpine = graph.PhraseStructureRoot;
                }
                if (headSpine != null)
                {
                    lockUpdate = true;
                    Edge.Edge e = graph.addPhraseStructureEdge(headSpine, dependentSpine);
                    if (depEdge.hasLabel(graph.SymbolTables.getSymbolTable(DEPREL)) && !depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(DEPREL)).Equals(EMPTY_LABEL) & e != null)
                    {
                        e.addLabel(graph.SymbolTables.addSymbolTable(EDGELABEL), depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(DEPREL)));
                    }
                    lockUpdate = false;
                }
            }
            else if (depEdge.Source.Root && !depEdge.Labeled)
            {
                headSpine  = graph.PhraseStructureRoot;
                lockUpdate = true;
                Edge.Edge e = graph.addPhraseStructureEdge(headSpine, dependentSpine);
                if (depEdge.hasLabel(graph.SymbolTables.getSymbolTable(DEPREL)) && !depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(DEPREL)).Equals(EMPTY_LABEL) & e != null)
                {
                    e.addLabel(graph.SymbolTables.addSymbolTable(EDGELABEL), depEdge.getLabelSymbol(graph.SymbolTables.getSymbolTable(DEPREL)));
                }
                else
                {
                    e.addLabel(graph.SymbolTables.addSymbolTable(EDGELABEL), graph.GetDefaultRootEdgeLabelSymbol(graph.SymbolTables.getSymbolTable(DEPREL)));
                }
                lockUpdate = false;
                // Recursively attach the dependent spines to target node.
                DependencyNode target = (DependencyNode)depEdge.Target;
                for (int i = 0; i < target.LeftDependentCount; i++)
                {
                    updatePhraseStructureGraph(graph, target.getLeftDependent(i).HeadEdge, attachHeadSpineToRoot);
                }
                for (int i = target.RightDependentCount - 1; i >= 0; i--)
                {
                    updatePhraseStructureGraph(graph, target.getRightDependent(i).HeadEdge, attachHeadSpineToRoot);
                }
            }
        }
Exemple #21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private boolean projectiveInterval(org.maltparser.core.syntaxgraph.DependencyStructure parse, org.maltparser.core.syntaxgraph.node.DependencyNode left, org.maltparser.core.syntaxgraph.node.DependencyNode right) throws org.maltparser.core.exception.MaltChainedException
        private bool projectiveInterval(IDependencyStructure parse, DependencyNode left, DependencyNode right)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int l = swapArray.get(left.getIndex());
            int l = swapArray[left.Index];
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int r = swapArray.get(right.getIndex());
            int            r    = swapArray[right.Index];
            DependencyNode node = null;

            if (l > r)
            {
                return(false);
            }
            else
            {
                for (int i = l + 1; i < r; i++)
                {
                    for (int j = 0; j < swapArray.Count; j++)
                    {
                        if (swapArray[j] == i)
                        {
                            node = parse.GetDependencyNode(j);
                            break;
                        }
                    }
                    while (node.hasHead())
                    {
                        node = node.Head;
                    }
                    if (!(node == left || node == right))
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
 public void Init()
 {
     //create a dependency that contains a unary expression (NOT)
     dependency = DependencyNode.Create(() => !SomeBool);
     dependency.DependencyChanged += delegate { eventCounter++; };
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void update() throws org.maltparser.core.exception.MaltChainedException
        public void update()
        {
            // Retrieve the address value
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.feature.value.AddressValue arg1 = addressFunction1.getAddressValue();
            AddressValue arg1 = addressFunction1.AddressValue;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.feature.value.AddressValue arg2 = addressFunction2.getAddressValue();
            AddressValue arg2 = addressFunction2.AddressValue;

            try
            {
                if (arg1.Address == null || arg2.Address == null)
                {
                    featureValue.IndexCode = table.getNullValueCode(NullValueId.NO_NODE);
                    featureValue.Symbol    = table.getNullValueSymbol(NullValueId.NO_NODE);
                    featureValue.NullValue = true;
                }
                else
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.syntaxgraph.node.DependencyNode node1 = (org.maltparser.core.syntaxgraph.node.DependencyNode)arg1.getAddress();
                    DependencyNode node1 = (DependencyNode)arg1.Address;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.syntaxgraph.node.DependencyNode node2 = (org.maltparser.core.syntaxgraph.node.DependencyNode)arg2.getAddress();
                    DependencyNode node2 = (DependencyNode)arg2.Address;

                    int head1 = -1;
                    int head2 = -1;

                    if (node1.hasHead())
                    {
                        head1 = node1.Head.Index;                         //lines below don't seem to work
                        //head1 = Integer.parseInt(node1.getHeadEdgeLabelSymbol(column.getSymbolTable()));
                        //if ( node1.hasHeadEdgeLabel(column.getSymbolTable()) )
                        //	head1 = Integer.parseInt(node1.getHeadEdgeLabelSymbol(column.getSymbolTable()));
                    }
                    if (node2.hasHead())
                    {
                        head2 = node2.Head.Index;                         //lines below don't seem to work
                        //head2 = Integer.parseInt(node2.getHeadEdgeLabelSymbol(column.getSymbolTable()));
                        //if ( node2.hasHeadEdgeLabel(column.getSymbolTable()) )
                        //	head2 = Integer.parseInt(node2.getHeadEdgeLabelSymbol(column.getSymbolTable()));
                    }
                    if (!node1.Root && head1 == node2.Index)
                    {
                        featureValue.IndexCode = table.getSymbolStringToCode("LEFT");
                        featureValue.Symbol    = "LEFT";
                        featureValue.NullValue = false;
                    }
                    else if (!node2.Root && head2 == node1.Index)
                    {
                        featureValue.IndexCode = table.getSymbolStringToCode("RIGHT");
                        featureValue.Symbol    = "RIGHT";
                        featureValue.NullValue = false;
                    }
                    else
                    {
                        featureValue.IndexCode = table.getNullValueCode(NullValueId.NO_NODE);
                        featureValue.Symbol    = table.getNullValueSymbol(NullValueId.NO_NODE);
                        featureValue.NullValue = true;
                    }
                }
            }
            catch (FormatException e)
            {
                throw new FeatureException("The index of the feature must be an integer value. ", e);
            }
            featureValue.Value = 1;
        }
Exemple #24
0
        private DependencyNode breadthFirstSearchSortedByDistanceForPath(IDependencyStructure dg, DependencyNode start, DependencyNode avoid)
        {
            DependencyNode        dependent;
            List <DependencyNode> nodes = new List <DependencyNode>(), newNodes;

            nodes.AddRange(findAllDependentsVectorSortedByDistanceToPProjNode(dg, start, avoid, true));
            while (nodes.Count > 0)
            {
                dependent = nodes.RemoveAt(0);
                if (((newNodes = findAllDependentsVectorSortedByDistanceToPProjNode(dg, dependent, avoid, true)).Count) == 0)
                {
                    return(dependent);
                }
                nodes.AddRange(newNodes);
            }
            return(null);
        }
Exemple #25
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void updateDependencyEdges(org.maltparser.core.syntaxgraph.MappablePhraseStructureGraph graph, org.maltparser.core.syntaxgraph.node.PhraseStructureNode top) throws org.maltparser.core.exception.MaltChainedException
        private void updateDependencyEdges(MappablePhraseStructureGraph graph, PhraseStructureNode top)
        {
            if (top == null)
            {
                return;
            }
            DependencyNode head      = null;
            DependencyNode dependent = null;

            if (top is NonTerminalNode)
            {
                foreach (PhraseStructureNode node in ((NonTerminalNode)top).Children)
                {
                    if (node is NonTerminalNode)
                    {
                        updateDependencyEdges(graph, node);
                    }
                    else
                    {
                        head      = ((NonTerminalNode)top).getLexicalHead(headRules);
                        dependent = (DependencyNode)node;
                        if (head != null && dependent != null && head != dependent)
                        {
                            lockUpdate = true;
                            if (!dependent.hasHead())
                            {
                                graph.addDependencyEdge(head, dependent);
                            }
                            else if (head != dependent.Head)
                            {
                                graph.moveDependencyEdge(head, dependent);
                            }
                            lockUpdate = false;
                        }
                    }
                }
            }

            head = null;
            if (top.Parent != null)
            {
                head = ((NonTerminalNode)top.Parent).getLexicalHead(headRules);
            }
            else if (top.Root)
            {
                head = (DependencyNode)top;
            }

            if (top is NonTerminalNode)
            {
                dependent = ((NonTerminalNode)top).getLexicalHead(headRules);
            }
            else if (!top.Root)
            {
                dependent = (DependencyNode)top;
            }
            if (head != null && dependent != null && head != dependent)
            {
                lockUpdate = true;
                if (!dependent.hasHead())
                {
                    graph.addDependencyEdge(head, dependent);
                }
                else if (head != dependent.Head)
                {
                    graph.moveDependencyEdge(head, dependent);
                }
                lockUpdate = false;
            }
        }
        public void Init()
        {
            eventCounter = 0;
              lastEventArgs = null;

              course = new Course();
              for (int i = 0; i < 10; i++)
              {
            var student = TestUtil.CreateTestStudent();
            student.Name = "Student " + i;
            course.Students.Add(student);
              }

              dependency = DependencyNode.Create(() => course.Students);
              dependency.DependencyChanged += OnDependencyChanged;
        }
 public void Init()
 {
     //create a dependency that contains a unary expression (NOT)
       dependency = DependencyNode.Create(() => !SomeBool);
       dependency.DependencyChanged += delegate { eventCounter++; };
 }
Exemple #28
0
 public MyApplication()
 {
     //create a dependency on the city of the student's school
     dependency = DependencyNode.Create(() => MyStudent.School.Address.City);
     dependency.DependencyChanged += OnStudentCityChanged;
 }
            public void GetDependencyDepth()
            {
                // TODO: Fill this method to find how many dependencies needs to be validated before this one will
                // Like that it will be easy to paint into the graph in columns
                Queue <DependencyNode> dependenciesToVisit        = new Queue <DependencyNode>(dependencies);
                List <DependencyNode>  alreadyVisitedDependencies = new List <DependencyNode>(dependencies);

                if (dependencies == null || dependencies.Count == 0)
                {
                    depth           = someIsDependentOfMe ? 1 : 0;
                    nodeRectangle.x = nodeRectangle.width * depth;
                    return;
                }
                depth           = 2;
                nodeRectangle.x = (nodeRectangle.width + 100) * depth;

                List <DependencyNode> newDependenciesToVisit = new List <DependencyNode>();

                while (dependenciesToVisit.Count > 0)
                {
                    DependencyNode node = dependenciesToVisit.Dequeue();
                    if (node.IsDepdendent)
                    {
                        foreach (DependencyNode n in node.dependencies)
                        {
                            if (!alreadyVisitedDependencies.Contains(n) && !newDependenciesToVisit.Contains(n))
                            {
                                newDependenciesToVisit.Add(n);
                            }
                        }
                    }
                    else
                    {
                        return;
                    }

                    alreadyVisitedDependencies.Add(node);

                    if (dependenciesToVisit.Count == 0 && newDependenciesToVisit.Count > 0)
                    {
                        depth++;
                        nodeRectangle.x = (nodeRectangle.width + 100) * depth;
                        bool cont = false;
                        foreach (DependencyNode depNode in newDependenciesToVisit)
                        {
                            if (!alreadyVisitedDependencies.Contains(depNode))
                            {
                                cont = true;
                            }
                        }
                        if (cont)
                        {
                            dependenciesToVisit = new Queue <DependencyNode>(newDependenciesToVisit);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
 public static bool InSameDatabase(this SqlSmoObject sqlSmoObject, DependencyNode x)
 {
     return 0 == string.Compare(
         x.Urn.GetNameForType(Const.Database),
         sqlSmoObject.Urn.GetNameForType(Const.Database),
         StringComparison.InvariantCultureIgnoreCase);
 }
Exemple #31
0
 static IEnumerable <DependencyNode <ContributorNotification> > GetCompatibleTypes(DependencyTree <ContributorNotification> tree,
                                                                                   DependencyNode <ContributorNotification> notificationNode,
                                                                                   IEnumerable <Type> beforeTypes)
 {
     return(from childType in beforeTypes
            from compatibleNode in tree.Nodes
            where compatibleNode != notificationNode &&
            childType.IsAssignableFrom(compatibleNode.Value.Contributor.GetType())
            select compatibleNode);
 }
Exemple #32
0
 public DependencyNode(string ownerPath, DependencyNode parent) : this(AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(ownerPath))
 {
     Parent = parent;
     Space  = Parent.Space + 20;
 }
        /// <summary>
        /// Cause the feature function to update the feature value.
        /// </summary>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void update() throws org.maltparser.core.exception.MaltChainedException
        public void update()
        {
            // Retrieve the address value
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.feature.value.AddressValue arg1 = addressFunction1.getAddressValue();
            AddressValue arg1 = addressFunction1.AddressValue;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.feature.value.AddressValue arg2 = addressFunction2.getAddressValue();
            AddressValue arg2 = addressFunction2.AddressValue;

            //		featureValue.setKnown(true);
            // if arg1 or arg2 is null, then set a NO_NODE null value as feature value
            if (arg1.Address == null || arg2.Address == null)
            {
                featureValue.IndexCode = table.getNullValueCode(NullValueId.NO_NODE);
                featureValue.Symbol    = table.getNullValueSymbol(NullValueId.NO_NODE);
                featureValue.Value     = 1;

                featureValue.NullValue = true;
            }
            else
            {
                // Unfortunately this method takes a lot of time  arg1.getAddressClass().asSubclass(org.maltparser.core.syntaxgraph.node.DependencyNode.class);
                // Cast the address arguments to dependency nodes
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.syntaxgraph.node.DependencyNode node1 = (org.maltparser.core.syntaxgraph.node.DependencyNode)arg1.getAddress();
                DependencyNode node1 = (DependencyNode)arg1.Address;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.syntaxgraph.node.DependencyNode node2 = (org.maltparser.core.syntaxgraph.node.DependencyNode)arg2.getAddress();
                DependencyNode node2 = (DependencyNode)arg2.Address;

                if (!node1.Root && !node2.Root)
                {
                    // Calculates the distance
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int index1 = node1.getIndex();
                    int index1 = node1.Index;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int index2 = node2.getIndex();
                    int index2 = node2.Index;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int distance = Math.abs(index1-index2);
                    int distance = Math.Abs(index1 - index2);


                    int  lower = -1;
                    bool f     = false;
                    foreach (int?upper in normalization.Keys)
                    {
                        if (distance >= lower && distance < upper.Value)
                        {
                            featureValue.IndexCode = table.getSymbolStringToCode(normalization[lower]);
                            featureValue.Symbol    = normalization[lower];
                            featureValue.Value     = 1;
                            f = true;
                            break;
                        }
                        lower = upper.Value;
                    }
                    if (f == false)
                    {
                        featureValue.IndexCode = table.getSymbolStringToCode(normalization[lower]);
                        featureValue.Symbol    = normalization[lower];
                        featureValue.Value     = 1;
                    }

                    // Tells the feature value that the feature is known and is not a null value

                    featureValue.NullValue = false;
                }
                else
                {
                    // if node1 or node2 is a root node, set a ROOT_NODE null value as feature value
                    featureValue.IndexCode = table.getNullValueCode(NullValueId.ROOT_NODE);
                    featureValue.Symbol    = table.getNullValueSymbol(NullValueId.ROOT_NODE);
                    featureValue.Value     = 1;
                    featureValue.NullValue = true;
                }
            }
        }
Exemple #34
0
        void OnGUINode(DependencyNode node, bool forceDisplay = false)
        {
            if (!node.IsChecked)
            {
                node.Check();
            }

            if (!forceDisplay && !node.RequireDisplay)
            {
                return;
            }

            bool beginDisabledGroup = false;

            if (forceDisplay && !node.RequireDisplay)
            {
                EditorGUI.BeginDisabledGroup(true);
                beginDisabledGroup = true;
            }

            int arrowWidth = 20;
            int iconWidth  = 16;

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Space(node.Space);
                if (node.HasDependencies)
                {
                    if (GUILayout.Button((node.IsOpened ? " ▼" : " ▶︎"), GUI.skin.label, GUILayout.Width(arrowWidth)))
                    {
                        node.IsOpened = !node.IsOpened;
                    }
                }
                else
                {
                    if (GUILayout.Button("  ", GUI.skin.label, GUILayout.Width(arrowWidth)))
                    {
                    }
                }

                var rect = GUILayoutUtility.GetLastRect();
                rect.x += iconWidth;
                GUI.DrawTexture(rect, node.Icon, ScaleMode.ScaleToFit);
                GUILayout.Space(iconWidth - 3);
                if (GUILayout.Button(node.Owner.name, GUI.skin.label))
                {
                    EditorGUIUtility.PingObject(node.Owner);
                }
            }

            if (node.IsOpened)
            {
                if (node.HasDependencies)
                {
                    using (new EditorGUI.IndentLevelScope())
                    {
                        foreach (var dependencyNode in node.Dependencies)
                        {
                            OnGUINode(dependencyNode);
                        }
                    }
                }
            }

            if (beginDisabledGroup)
            {
                EditorGUI.EndDisabledGroup();
            }
        }
        /// <summary>
        /// Add to the seen list for tracking.
        /// </summary>
        /// <returns>True if the node should be walked</returns>
        private static bool AddToSeen(Dictionary <string, NodeWarningProperties> seen, DependencyNode node)
        {
            var id        = node.Id;
            var nodeProps = node.NodeWarningProperties;

            if (!seen.TryGetValue(id, out var visitedProps))
            {
                // New id
                seen.Add(id, nodeProps);
                return(true);
            }

            if (!nodeProps.IsSubSetOf(visitedProps))
            {
                // Find the intersection of properties between these nodes,
                // these are the only properties that we need to look for in
                // future passes.
                seen[id] = nodeProps.GetIntersect(visitedProps);
                return(true);
            }

            // This has already been walked
            return(false);
        }
 /// <summary>
 /// Inits the <see cref="Dependency"/> property. The default implementation
 /// registers a dependency on the school's city.
 /// </summary>
 protected virtual void CreateDependency()
 {
     Dependency = DependencyNode.Create(() => Student.School.Address.City);
 }
Exemple #37
0
 private void IterateNodes(DependencyNode node, AttributeContext<DependsOnAttribute> context, IModule item, ref bool added)
 {
     if (node.Nodes.ContainsKey(context.AttributeInstance.DependencyType))
     {
         node.Nodes[context.AttributeInstance.DependencyType].Nodes.Add(item.GetType(), new DependencyNode(item));
         added = true;
     }
     else if (node.Nodes.Count == 0)
     {
         added = false;
     }
     else
     {
         foreach (var child in node.Nodes.Values)
         {
             IterateNodes(child, context, item, ref added);
         }
     }
 }
Exemple #38
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.history.action.GuideUserAction predict(org.maltparser.core.syntaxgraph.DependencyStructure gold, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override GuideUserAction predict(IDependencyStructure gold, ParserConfiguration config)
        {
            TwoPlanarConfig      planarConfig      = (TwoPlanarConfig)config;
            IDependencyStructure dg                = planarConfig.DependencyGraph;
            DependencyNode       activeStackPeek   = planarConfig.ActiveStack.Peek();
            DependencyNode       inactiveStackPeek = planarConfig.InactiveStack.Peek();
            int activeStackPeekIndex               = activeStackPeek.Index;
            int inactiveStackPeekIndex             = inactiveStackPeek.Index;
            int inputPeekIndex = planarConfig.Input.Peek().Index;

            //System.out.println("Initting crossings");

            if (crossingsGraph == null)
            {
                initCrossingsGraph(gold);
            }

            //System.out.println("Crossings initted");

            if (!activeStackPeek.Root && gold.GetTokenNode(activeStackPeekIndex).Head.Index == inputPeekIndex && !checkIfArcExists(dg, inputPeekIndex, activeStackPeekIndex))
            {
                if (planarConfig.StackActivityState == TwoPlanarConfig.FIRST_STACK)
                {
                    propagatePlaneConstraint(gold.GetTokenNode(activeStackPeekIndex).HeadEdge, FIRST_PLANE);
                }
                else
                {
                    propagatePlaneConstraint(gold.GetTokenNode(activeStackPeekIndex).HeadEdge, SECOND_PLANE);
                }
                //System.out.println("From " + inputPeekIndex + " to " + activeStackPeekIndex);
                return(updateActionContainers(TwoPlanar.LEFTARC, gold.GetTokenNode(activeStackPeekIndex).HeadEdge.LabelSet));
            }

            else if (gold.GetTokenNode(inputPeekIndex).Head.Index == activeStackPeekIndex && !checkIfArcExists(dg, activeStackPeekIndex, inputPeekIndex))
            {
                if (planarConfig.StackActivityState == TwoPlanarConfig.FIRST_STACK)
                {
                    propagatePlaneConstraint(gold.GetTokenNode(inputPeekIndex).HeadEdge, FIRST_PLANE);
                }
                else
                {
                    propagatePlaneConstraint(gold.GetTokenNode(inputPeekIndex).HeadEdge, SECOND_PLANE);
                }
                //System.out.println("From " + activeStackPeekIndex + " to " + inputPeekIndex);
                return(updateActionContainers(TwoPlanar.RIGHTARC, gold.GetTokenNode(inputPeekIndex).HeadEdge.LabelSet));
            }

            else if (!inactiveStackPeek.Root && gold.GetTokenNode(inactiveStackPeekIndex).Head.Index == inputPeekIndex && !checkIfArcExists(dg, inputPeekIndex, inactiveStackPeekIndex))
            {
                //need to create link, but on the other plane!!
                //TODO is this if branch really necessary? i.e. will this happen? (later branches already switch)
                //System.out.println("Switch one");
                return(updateActionContainers(TwoPlanar.SWITCH, null));
            }

            else if (gold.GetTokenNode(inputPeekIndex).Head.Index == inactiveStackPeekIndex && !checkIfArcExists(dg, inactiveStackPeekIndex, inputPeekIndex))
            {
                //need to create link, but on the other plane!!
                //TODO is this if branch really necessary? i.e. will this happen? (later branches already switch)
                //System.out.println("Switch two");
                return(updateActionContainers(TwoPlanar.SWITCH, null));
            }

            else if (getFirstPendingLinkOnActivePlane(planarConfig, gold) != null)
            {
                //System.out.println("Reduce one");
                return(updateActionContainers(TwoPlanar.REDUCE, null));
            }

            else if (getFirstPendingLinkOnInactivePlane(planarConfig, gold) != null)
            {
                //System.out.println("Switch for reducing");
                return(updateActionContainers(TwoPlanar.SWITCH, null));
            }

            //TODO: double reduce somehow? (check if reduced node is not covered by links of the other plane, or something like that).

            else
            {
                //System.out.println("Shift");
                return(updateActionContainers(TwoPlanar.SHIFT, null));
            }
        }
 public void Monitoring_A_Collection_Item_Should_Work()
 {
     //this is currently not supported
     var dep = DependencyNode.Create(() => course.Students.FirstOrDefault(s => s.Age > 20));
 }
 private bool CheckDependenciesExist(DependencyNode node)
 {
     HashSet<string> effectiveExistingObjectNames = new HashSet<string>(existingObjectNames, existingObjectNames.Comparer);
     effectiveExistingObjectNames.ExceptWith(dependencies.Keys);
     return effectiveExistingObjectNames.IsSupersetOf(node.Edges);
 }
Exemple #41
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private boolean necessarySwap(org.maltparser.core.syntaxgraph.DependencyStructure gold, org.maltparser.core.syntaxgraph.DependencyStructure parse, org.maltparser.core.syntaxgraph.node.DependencyNode node, java.util.Stack<org.maltparser.core.syntaxgraph.node.DependencyNode> input) throws org.maltparser.core.exception.MaltChainedException
        private bool necessarySwap(IDependencyStructure gold, IDependencyStructure parse, DependencyNode node, Stack <DependencyNode> input)
        {
            DependencyNode left  = node;
            int            index = input.Count - 1;

            if (index < 0)
            {
                return(true);
            }
            DependencyNode right = input.Peek();

            int rc = -1;

            while (projectiveInterval(parse, left, right))
            {
                if (rc == right.Index)
                {
                    return(false);
                }
                if (gold.GetDependencyNode(node.Index).Head.Index == right.Index)
                {
                    return(!leftComplete(gold, node));
                }
                if (gold.GetDependencyNode(right.Index).Head.Index == node.Index)
                {
                    if (gold.GetDependencyNode(right.Index).hasRightDependent())
                    {
                        rc = gold.GetDependencyNode(right.Index).RightmostProperDescendantIndex;
                    }
                    else
                    {
                        return(false);
                    }
                }
                if (index > 0)
                {
                    left = right;
//JAVA TO C# CONVERTER TODO TASK: There is no direct .NET Stack equivalent to Java Stack methods based on internal indexing:
                    right = input.get(--index);
                }
                else
                {
                    break;
                }
            }

            return(true);
        }
 private IEnumerable<DependencyNode> GetAllDependencies(DependencyNode node)
 {
     HashSet<DependencyNode> result = new HashSet<DependencyNode>();
     Queue<DependencyNode> queue = new Queue<DependencyNode>();
     queue.Enqueue(node);
     do {
         DependencyNode dependencyNode = queue.Dequeue();
         if (result.Add(dependencyNode)) {
             foreach (string edge in dependencyNode.Edges) {
                 List<DependencyNode> dependencyNodes;
                 if (dependencies.TryGetValue(edge, out dependencyNodes)) {
                     foreach (DependencyNode innerDependency in dependencyNodes) {
                         queue.Enqueue(innerDependency);
                     }
                 }
             }
         }
     } while (queue.Count > 0);
     return result;
 }
Exemple #43
0
        private String GetCodeForNodeData(List <NodeDataSection> nodeDataSections, Relocation[] relocs, byte[] byteData, DependencyNode node, int offset, NodeFactory factory)
        {
            CppGenerationBuffer nodeDataDecl = new CppGenerationBuffer();
            int relocCounter       = 0;
            int divisionStartIndex = offset;

            nodeDataDecl.Indent();
            nodeDataDecl.Indent();
            nodeDataDecl.AppendLine();

            for (int i = 0; i < nodeDataSections.Count; i++)
            {
                if (nodeDataSections[i].SectionType == NodeDataSectionType.Relocation)
                {
                    Relocation reloc = relocs[relocCounter];
                    nodeDataDecl.Append(GetCodeForReloc(reloc, node, factory));
                    nodeDataDecl.Append(",");
                    relocCounter++;
                }
                else
                {
                    AppendFormattedByteArray(nodeDataDecl, byteData, divisionStartIndex, divisionStartIndex + nodeDataSections[i].SectionSize);
                    nodeDataDecl.Append(",");
                }
                divisionStartIndex += nodeDataSections[i].SectionSize;
                nodeDataDecl.AppendLine();
            }
            return(nodeDataDecl.ToString());
        }
 private void RemoveDependency(DependencyNode node)
 {
     List<DependencyNode> dependencyNodes = dependencies[node.ObjectName];
     dependencyNodes.Remove(node);
     if (dependencyNodes.Count == 0) {
         dependencies.Remove(node.ObjectName);
         existingObjectNames.Add(node.ObjectName);
     }
 }