test_class.declarator: LOG = LoggerFactory.getLogger(ConstraintSolverTest.class)
test_class.modifier: static final
test_class.original_string: static final Logger LOG = LoggerFactory.getLogger(ConstraintSolverTest.class);
test_class.type: Logger
test_class.var_name: LOG
test_class.file: core/src/test/java/edu/tuberlin/dima/textmining/jedi/core/features/ConstraintSolverTest.java
test_class.identifier: ConstraintSolverTest
test_case.body: @Test
      public void testSolve() throws Exception {
  
          ConstraintSolver.ConstraintSolverBuilder<String> solverBuilder = new ConstraintSolver.ConstraintSolverBuilder<>();
  
  
          solverBuilder.add("E1", "E2", "x -> y", "1", "A", "D", 1, 1, 1);
          solverBuilder.add("E1", "E2", "x -> y", "2", "A#", "D", 3, 1, 1);
          solverBuilder.add("E2", "E3", "x -> y", "3", "D", "B", 1, 1, 1);
          solverBuilder.add("E1", "E3", "x -> y", "4", "A", "B", 1, 1, 1);
  
  
          solverBuilder.add("E3", "E4", "x -> y", "5", "B", "C", 1, 1, 1);
          PrintCollector printCollector = new PrintCollector(true);
  
          final List<DetectedRelation<String>> solve = solverBuilder.build().solve(printCollector);
  
          assertNotNull(solve);
          assertThat(solve.size(), is(4));
  
          assertThat(solve.get(0).getEdge(), is(new Edge(1, "1", "x -> y", "A", "D", 1, 1, 1, false)));
          assertThat(solve.get(1).getEdge(), is(new Edge(4, "4", "x -> y", "A", "B", 1, 1, 1, false)));
          assertThat(solve.get(2).getEdge(), is(new Edge(3, "3", "x -> y", "D", "B", 1, 1, 1, false)));
          assertThat(solve.get(3).getEdge(), is(new Edge(5, "5", "x -> y", "B", "C", 1, 1, 1, false)));
  
          printCollector.print(Joiner.on("\n").join(solve));
  
          printCollector.print(Graph.transform(solve).toString());
      }
test_case.class_method_signature: ConstraintSolverTest.testSolve()
test_case.full_signature: @Test public void testSolve()
test_case.identifier: testSolve
test_case.invocations: add add add add add solve build assertNotNull assertThat size is assertThat getEdge get is assertThat getEdge get is assertThat getEdge get is assertThat getEdge get is print join on print toString transform
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSolve()
focal_class.declarator: types
focal_class.modifier: final
focal_class.original_string: final Set<String> types;
focal_class.type: Set<String>
focal_class.var_name: types
focal_class.declarator: rel
focal_class.modifier: final
focal_class.original_string: final Table<String, String, String> rel;
focal_class.type: Table<String, String, String>
focal_class.var_name: rel
focal_class.declarator: graph
focal_class.original_string: Multigraph<T, Edge> graph;
focal_class.type: Multigraph<T, Edge>
focal_class.var_name: graph
focal_class.declarator: LOG = LoggerFactory.getLogger(ConstraintSolver.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(ConstraintSolver.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: orphanedVerticesPredicate = new Predicate<T>() {
          @Override
          public boolean apply(@Nullable T input) {
              return graph.degreeOf(input) == 0;
          }
      }
focal_class.modifier: private final
focal_class.original_string: private final Predicate<T> orphanedVerticesPredicate = new Predicate<T>() {
          @Override
          public boolean apply(@Nullable T input) {
              return graph.degreeOf(input) == 0;
          }
      };
focal_class.type: Predicate<T>
focal_class.var_name: orphanedVerticesPredicate
focal_class.declarator: solutionComparator = (o1, o2) -> {
  
          // compare size of detectedRelation chain as well
          return ComparisonChain.start()/*.compare(o1.size(), o2.size())*/.compare(score(o1), score(o2)).result();
      }
focal_class.modifier: private final
focal_class.original_string: private final Comparator<List<DetectedRelation<T>>> solutionComparator = (o1, o2) -> {
  
          // compare size of detectedRelation chain as well
          return ComparisonChain.start()/*.compare(o1.size(), o2.size())*/.compare(score(o1), score(o2)).result();
      };
focal_class.type: Comparator<List<DetectedRelation<T>>>
focal_class.var_name: solutionComparator
focal_class.declarator: emptyList = Lists.<DetectedRelation<T>>newArrayList()
focal_class.modifier: private final
focal_class.original_string: private final List<DetectedRelation<T>> emptyList = Lists.<DetectedRelation<T>>newArrayList();
focal_class.type: List<DetectedRelation<T>>
focal_class.var_name: emptyList
focal_class.declarator: vertexToString = new Function<T, String>() {
          @Nullable
          @Override
          public String apply(@Nullable T input) {
              return transformToString(input) + " " + input.hashCode();
          }
      }
focal_class.modifier: private final
focal_class.original_string: private final Function<T, String> vertexToString = new Function<T, String>() {
          @Nullable
          @Override
          public String apply(@Nullable T input) {
              return transformToString(input) + " " + input.hashCode();
          }
      };
focal_class.type: Function<T, String>
focal_class.var_name: vertexToString
focal_class.file: core/src/main/java/edu/tuberlin/dima/textmining/jedi/core/features/ConstraintSolver.java
focal_class.identifier: ConstraintSolver
focal_class.class_method_signature: ConstraintSolver.ConstraintSolver(Set<String> types, Table<String, String, String> rel, Multigraph<T, Edge> graph)
focal_class.full_signature: private  ConstraintSolver(Set<String> types, Table<String, String, String> rel, Multigraph<T, Edge> graph)
focal_class.identifier: ConstraintSolver
focal_class.modifiers: private
focal_class.parameters: (Set<String> types, Table<String, String, String> rel, Multigraph<T, Edge> graph)
focal_class.signature:  ConstraintSolver(Set<String> types, Table<String, String, String> rel, Multigraph<T, Edge> graph)
focal_class.class_method_signature: ConstraintSolver.score(List<DetectedRelation<T>> detectedRelation)
focal_class.full_signature: private float score(List<DetectedRelation<T>> detectedRelation)
focal_class.identifier: score
focal_class.modifiers: private
focal_class.parameters: (List<DetectedRelation<T>> detectedRelation)
focal_class.return: float
focal_class.signature: float score(List<DetectedRelation<T>> detectedRelation)
focal_class.class_method_signature: ConstraintSolver.pruneGraph(PrintCollector printCollector)
focal_class.full_signature: private void pruneGraph(PrintCollector printCollector)
focal_class.identifier: pruneGraph
focal_class.modifiers: private
focal_class.parameters: (PrintCollector printCollector)
focal_class.return: void
focal_class.signature: void pruneGraph(PrintCollector printCollector)
focal_class.class_method_signature: ConstraintSolver.solve(PrintCollector printCollector)
focal_class.full_signature: public List<DetectedRelation<T>> solve(PrintCollector printCollector)
focal_class.identifier: solve
focal_class.modifiers: public
focal_class.parameters: (PrintCollector printCollector)
focal_class.return: List<DetectedRelation<T>>
focal_class.signature: List<DetectedRelation<T>> solve(PrintCollector printCollector)
focal_class.class_method_signature: ConstraintSolver.solveConnectedComponent(PrintCollector printCollector, Set<T> connectedComponents)
focal_class.full_signature: private List<DetectedRelation<T>> solveConnectedComponent(PrintCollector printCollector, Set<T> connectedComponents)
focal_class.identifier: solveConnectedComponent
focal_class.modifiers: private
focal_class.parameters: (PrintCollector printCollector, Set<T> connectedComponents)
focal_class.return: List<DetectedRelation<T>>
focal_class.signature: List<DetectedRelation<T>> solveConnectedComponent(PrintCollector printCollector, Set<T> connectedComponents)
focal_class.class_method_signature: ConstraintSolver.internalSolve(final PrintCollector printCollector, final boolean initial)
focal_class.full_signature: private InternalSolveResult<T> internalSolve(final PrintCollector printCollector, final boolean initial)
focal_class.identifier: internalSolve
focal_class.modifiers: private
focal_class.parameters: (final PrintCollector printCollector, final boolean initial)
focal_class.return: InternalSolveResult<T>
focal_class.signature: InternalSolveResult<T> internalSolve(final PrintCollector printCollector, final boolean initial)
focal_class.class_method_signature: ConstraintSolver.generateSolution(final BiMap<Integer, String> typeMapping, Map<T, IntVar> encoding)
focal_class.full_signature: private List<DetectedRelation<T>> generateSolution(final BiMap<Integer, String> typeMapping, Map<T, IntVar> encoding)
focal_class.identifier: generateSolution
focal_class.modifiers: private
focal_class.parameters: (final BiMap<Integer, String> typeMapping, Map<T, IntVar> encoding)
focal_class.return: List<DetectedRelation<T>>
focal_class.signature: List<DetectedRelation<T>> generateSolution(final BiMap<Integer, String> typeMapping, Map<T, IntVar> encoding)
focal_class.class_method_signature: ConstraintSolver.transformToString(T node)
focal_class.full_signature: private static String transformToString(T node)
focal_class.identifier: transformToString
focal_class.modifiers: private static
focal_class.parameters: (T node)
focal_class.return: String
focal_class.signature: String transformToString(T node)
focal_method.body: public List<DetectedRelation<T>> solve(PrintCollector printCollector) {
  
          List<DetectedRelation<T>> detectedRelations = Lists.newArrayList();
  
          // prune graph
          pruneGraph(printCollector);
  
          ConnectivityInspector<T, Edge> connectivityInspector = new ConnectivityInspector<>(graph);
  
          List<Set<T>> connectedComponents = connectivityInspector.connectedSets();
  
  /*        for (Edge edge : graph.edgeSet()) {
              T edgeSource = graph.getEdgeSource(edge);
              T edgeTarget = graph.getEdgeTarget(edge);
              System.out.println(
                      Joiner.on(" ").join(transformToString(edgeSource), ((Annotation)edgeSource).getBegin(), ((Annotation)edgeSource).getEnd(), edgeSource.hashCode()) + "   ->  " +
                              Joiner.on(" ").join(((Annotation)edgeTarget).getCoveredText(),((Annotation)edgeTarget).getBegin(), ((Annotation)edgeTarget).getEnd(), edgeTarget.hashCode()));
          } */
  
          // solve each connected component separately
  
          // save the current state of the graph to revert
          final UndirectedGraph<T, Edge> restored = new Multigraph<>(Edge.class);
          Graphs.addGraph(restored, graph);
  
          printCollector.print(String.format("Graph has %2d components", connectedComponents.size()));
          for (Set<T> connectedComponent : connectedComponents) {
  
              // remove all vertices that are not part of the connected component
              printCollector.print(String.format("Solving connected component with %d vertices", connectedComponent.size()));
              //printCollector.print(Iterables.toString(Iterables.transform(connectedComponent, vertexToString)));
  
              // determine which nodes need to go
              HashSet<T> difference = Sets.newHashSet(Sets.difference(graph.vertexSet(), connectedComponent));
              graph.removeAllVertices(difference);
  
              detectedRelations.addAll(solveConnectedComponent(printCollector, connectedComponent));
  
              // restore graph
              Graphs.addGraph(graph, restored);
          }
  
          return detectedRelations;
      }
focal_method.class_method_signature: ConstraintSolver.solve(PrintCollector printCollector)
focal_method.full_signature: public List<DetectedRelation<T>> solve(PrintCollector printCollector)
focal_method.identifier: solve
focal_method.invocations: newArrayList pruneGraph connectedSets addGraph print format size print format size newHashSet difference vertexSet removeAllVertices addAll solveConnectedComponent addGraph
focal_method.modifiers: public
focal_method.parameters: (PrintCollector printCollector)
focal_method.return: List<DetectedRelation<T>>
focal_method.signature: List<DetectedRelation<T>> solve(PrintCollector printCollector)