Package eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars

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


                new Vector2D(0, 0),
                180,
                new Vector2D(1.2, 1.2));
       
        ArrayList<Word> start = new ArrayList<Word>(50);
        start.add(new Word(new Symbol[] {this.grammar.getStartSymbol()}));
        addWords.add(start);
       
        frame = new GrammarFrame("Non-final words in temp. storage", this);
        frame.setSize(600, 600);
        frame.setVisible(true);
View Full Code Here


    private List<Word> match(Word w, Rule r) {
        LinkedList<Word> words = new LinkedList<Word>();
        for (int i = 0; i < w.getWord().size(); i++) {
            int skip = this.matchInternal(w, r, i);
            if (skip > 0) {
                Word newWord = new Word(w.replace(i, r.getLeftSide().getWord().size(), r.getRightSide()));
                words.add(newWord);
            }
           
            i += Math.abs(skip) - 1;
        }
View Full Code Here

        if (env.getAgents().size() >= this.maxNumTerminals) {
            params.logInfo(this.maxNumTerminals + " words have been produced. Stopping word production.");
        }
       
        if (simZyk.getLastTick() % 50 == 0) {
            Word minWord = null;
            Word maxWord = null;
            ArrayList<Word> minDer = null;
            ArrayList<Word> maxDer = null;
           
            for (ArrayList<Word> ww : words) {
                if (minWord == null || ww.get(ww.size() - 1).compareTo(minWord) < 0) {
View Full Code Here

     * Generates all derivations possible with the current word
     * and moves the iterator to the next word in the list.
     */
    private void generateAllDerivationsWithCurrentAndMoveToNextWord() {
        ArrayList<Word> derivation = it.next();
        Word w = derivation.get(derivation.size() - 1);
       
        if (w.isTerminal()) {
            generatedWords.add(derivation);
        } else {
            for (Rule r : this.grammar.getRules()) {
                for (Word newWord : this.match(w, r)) {
                    ArrayList<Word> newDerivation;
View Full Code Here

    public static void main(String[] args) {
        eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Grammar g = new eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Grammar();
       
        g.addRule(new Rule(
                new Word(new Symbol[] {new Nonterminal(new StringBuffer("S"))}),
                new Word(new Symbol[] {
                        new Nonterminal(new StringBuffer("a")),
                        new Nonterminal(new StringBuffer("S")),
                        new Terminal(new StringBuffer("b"))})));

        g.addRule(new Rule(
                new Word(new Symbol[] {new Nonterminal(new StringBuffer("S"))}),
                new Word(new Symbol[] {
                        new Nonterminal(new StringBuffer("S")),
                        new Terminal(new StringBuffer("S"))})));

        g.addRule(new Rule(
                new Word(new Symbol[] {new Nonterminal(new StringBuffer("S"))}),
                new Word(new Symbol[] {new Terminal(new StringBuffer("a")), new Terminal(new StringBuffer("b"))})));

        CtxtFreeGrammar g2 = new CtxtFreeGrammar(g);
       
        try {
            ParseTree[] trees = ChartParser.parse(
View Full Code Here

            for (Transition targetTransition : this.getTransitionsFrom(fromState)) {
                String toState = targetTransition.getDestination();
                String symbol = targetTransition.getLabel();
               
                g.addRule(new Rule(
                        new Word(new Symbol[] {new Nonterminal(new StringBuffer(fromState))}),
                        new Word(new Symbol[] {
                                new Terminal(new StringBuffer(symbol)),
                                new Nonterminal(new StringBuffer(toState))})));
            }
           
            if (this.finalStates.contains(fromState)) {
                g.addRule(new Rule(
                        new Word(new Symbol[] {new Nonterminal(new StringBuffer(fromState))}),
                        new Word(new Symbol[] {})));
            }
        }
       
        return g;
    }
View Full Code Here

TOP

Related Classes of eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Word

Copyright © 2018 www.massapicom. 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.