Examples of GrammarFactory


Examples of com.siemens.ct.exi.GrammarFactory

    encoder.setOutputStream(exiOutputStream);
  }
 
  public EXISerializer(OutputStream exiOutputStream, InputStream xsdInputStream) throws EXIException, IOException {
    final EXIFactory exiFactory = DefaultEXIFactory.newInstance();
    final GrammarFactory grammarFactory = GrammarFactory.newInstance();
    final Grammar g = grammarFactory.createGrammar(xsdInputStream);
    exiFactory.setGrammar(g);
    encoder = new SAXEncoder(exiFactory);
    encoder.setOutputStream(exiOutputStream);
  }
View Full Code Here

Examples of com.siemens.ct.exi.GrammarFactory

      EXIFactory exiFactory = DefaultEXIFactory.newInstance();
      if(args.length > 1) {
        if(!args[1].isEmpty()) {
          Item xsdItem = args[1].itemAt(0);
          InputStream xsdInputStream = EXIUtils.getInputStream(xsdItem, context);
          GrammarFactory grammarFactory = GrammarFactory.newInstance();
          Grammar grammar = grammarFactory.createGrammar(xsdInputStream);
          exiFactory.setGrammar(grammar);
        }
      }
      SAXDecoder decoder = new SAXDecoder(exiFactory);
      SAXAdapter adapter = new AppendingSAXAdapter(builder);
View Full Code Here

Examples of joshua.decoder.ff.tm.GrammarFactory

  private void initializeTranslationGrammars(String tm_file)
  throws IOException {
    grammarFactories = new GrammarFactory[2];
   
    // Glue Grammar
    GrammarFactory glueGrammar =
      //new MemoryBasedBatchGrammarWithPrune(
      new MonolingualGrammar(
        "monolingual",
        p_symbolTable,
        JoshuaConfiguration.glue_file,
        JoshuaConfiguration.phrase_owner,
        JoshuaConfiguration.default_non_terminal,
        JoshuaConfiguration.goal_symbol,
        -1,
        runEM);
   
    grammarFactories[0] = glueGrammar;
   
    // Regular TM Grammar
    GrammarFactory regularGrammar =
      //new MemoryBasedBatchGrammarWithPrune(
      new MonolingualGrammar(
        "monolingual",
        p_symbolTable, tm_file,
        JoshuaConfiguration.phrase_owner,
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.GrammarFactory

    // Get a SAX parser
    xmlparser = parserFactoryImpl.newSAXParser().getXMLReader();

    // Create a grammar model for a given grammar file
    GrammarFactory grammarfactory = new GrammarFactory();
    xmlparser.setContentHandler(grammarfactory);
    xmlparser.parse(grammarFile.toString());

    Grammar grammar = grammarfactory.getGrammar();

    // Build a automaton from the grammar model
    ParserAutomaton parserautomaton =
      (new ParserAutomatonBuilder(grammar, log)).getParserAutomaton();
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.GrammarFactory

    factory.setNamespaceAware(true);

    XMLReader parser = factory.newSAXParser().getXMLReader();

    GrammarFactory handler = new GrammarFactory();
    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.model.grammar.GrammarFactory

    SAXParserFactory parserfactory = SAXParserFactory.newInstance();
    parserfactory.setNamespaceAware(true);

    XMLReader parser = parserfactory.newSAXParser().getXMLReader();

    GrammarFactory grammarfactory = new GrammarFactory();
    parser.setContentHandler(grammarfactory);
    parser.parse(new InputSource(getClass().getClassLoader().getResourceAsStream(in)));

    //System.out.println("====================================\nGrammar:\n"+grammarfactory.getGrammar()+"\n");
    return grammarfactory.getGrammar();
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.GrammarFactory

    Node node = list.item(0);

    TransformerFactory streamerfactory = TransformerFactory.newInstance();
    Transformer streamer = streamerfactory.newTransformer();

    GrammarFactory grammarfactory = new GrammarFactory();

    streamer.transform(new DOMSource(node), new SAXResult(grammarfactory));

    Grammar grammar = grammarfactory.getGrammar();

    System.out.println("Grammar:\n"+grammar);

    return grammar;
  }
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.GrammarFactory

        //SAXConfigurationHandler confighandler = new SAXConfigurationHandler();
        if (this.grammarSource.getInputStream()==null)
          throw new ProcessingException("Source '"+this.grammarSource.getURI()+"' not found");

        GrammarFactory factory = new GrammarFactory();
        SourceUtil.toSAX(this.manager, this.grammarSource, null, factory);

        //Configuration config = confighandler.getConfiguration();
        //Grammar grammar = GrammarFactory.createGrammar(config);
        Grammar grammar = factory.getGrammar();

        if (grammar==null)
          throw new ProcessingException("Error while reading the grammar from "+src);

        ParserAutomatonBuilder builder =
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.GrammarFactory

        //SAXConfigurationHandler confighandler = new SAXConfigurationHandler();
        if (this.grammarSource.getInputStream()==null)
          throw new ProcessingException("Source '"+this.grammarSource.getURI()+"' not found");

        GrammarFactory factory = new GrammarFactory();
        SourceUtil.toSAX(this.manager, this.grammarSource, null, factory);

        //Configuration config = confighandler.getConfiguration();
        //Grammar grammar = GrammarFactory.createGrammar(config);
        Grammar grammar = factory.getGrammar();

        if (grammar==null)
          throw new ProcessingException("Error while reading the grammar from "+src);

        ParserAutomatonBuilder builder =
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.GrammarFactory

        //SAXConfigurationHandler confighandler = new SAXConfigurationHandler();
        if (this.grammarSource.getInputStream()==null)
          throw new ProcessingException("Source '"+this.grammarSource.getURI()+"' not found");

        GrammarFactory factory = new GrammarFactory();
        SourceUtil.toSAX(this.manager, this.grammarSource, null, factory);

        //Configuration config = confighandler.getConfiguration();
        //Grammar grammar = GrammarFactory.createGrammar(config);
        Grammar grammar = factory.getGrammar();

        if (grammar==null)
          throw new ProcessingException("Error while reading the grammar from "+src);

        ParserAutomatonBuilder builder =
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.