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

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


     * automaton2 - akceptującego wyraz składający się z liter "a" i "b",
     *     który zawiera nieparzystą ilość "b".
     */
    public final void testCreateAutomatonFromTwoAutomata1() {

        AutomatonSpecification automaton1 = new NaiveAutomatonSpecification();

        State q0 = automaton1.addState();
        State q1 = automaton1.addState();
        automaton1.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton1.addLoop(q0, new CharTransitionLabel('b'));
        automaton1.addLoop(q1, new CharTransitionLabel('a'));
        automaton1.addLoop(q1, new CharTransitionLabel('b'));

        automaton1.markAsInitial(q0);
        automaton1.markAsFinal(q1);

        AutomatonSpecification automaton2 = new NaiveAutomatonSpecification();

        State q2 = automaton2.addState();
        State q3 = automaton2.addState();
        automaton2.addTransition(q2, q3, new CharTransitionLabel('b'));
        automaton2.addTransition(q3, q2, new CharTransitionLabel('b'));
        automaton2.addLoop(q2, new CharTransitionLabel('a'));
        automaton2.addLoop(q3, new CharTransitionLabel('a'));

        automaton2.markAsInitial(q2);
        automaton2.markAsFinal(q3);

        AlternativeOperator oper = new AlternativeOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                oper.createAutomatonFromTwoAutomata(automaton1, automaton2));
View Full Code Here


     *     postaci {(ab)^n : n>0}
     * automaton2 - automatu pustego.
     */
    public final void testCreateAutomatonFromTwoAutomata2() {

        AutomatonSpecification automaton1 = new NaiveAutomatonSpecification();

        State q0 = automaton1.addState();
        State q1 = automaton1.addState();
        State q2 = automaton1.addState();
        automaton1.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton1.addTransition(q1, q2, new CharTransitionLabel('b'));
        automaton1.addTransition(q2, q1, new CharTransitionLabel('a'));

        automaton1.markAsInitial(q0);
        automaton1.markAsFinal(q2);

        AutomatonSpecification automaton2 = new NaiveAutomatonSpecification();

        AlternativeOperator oper = new AlternativeOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                oper.createAutomatonFromTwoAutomata(automaton1, automaton2));
View Full Code Here

    /**
* Test metody createAutomatonFromOneAutomaton.
*/
    public final void testCreateAutomatonFromOneAutomaton() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        State q2 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton.addTransition(q1, q2, new CharTransitionLabel('b'));
        automaton.addLoop(q1, new CharTransitionLabel('a'));
        automaton.addLoop(q2, new CharTransitionLabel('b'));

        automaton.markAsInitial(q0);
        automaton.markAsFinal(q2);

        OptionalityOperator operator = new OptionalityOperator();
        NondeterministicAutomatonByThompsonApproach result =
            new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(automaton));

        assertTrue(result.accepts("aaabbb"));
        assertTrue(result.accepts("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"));
        assertTrue(result.accepts("aabbbbbbbbbbbbb"));
        assertTrue(result.accepts("ab"));
        assertTrue(automaton.acceptEmptyWord());

        assertFalse(result.accepts("aaabbbbaabbbbab"));
        assertFalse(result.accepts("aaaaaaaaaaa"));
        assertFalse(result.accepts("cojapacze"));
        assertFalse(result.accepts("macrimnatueshzanc"));
View Full Code Here

    /**
     * Test metody createAutomatonFromOneAutomaton.
     */
    public final void testCreateAutomatonFromOneAutomaton() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        State q2 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton.addTransition(q1, q2, new CharTransitionLabel('b'));
        automaton.addLoop(q1, new CharTransitionLabel('a'));
        automaton.addLoop(q2, new CharTransitionLabel('b'));

        automaton.markAsInitial(q0);
        automaton.markAsFinal(q2);

        AtLeastOneOperator operator = new AtLeastOneOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(automaton));

        assertTrue(result.accepts("aaaab"));
        assertTrue(result.accepts("abbbbb"));
        assertTrue(result.accepts("aaaaaaaaaaaabb"));
        assertTrue(result.accepts("abbbaaaab"));
        assertTrue(result.accepts("abababb"));

        assertFalse(automaton.acceptEmptyWord());
        assertFalse(result.accepts("baba"));
        assertFalse(result.accepts("baaaaaaaaa"));
        assertFalse(result.accepts("cojatestujem"));
        assertFalse(result.accepts("bartlomiejburczymucha"));
    }
View Full Code Here

TOP

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

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.