@Test public void testTraveseWithTerminate() { traverseCount = 0; graph.traverse( 10, Collections.singletonList(dA), (d, f, t, h) -> { traverseCount++; return false; }); assertEquals(1, traverseCount); }
public void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate) { if (distance <= 0) { return; } final ImmutableStack<WordToken> history = new ImmutableStack<>(); for (final Dependency d : start) { if (predicate.test(d, null, d.getDependent(), history)) { ImmutableStack<WordToken> stack = history.push(d.getDependent()); traverse(distance, d.getDependent(), stack, predicate); } } }
DependencyGraph { public void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate) { if (distance <= 0) { return; } final ImmutableStack<WordToken> history = new ImmutableStack<>(); for (final Dependency d : start) { if (predicate.test(d, null, d.getDependent(), history)) { ImmutableStack<WordToken> stack = history.push(d.getDependent()); traverse(distance, d.getDependent(), stack, predicate); } } } }
DependencyGraph { public void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate) { if (distance <= 0) { return; } final ImmutableStack<WordToken> history = new ImmutableStack<>(); for (final Dependency d : start) { if (predicate.test(d, null, d.getDependent(), history)) { ImmutableStack<WordToken> stack = history.push(d.getDependent()); traverse(distance, d.getDependent(), stack, predicate); } } } private  DependencyGraph(); private  DependencyGraph(
      SetMultimap<WordToken, Edge> edges,
      Map<WordToken, Dependency> dependentMap,
      SetMultimap<WordToken, Dependency> governorMap,
      SetMultimap<String, WordToken> partOfSpeechMap); }
DependencyGraph { public void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate) { if (distance <= 0) { return; } final ImmutableStack<WordToken> history = new ImmutableStack<>(); for (final Dependency d : start) { if (predicate.test(d, null, d.getDependent(), history)) { ImmutableStack<WordToken> stack = history.push(d.getDependent()); traverse(distance, d.getDependent(), stack, predicate); } } } private  DependencyGraph(); private  DependencyGraph(
      SetMultimap<WordToken, Edge> edges,
      Map<WordToken, Dependency> dependentMap,
      SetMultimap<WordToken, Dependency> governorMap,
      SetMultimap<String, WordToken> partOfSpeechMap); Dependency getDependency(WordToken word); Set<Dependency> getGovernors(WordToken word); Stream<WordToken> getEdges(WordToken word); Set<WordToken> extractWords(final int distance, final Dependency... start); Set<WordToken> extractWords(
      final int distance, Predicate<Dependency> predicate, final Dependency... start); Set<WordToken> extractWords(
      final int distance, Predicate<Dependency> predicate, final Collection<Dependency> start); Set<WordToken> nearestWords(final int distance, final WordToken... start); Set<WordToken> nearestWords(
      final int distance, Predicate<Dependency> predicate, final WordToken... start); Set<WordToken> nearestWords(
      final int distance, Predicate<Dependency> predicate, final Collection<WordToken> start); void log(); DependencyGraph filter(Predicate<WordToken> predicate); Set<WordToken> getWords(); List<WordToken> shortestPath(
      Collection<WordToken> from, Collection<WordToken> to, int maxDistance); static DependencyGraph build(final JCas jCas); static DependencyGraph build(final JCas jCas, AnnotationFS annnotation); void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate); Collection<DependencyMatch> match(DependencyTree dependencyTree); Optional<WordToken> getHeadNode(Entity annotation); Optional<WordToken> getHeadNode(List<WordToken> covered); DependencyTree minimalTree(Collection<WordToken> tokens); }
DependencyGraph { public void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate) { if (distance <= 0) { return; } final ImmutableStack<WordToken> history = new ImmutableStack<>(); for (final Dependency d : start) { if (predicate.test(d, null, d.getDependent(), history)) { ImmutableStack<WordToken> stack = history.push(d.getDependent()); traverse(distance, d.getDependent(), stack, predicate); } } } private  DependencyGraph(); private  DependencyGraph(
      SetMultimap<WordToken, Edge> edges,
      Map<WordToken, Dependency> dependentMap,
      SetMultimap<WordToken, Dependency> governorMap,
      SetMultimap<String, WordToken> partOfSpeechMap); Dependency getDependency(WordToken word); Set<Dependency> getGovernors(WordToken word); Stream<WordToken> getEdges(WordToken word); Set<WordToken> extractWords(final int distance, final Dependency... start); Set<WordToken> extractWords(
      final int distance, Predicate<Dependency> predicate, final Dependency... start); Set<WordToken> extractWords(
      final int distance, Predicate<Dependency> predicate, final Collection<Dependency> start); Set<WordToken> nearestWords(final int distance, final WordToken... start); Set<WordToken> nearestWords(
      final int distance, Predicate<Dependency> predicate, final WordToken... start); Set<WordToken> nearestWords(
      final int distance, Predicate<Dependency> predicate, final Collection<WordToken> start); void log(); DependencyGraph filter(Predicate<WordToken> predicate); Set<WordToken> getWords(); List<WordToken> shortestPath(
      Collection<WordToken> from, Collection<WordToken> to, int maxDistance); static DependencyGraph build(final JCas jCas); static DependencyGraph build(final JCas jCas, AnnotationFS annnotation); void traverse(int distance, Collection<Dependency> start, TraversePredicate predicate); Collection<DependencyMatch> match(DependencyTree dependencyTree); Optional<WordToken> getHeadNode(Entity annotation); Optional<WordToken> getHeadNode(List<WordToken> covered); DependencyTree minimalTree(Collection<WordToken> tokens);  }