Package pl.edu.amu.wmi.daut.base

Examples of pl.edu.amu.wmi.daut.base.NondeterministicAutomatonByThompsonApproach


        subautomaton.addTransition(q1, q2, new CharTransitionLabel('a'));
        subautomaton.markAsInitial(q0);
        subautomaton.markAsFinal(q2);

        DoNothingOperator operator = new DoNothingOperator();
        NondeterministicAutomatonByThompsonApproach automaton =
                new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(subautomaton));

        assertTrue(automaton.accepts("aa"));
        assertTrue(automaton.accepts("aba"));
        assertTrue(automaton.accepts("abbbbbbbbbbbbbba"));
        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("abb"));

    }
View Full Code Here


    public final void testAsciiCharacterClassOperatorPrint() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("print");
        RegexpOperator spec = (new AsciiCharacterClassOperator.Factory()).createOperator(params);
        NondeterministicAutomatonByThompsonApproach automaton =
            new NondeterministicAutomatonByThompsonApproach(spec.createAutomaton(
                new ArrayList<AutomatonSpecification>()));

        assertTrue(automaton.accepts("-"));
        assertTrue(automaton.accepts("a"));
        assertTrue(automaton.accepts("B"));
        assertTrue(automaton.accepts("$"));
        assertTrue(automaton.accepts("~"));
        assertTrue(automaton.accepts(" "));

        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("Lech"));
        assertFalse(automaton.accepts("+*+"));
        assertFalse(automaton.accepts("<>"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorPunct() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("punct");
        RegexpOperator spec = (new AsciiCharacterClassOperator.Factory()).createOperator(params);
        NondeterministicAutomatonByThompsonApproach automaton =
            new NondeterministicAutomatonByThompsonApproach(spec.createAutomaton(
                new ArrayList<AutomatonSpecification>()));

        assertTrue(automaton.accepts("!"));
        assertTrue(automaton.accepts(":"));
        assertTrue(automaton.accepts("@"));
        assertTrue(automaton.accepts("~"));

        assertFalse(automaton.accepts(":("));
        assertFalse(automaton.accepts(":-("));
        assertFalse(automaton.accepts(":-@"));
        assertFalse(automaton.accepts("~-~"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorSpace() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("space");
        RegexpOperator spec = (new AsciiCharacterClassOperator.Factory()).createOperator(params);
        NondeterministicAutomatonByThompsonApproach automaton =
            new NondeterministicAutomatonByThompsonApproach(spec.createAutomaton(
                new ArrayList<AutomatonSpecification>()));

        assertTrue(automaton.accepts("\t"));
        assertTrue(automaton.accepts("\n"));
        assertTrue(automaton.accepts("\u000B"));

        assertFalse(automaton.accepts("aqq"));
        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("ola"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorUpper() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("upper");
        RegexpOperator spec = (new AsciiCharacterClassOperator.Factory()).createOperator(params);
        NondeterministicAutomatonByThompsonApproach automaton =
            new NondeterministicAutomatonByThompsonApproach(spec.createAutomaton(
                new ArrayList<AutomatonSpecification>()));

        assertTrue(automaton.accepts("A"));
        assertTrue(automaton.accepts("L"));
        assertTrue(automaton.accepts("I"));

        assertFalse(automaton.accepts("w"));
        assertFalse(automaton.accepts("i"));
        assertFalse(automaton.accepts("a"));
        assertFalse(automaton.accepts("t"));
        assertFalse(automaton.accepts("r"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorWord() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("word");
        RegexpOperator spec = (new AsciiCharacterClassOperator.Factory()).createOperator(params);
        NondeterministicAutomatonByThompsonApproach automaton =
            new NondeterministicAutomatonByThompsonApproach(spec.createAutomaton(
                new ArrayList<AutomatonSpecification>()));

        assertTrue(automaton.accepts("_"));
        assertTrue(automaton.accepts("7"));
        assertTrue(automaton.accepts("w"));
        assertTrue(automaton.accepts("Z"));
        assertTrue(automaton.accepts("1"));

        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("112"));
        assertFalse(automaton.accepts(" "));
        assertFalse(automaton.accepts("cotojestkakademona"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorXdigit() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("xdigit");
        RegexpOperator spec = (new AsciiCharacterClassOperator.Factory()).createOperator(params);
        NondeterministicAutomatonByThompsonApproach automaton =
            new NondeterministicAutomatonByThompsonApproach(spec.createAutomaton(
                new ArrayList<AutomatonSpecification>()));

        assertTrue(automaton.accepts("F"));
        assertTrue(automaton.accepts("9"));
        assertTrue(automaton.accepts("f"));
        assertTrue(automaton.accepts("C"));
        assertTrue(automaton.accepts("1"));

        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("g"));
        assertFalse(automaton.accepts("G"));
        assertFalse(automaton.accepts("12"));
    }
View Full Code Here

     */
    public final void testCreateFixedAutomaton() {

        SingleCharacterOperator operator = new SingleCharacterOperator('c');
        AutomatonSpecification automaton = operator.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result =
          new NondeterministicAutomatonByThompsonApproach(automaton);

        assertFalse(automaton.isEmpty());

        assertTrue(result.accepts("c"));

        assertFalse(result.accepts("cc"));
        assertFalse(result.accepts("a"));

        assertEquals('c', operator.getCharacter());
    }
View Full Code Here

        automaton2.addTransition(q2, q3, new CharTransitionLabel('k'));
        automaton2.markAsInitial(q2);
        automaton2.markAsFinal(q3);

        AnyOrderOperator operator = new AnyOrderOperator();
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromTwoAutomata(automaton1, automaton2));

        assertTrue(result.accepts("ak"));
        assertTrue(result.accepts("ka"));
        assertFalse(result.accepts("a"));
        assertFalse(result.accepts("k"));
        assertFalse(result.accepts(""));

        AutomatonSpecification automaton3 = new NaiveAutomatonSpecification();
        State q4 = automaton3.addState();
        State q5 = automaton3.addState();
        automaton3.addTransition(q4, q5, new EpsilonTransitionLabel());
        automaton3.markAsInitial(q4);
        automaton3.markAsFinal(q5);

        AutomatonSpecification automaton4 = new NaiveAutomatonSpecification();
        State q6 = automaton2.addState();
        State q7 = automaton2.addState();
        automaton2.addTransition(q6, q7, new EpsilonTransitionLabel());
        automaton2.markAsInitial(q6);
        automaton2.markAsFinal(q7);

        AnyOrderOperator operator1 = new AnyOrderOperator();
        NondeterministicAutomatonByThompsonApproach result1 =
                new NondeterministicAutomatonByThompsonApproach(
                operator1.createAutomatonFromTwoAutomata(automaton3, automaton4));

        assertFalse(result1.accepts(""));
        assertFalse(result1.accepts(" "));
        assertFalse(result1.accepts("asd"));
        assertFalse(result1.accepts("epsilon"));
    }
View Full Code Here

     * Testuje automat roznych znakow, takze pustego przejscia.
     */
    public final void testcreateFixedAutomaton() {

        AnyStringOperator spec2 = new AnyStringOperator();
        NondeterministicAutomatonByThompsonApproach automaton2 =
                new NondeterministicAutomatonByThompsonApproach(spec2.createFixedAutomaton());

        assertTrue(automaton2.accepts("qwer"));
        assertTrue(automaton2.accepts("qqqq"));
        assertTrue(automaton2.accepts("w"));
        assertTrue(automaton2.accepts("kakademona"));
        assertTrue(automaton2.accepts("qqrrqqrr"));
        assertTrue(automaton2.accepts(""));
        assertTrue(automaton2.accepts("  s  "));
    }
View Full Code Here

TOP

Related Classes of pl.edu.amu.wmi.daut.base.NondeterministicAutomatonByThompsonApproach

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.