@@ -0,0 +1,2110 @@
+package annis;%0A%0Aimport org.corpus_tools.salt.common.SDocumentGraph;%0Aimport org.corpus_tools.salt.common.SOrderRelation;%0Aimport org.corpus_tools.salt.common.SSpan;%0Aimport org.corpus_tools.salt.common.SSpanningRelation;%0Aimport org.corpus_tools.salt.common.STextualDS;%0Aimport org.corpus_tools.salt.common.STimeline;%0Aimport org.corpus_tools.salt.common.SToken;%0Aimport org.corpus_tools.salt.core.SRelation;%0A%0Aimport com.google.common.collect.HashMultimap;%0Aimport com.google.common.collect.Multimap;%0Aimport com.google.common.collect.TreeMultimap;%0A%0A/**%0A * Allows to reconstruct a proper %7B@link SDocumentGraph%7D with an %7B@link STimeline%7D and%0A * several %7B@link SToken%7D connected by %7B@link SOrderRelation%7D from of a virtual tokenization.%0A * %0A * @author Thomas Krause %3Cthomaskrause@posteo.de%3E%0A *%0A */%0Apublic class TimelineReconstructor %7B%0A  %0A  private static Multimap%3CSSpan, Integer%3E addTimeline(SDocumentGraph graph)%0A  %7B%0A    Multimap%3CSSpan, Integer%3E spans2TimelinePos = HashMultimap.create();%0A    STimeline timeline = graph.createTimeline();%0A    for(SToken virtualTok : graph.getSortedTokenByText())%0A    %7B%0A      timeline.increasePointOfTime();%0A      // find all spans that are connected to this token and are part of an SOrderRelation%0A      for(SRelation%3C?,?%3E inRel : virtualTok.getInRelations())%0A      %7B%0A        if(inRel instanceof SSpanningRelation)%0A        %7B%0A          SSpanningRelation spanRel = (SSpanningRelation) inRel;%0A          SSpan overlappingSpan = spanRel.getSource();%0A          if(overlappingSpan != null)%0A          %7B%0A            spans2TimelinePos.put(overlappingSpan, timeline.getEnd());%0A          %7D%0A        %7D%0A      %7D%0A    %7D%0A    return spans2TimelinePos;%0A  %7D%0A  %0A  /**%0A   * Removes the virtual tokenization from a %7B@link SDocumentGraph%7D and replaces it with an%0A   * %7B@link STimeline%7D and multiple %7B@link STextualDS%7D.%0A   * %0A   * This alters the original graph.%0A   * @param orig%0A   * @return%0A   */%0A  public static void removeVirtualTokenization(SDocumentGraph graph)%0A  %7B%0A    if(graph.getTimeline() != null)%0A    %7B%0A      return;%0A    %7D%0A    %0A    Multimap%3CSSpan, Integer%3E spans2TimelinePos = addTimeline(graph);%0A  %7D%0A%7D%0A

add an unfinished class to reconstruct a proper SDocumentGraph with timeline from virtual tokenization