@@ -0,0 +1,2887 @@
+/*%0A * Copyright 2017 SFB 632.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage annis.utils;%0A%0Aimport java.net.URI;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Set;%0Aimport org.corpus_tools.salt.SaltFactory;%0Aimport org.corpus_tools.salt.common.SDocumentGraph;%0Aimport org.corpus_tools.salt.common.SDominanceRelation;%0Aimport org.corpus_tools.salt.common.STextOverlappingRelation;%0Aimport org.corpus_tools.salt.common.SToken;%0Aimport org.corpus_tools.salt.core.GraphTraverseHandler;%0Aimport org.corpus_tools.salt.core.SGraph;%0Aimport org.corpus_tools.salt.core.SNode;%0Aimport org.corpus_tools.salt.core.SRelation;%0A%0A/**%0A *%0A * @author Thomas Krause %3Cthomaskrause@posteo.de%3E%0A */%0Apublic class SubgraphExtractor implements GraphTraverseHandler%0A%7B%0A  %0A  private final List%3CSNode%3E reachableNodes = new LinkedList%3C%3E();%0A  %0A  public static SDocumentGraph extract(SDocumentGraph old, Set%3CURI%3E contextToken)%0A  %7B%0A   %0A    if(contextToken != null && old != null)%0A    %7B%0A      List%3CSNode%3E startNodes = new LinkedList%3C%3E();%0A      for(URI id : contextToken)%0A      %7B%0A        SNode tok = old.getNode(id.getFragment());%0A        if(tok != null && tok instanceof SToken)%0A        %7B%0A          startNodes.add(tok);%0A        %7D%0A      %7D%0A      SubgraphExtractor extractor = new SubgraphExtractor();%0A      old.traverse(startNodes, SGraph.GRAPH_TRAVERSE_TYPE.BOTTOM_UP_DEPTH_FIRST, %22SubgraphExtractor%22, extractor);%0A      %0A      // create a new graph and add all original nodes, this will alter the old graph%0A      SDocumentGraph result = SaltFactory.createSDocumentGraph();%0A      for(SNode n : extractor.reachableNodes)%0A      %7B%0A        result.addNode(n);%0A      %7D%0A      return result;%0A      %0A    %7D%0A    %0A    return null;%0A  %7D%0A%0A  @Override%0A  public void nodeReached(SGraph.GRAPH_TRAVERSE_TYPE traversalType, String traversalId, SNode currNode, SRelation%3CSNode, SNode%3E relation, SNode fromNode, long order)%0A  %7B%0A    reachableNodes.add(currNode);%0A  %7D%0A%0A  @Override%0A  public void nodeLeft(SGraph.GRAPH_TRAVERSE_TYPE traversalType, String traversalId, SNode currNode, SRelation%3CSNode, SNode%3E relation, SNode fromNode, long order)%0A  %7B%0A  %7D%0A%0A  @Override%0A  public boolean checkConstraint(SGraph.GRAPH_TRAVERSE_TYPE traversalType, String traversalId, SRelation%3CSNode, SNode%3E relation, SNode currNode, long order)%0A  %7B%0A    return relation == null %7C%7C relation instanceof STextOverlappingRelation;%0A  %7D%0A  %0A%7D%0A

Add dummy subgraph extractor.