Examples of Grammar


Examples of dk.brics.string.grammar.Grammar

        if (log.isDebugEnabled()) {
            log.debug(g.toDot(nodes));
        }
        log.info("Transforming into grammar...");
        FlowGraph2Grammar f2g = new FlowGraph2Grammar(g);
        Grammar r = f2g.convert();
        Set<Nonterminal> hs_nt = new HashSet<Nonterminal>();
        for (Node hn : nodes) {
            hs_nt.add(f2g.getNonterminal(hn));
        }
        if (log.isDebugEnabled()) {
            log.debug(r.toString() + "Hotspots: " + hs_nt);
        }

        // Approximate grammar
        log.info("Cutting operation cycles...");
        r.approximateOperationCycles();
        log.info("Performing regular approximation...");
        r.approximateNonLinear(hs_nt);
        if (log.isDebugEnabled()) {
            log.debug(r.toString() + "Hotspots: " + hs_nt);
        }
        log.info("Converting to MLFA...");

        Grammar2MLFA gm = new Grammar2MLFA(r);
        MLFA mlfa = gm.convert();
View Full Code Here

Examples of eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Grammar

        if (dia.getDirectory() == null || dia.getFile() == null) {
            env.getSimTime().timeTerminate();
            System.exit(0);
        }
       
        grammar = new Grammar(new File(dia.getDirectory() + File.separator + dia.getFile()), new Nonterminal(new StringBuffer("S")));
       
        env.addAgent(
                new GrammarAgent(
                        env.getFirstFreeID(),
                        env,
View Full Code Here

Examples of hampi.grammars.Grammar

import junit.framework.TestCase;

public class CYKTests extends TestCase{
  public void test1() throws Exception{
    String grammarFile = "tests/resources/test_cyk1.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    List<ParseTree> parse = p.parse("s1 s2".split(" "), "S");
    assertTrue(!parse.isEmpty());
  }
View Full Code Here

Examples of joshua.decoder.ff.tm.Grammar

  }
 
 
  private void reEstmateGrammars(){
    for (GrammarFactory grammarFactory : this.p_grammar_factories) {
      Grammar bathGrammar = grammarFactory.getGrammarForSentence(null);
      accumulatePosteriorCountInGrammar(bathGrammar);
      normalizePosteriorCountInGrammar(bathGrammar);
     
      //TODO: this will *correctly* write the regular grammar, instead of the GLUE grammar, but we should avoid this
      ((MonolingualGrammar) bathGrammar).writeGrammarOnDisk(outGrammarFile, this.symbolTable);
     
      bathGrammar.sortGrammar(this.p_l_feat_functions);
    }
  }
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

        synchronized (fGrammars) {
            clean();
            int hash = hashCode(desc);
            int index = (hash & 0x7FFFFFFF) % fGrammars.length;
            for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
                Grammar tempGrammar = (Grammar) entry.grammar.get();
                /** If the soft reference has been cleared, remove this entry from the pool. */
                if (tempGrammar == null) {
                    removeEntry(entry);
                }
                else if ((entry.hash == hash) && equals(entry.desc, desc)) {
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

        synchronized (fGrammars) {
            clean();
            int hash = hashCode(desc);
            int index = (hash & 0x7FFFFFFF) % fGrammars.length;
            for (Entry entry = fGrammars[index]; entry != null ; entry = entry.next) {
                Grammar tempGrammar = (Grammar) entry.grammar.get();
                /** If the soft reference has been cleared, remove this entry from the pool. */
                if (tempGrammar == null) {
                    removeEntry(entry);
                }
                else if ((entry.hash == hash) && equals(entry.desc, desc)) {
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

    /* (non-Javadoc)
     * @see org.apache.xerces.xs.XSLoader#load(org.w3c.dom.ls.LSInput)
     */
    public XSModel load(LSInput is) {
        try {
            Grammar g = loadGrammar(dom2xmlInputSource(is));
            return ((XSGrammar) g).toXSModel();
        } catch (Exception e) {
            reportDOMFatalError(e);
            return null;
        }
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

    /* (non-Javadoc)
     * @see org.apache.xerces.xs.XSLoader#loadURI(java.lang.String)
     */
    public XSModel loadURI(String uri) {
        try {
            Grammar g = loadGrammar(new XMLInputSource(null, uri, null));
            return ((XSGrammar)g).toXSModel();
        }
        catch (Exception e){
            reportDOMFatalError(e);
            return null;
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

        public Grammar retrieveGrammar(XMLGrammarDescription desc) {
            if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) {
                final String tns = ((XMLSchemaDescription) desc).getTargetNamespace();
                if (fGrammarBucket != null) {
                    Grammar grammar = fGrammarBucket.getGrammar(tns);
                    if (grammar != null) {
                        return grammar;
                    }
                }
                if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) {
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

         *
         * @param gDesc Description of the grammar to be retrieved
         * @return      Grammar corresponding to gDesc, or null if none exists.
         */
        public Grammar retrieveGrammar(XMLGrammarDescription gDesc) {
            Grammar g = super.retrieveGrammar(gDesc);
            if(g != null) return g;
            return fGrammarPool.retrieveGrammar(gDesc);
        } // retrieveGrammar(XMLGrammarDesc):  Grammar
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.