Examples of Automaton


Examples of dk.brics.automaton.Automaton

    private RunAutomaton runauto = null;
   
    public CompiledAutomaton( String rhsPattern ) {
        RegExp regexpr = new dk.brics.automaton.RegExp(rhsPattern);
        Automaton auto = regexpr.toAutomaton();
        this.runauto = new RunAutomaton(auto, true);
    }
View Full Code Here

Examples of dk.brics.automaton.Automaton

*/
public class AutomatonOperation {


    public static Automaton makeAcceptAllOfLength(int length, int[] alphabet) {
        Automaton auto = new Automaton();
        State start = new State();
        State tmp = start;
        State last = start;

        for (int i = 0; i < length; i++) {
            last = new State();
            for (int k : alphabet) {
                tmp.addTransition(new Transition(FiniteAutomaton.getCharFromInt(k), last));
            }
            tmp = last;

        }
        last.setAccept(true);
        auto.setInitialState(start);
        return auto;
    }
View Full Code Here

Examples of net.sourceforge.chaperon.build.Automaton

  public void testConstruction()
  {
    System.out.println(grammar);

    //FirstSetCollection firstsets = new FirstSetCollection(grammar);
    Automaton collection = new Automaton(grammar,  /*firstsets,*/
                                         null);

    System.out.println(collection);
  }
View Full Code Here

Examples of net.sourceforge.chaperon.build.Automaton

    parser.setContentHandler(handler);
    parser.parse(new InputSource(getClass().getResourceAsStream("java.xgrm")));

    Grammar grammar = handler.getGrammar();

    Automaton collection = new Automaton(grammar,  /*firstsets,*/
                                         null);

    System.out.println(collection);
  }
View Full Code Here

Examples of net.sourceforge.chaperon.build.Automaton

    /*Automaton automaton =
      (new AutomatonBuilder(grammar, new ConsoleLog())).getParserAutomaton();*/

    //  (new AutomatonBuilder(grammar)).getParserAutomaton();
    Automaton automaton = new Automaton(grammar, new ConsoleLog());

    assertNotNull("Test if automaton is generated", automaton);

    processor.setParserAutomaton(automaton);

View Full Code Here

Examples of net.sourceforge.chaperon.build.Automaton

      //Grammar grammar = GrammarFactory.createGrammar(grammarconfig);
      Grammar grammar = grammarfactory.getGrammar();

      /*this.parserautomaton = (new ParserAutomatonBuilder(grammar,
          log)).getParserAutomaton();*/
      this.parserautomaton = new Automaton(grammar, log);

      /*if (cacheFile!=null)
      {
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(cacheFile));
        out.writeObject(this.parserautomaton);
View Full Code Here

Examples of org.apache.lucene.util.automaton.Automaton

 
  // LUCENE-3849
  public void testStopwordsPosIncHole2() throws Exception {
    // use two stopfilters for testing here
    Directory dir = newDirectory();
    final Automaton secondSet = BasicAutomata.makeString("foobar");
    Analyzer a = new Analyzer() {
      @Override
      protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
        Tokenizer tokenizer = new MockTokenizer(reader);
        TokenStream stream = new MockTokenFilter(tokenizer, MockTokenFilter.ENGLISH_STOPSET);
View Full Code Here

Examples of org.apache.lucene.util.automaton.Automaton

      }
    } else if (clazz.equals("lucene.WildcardQuery")) {
      WildcardQuery wq = (WildcardQuery)q;
      Term t = wq.getTerm();
      setString(n, "text", getString(n, "text") + ", term=" + t);
      Automaton a = WildcardQuery.toAutomaton(t);
      addAutomaton(n, a);
    } else if (clazz.equals("lucene.TermRangeQuery")) {
      TermRangeQuery rq = (TermRangeQuery)q;
      setString(n, "text", getString(n, "text") + ", inclLower=" + rq.includesLower() + ", inclUpper=" + rq.includesUpper());
      Object n1 = create("node");
      setString(n1, "text", "lowerTerm=" + rq.getField() + ":" + rq.getLowerTerm() + "'");
      add(n, n1);
      n1 = create("node");
      setString(n1, "text", "upperTerm=" + rq.getField() + ":" + rq.getUpperTerm() + "'");
      add(n, n1);
      try {
        addTermsEnum(n, TermRangeQuery.class, rq.getField(), rq);
      } catch (Exception e) {
        e.printStackTrace();
        n1 = create("node");
        setString(n1, "text", "TermEnum: Exception " + e.getMessage());
        add(n, n1);
      }
    } else if (q instanceof AutomatonQuery) {
      AutomatonQuery aq = (AutomatonQuery)q;
      setString(n, "text", getString(n, "text") + ", " + aq.toString());
      // get automaton
      try {
        java.lang.reflect.Field aField = AutomatonQuery.class.getDeclaredField("automaton");
        aField.setAccessible(true);
        Automaton a = (Automaton)aField.get(aq);
        addAutomaton(n, a);
      } catch (Exception e) {
        e.printStackTrace();
        Object n1 = create("node");
        setString(n1, "text", "Automaton: Exception " + e.getMessage());
View Full Code Here

Examples of org.apache.lucene.util.automaton.Automaton

        }

        try {
            List<Term> terms = new ArrayList<Term>();
            Terms t = MultiFields.getTerms(reader, FieldNames.FULLTEXT);
            Automaton a = WildcardQuery.toAutomaton(newFulltextTerm(token));
            CompiledAutomaton ca = new CompiledAutomaton(a);
            TermsEnum te = ca.getTermsEnum(t);
            BytesRef text;
            while ((text = te.next()) != null) {
                terms.add(newFulltextTerm(text.utf8ToString()));
View Full Code Here

Examples of org.apache.lucene.util.automaton.Automaton

        }

        try {
            List<Term> terms = new ArrayList<Term>();
            Terms t = MultiFields.getTerms(reader, FieldNames.FULLTEXT);
            Automaton a = WildcardQuery.toAutomaton(newFulltextTerm(token));
            CompiledAutomaton ca = new CompiledAutomaton(a);
            TermsEnum te = ca.getTermsEnum(t);
            BytesRef text;
            while ((text = te.next()) != null) {
                terms.add(newFulltextTerm(text.utf8ToString()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.