/**
   * Performs a filter of the entries.
   *
   * @param context
   * @return a set whose each element is a set of entries that are coherent alltogether
   */
  private Set<GrammarEntries> filter(PolarityContext context) {
    if (logger.isDebugEnabled()) logger.debug("Polarity keys: " + context.getAllKeys());

    PolarityAutomaton automaton = new PolarityAutomaton();
    automaton.createAutomaton(context);

    if (logger.isDebugEnabled()) logger.debug("Automaton:\n" + automaton.toString());

    Set<GrammarEntries> ret = new HashSet<GrammarEntries>();
    for (PolarityPath path : automaton.getPathsToFinalStates(context)) {
      System.out.println("Path: " + path);
      ret.add(new GrammarEntries(path.collectEntries()));
    }

    return ret;
  }
示例#2
0
  /**
   * Performs a filter of the entries.
   *
   * @param context
   * @return a set whose each element is a set of entries that are coherent alltogether
   */
  public Set<GrammarEntries> filter(PolarityContext context) {
    PolarityAutomaton automaton = new PolarityAutomaton();
    automaton.createAutomaton(context);
    // logger.fine("0-key automaton: " + automaton.size()+"\n"+automaton);
    // logger.fine("0-key automaton: " + automaton.size());

    for (PolarityKey key : context.getAllKeys()) {
      PolarityAutomaton newAutomaton = new PolarityAutomaton(key);
      newAutomaton.extendAutomaton(automaton, context);
      automaton = newAutomaton;
      // logger.fine(key+" automaton: " + automaton.size()+"\n"+automaton);
      // logger.fine(key + " automaton: " + automaton.size());
    }

    // System.out.println(automaton);

    Set<GrammarEntries> ret = new HashSet<GrammarEntries>();
    for (PolarityPath path : automaton.getPathsToFinalStates(context)) {
      // System.out.println("Path: " + path);
      ret.add(new GrammarEntries(path.collectEntries()));
    }

    return ret;
  }