Class ConcreteRegularTreeGrammar<E>

java.lang.Object
de.saar.chorus.domgraph.chart.RegularTreeGrammar<E>
de.saar.chorus.domgraph.chart.ConcreteRegularTreeGrammar<E>
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Chart, WeightedRegularTreeGrammar

public class ConcreteRegularTreeGrammar<E> extends RegularTreeGrammar<E> implements Cloneable
  • Field Details

    • chart

      protected Map<E,List<Split<E>>> chart
    • refcount

      protected Map<E,org._3pq.jgrapht.util.ModifiableInteger> refcount
    • size

      protected int size
    • toplevelSubgraphs

      protected List<E> toplevelSubgraphs
    • finalStates

      protected Set<E> finalStates
    • singletons

      protected Map<E,String> singletons
  • Constructor Details

    • ConcreteRegularTreeGrammar

      public ConcreteRegularTreeGrammar()
      The constructor.
  • Method Details

    • addSplit

      public void addSplit(E subgraph, Split<E> split)
      Adds a split for the given subgraph.
      Parameters:
      subgraph - a subgraph of some dominance graph
      split - a split of this subgraph
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • makeExplicit

      public static <E> ConcreteRegularTreeGrammar<E> makeExplicit(RegularTreeGrammar<E> rtg)
    • getLabelForSplit

      public String getLabelForSplit(Split<E> split)
    • countSubgraphs

      public int countSubgraphs()
    • getAllNonterminals

      public Set<E> getAllNonterminals()
      Specified by:
      getAllNonterminals in class RegularTreeGrammar<E>
    • recomputeSingletons

      public void recomputeSingletons()
      Recomputes the singleton subgraphs (in RTG language: the preterminal nonterminals) for the RTG. It is expected that this method is called whenever the RTG changes.
    • isSingleton

      public boolean isSingleton(E nt)
      Specified by:
      isSingleton in class RegularTreeGrammar<E>
    • getRootForSingleton

      public String getRootForSingleton(E nt)
      Specified by:
      getRootForSingleton in class RegularTreeGrammar<E>
    • cleanup

      public void cleanup()
    • reduce

      public void reduce()
      Removes all unproductive nonterminals and splits from this chart. A nonterminal is called unproductive if it isn't possible to derive a solved form from it (but it may still be inaccessible from the top-level subgraphs).

      This method accesses the precomputed preterminals of this RTG, and therefore assumes that recomputeSingletons() has been called since the latest change to the RTG.

      Parameters:
      roots - the roots of the dominance graph on which this chart is based
    • setSplitsForSubgraph

      public void setSplitsForSubgraph(E subgraph, List<Split<E>> splits)
      Sets the splits for a given subgraph. If the subgraph already had splits, these are deleted first.
      Parameters:
      subgraph - a subgraph
      splits - the new splits for this subgraph
      Throws:
      UnsupportedOperationException - - if you try to delete all splits of a subgraph that is still referenced from some other split. If this happens, the chart remains unchanged.
    • deleteSubgraph

      public void deleteSubgraph(E subgraph)
      Deletes a subgraph and all of its splits from the chart. This method updates the reference counts, and recursively deletes all other subgraphs that become unreachable.
      Parameters:
      subgraph - a subgraph
      Throws:
      UnsupportedOperationException - - if you try to delete a subgraph that is still referenced from some split. If this happens, the chart remains unchanged.
    • getSplitsFor

      public List<Split<E>> getSplitsFor(E subgraph)
      Returns the list of all splits for the given subgraph.
      Specified by:
      getSplitsFor in class RegularTreeGrammar<E>
      Parameters:
      subgraph - a subgraph
      Returns:
      the list of splits for this subgraph.
    • getSplitsFor

      public void getSplitsFor(E subgraph, String label, List<Split<E>> ret)
      Specified by:
      getSplitsFor in class RegularTreeGrammar<E>
    • containsSplitFor

      public boolean containsSplitFor(E subgraph)
      Checks whether the chart contains a split for the given subgraph.
      Specified by:
      containsSplitFor in class RegularTreeGrammar<E>
      Parameters:
      subgraph - a subgraph
      Returns:
      true iff the chart contains any splits for this subgraph.
    • size

      public int size()
      Returns the number of splits in the entire chart.
      Specified by:
      size in class RegularTreeGrammar<E>
      Returns:
      the number of splits
    • getToplevelSubgraphs

      public List<E> getToplevelSubgraphs()
      Returns the list of all top-level subgraphs.
      Specified by:
      getToplevelSubgraphs in class RegularTreeGrammar<E>
      Returns:
      the top-level subgraphs.
    • addToplevelSubgraph

      public void addToplevelSubgraph(E subgraph)
      Adds a top-level subgraph. This should be one of the maximal weakly connected subgraphs of the dominance graph; if the entire graph is connected, then this should be the set of all nodes of the dominance graph.
      Parameters:
      subgraph - a weakly connected subgraph.
    • clear

      public void clear()
    • isFinal

      public boolean isFinal(E nt)
    • setFinal

      public void setFinal(E nt)