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

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


    public final void testAsciiCharacterClassOperatorAlnum() {

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

        assertTrue(automaton.accepts("w"));
        assertTrue(automaton.accepts("9"));
        assertTrue(automaton.accepts("W"));
        assertTrue(automaton.accepts("a"));
        assertTrue(automaton.accepts("6"));

        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts(" "));
        assertFalse(automaton.accepts("g9"));
        assertFalse(automaton.accepts("bedziedobrze"));
        assertFalse(automaton.accepts("7dwa7dwa"));
    }
View Full Code Here


    public final void testAsciiCharacterClassOperatorAlpha() {

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

        assertTrue(automaton.accepts("A"));
        assertTrue(automaton.accepts("s"));
        assertTrue(automaton.accepts("I"));
        assertTrue(automaton.accepts("a"));

        assertFalse(automaton.accepts("7"));
        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("wrotka"));
        assertFalse(automaton.accepts("siedem"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorBlank() {

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

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

        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts("M"));
        assertFalse(automaton.accepts("a"));
        assertFalse(automaton.accepts("456"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorCntrl() {

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

        assertTrue(automaton.accepts("\u0000"));
        assertTrue(automaton.accepts("\u0002"));
        assertTrue(automaton.accepts("\u001F"));
        assertTrue(automaton.accepts("\u000F"));

        assertFalse(automaton.accepts("\u1044"));
        assertFalse(automaton.accepts(" t67"));
        assertFalse(automaton.accepts("g9"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorDigit() {

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

        assertTrue(automaton.accepts("1"));
        assertTrue(automaton.accepts("9"));
        assertTrue(automaton.accepts("7"));
        assertTrue(automaton.accepts("3"));

        assertFalse(automaton.accepts("bakteryja"));
        assertFalse(automaton.accepts(" "));
        assertFalse(automaton.accepts("digit"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorGraph() {

        ArrayList<String> params = new ArrayList<String>();
        params.add("graph");
        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("-"));

        assertFalse(automaton.accepts(""));
        assertFalse(automaton.accepts(" "));
        assertFalse(automaton.accepts("^^"));
        assertFalse(automaton.accepts("o/\\o"));
    }
View Full Code Here

    public final void testAsciiCharacterClassOperatorLower() {

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

        assertTrue(automaton.accepts("p"));
        assertTrue(automaton.accepts("i"));
        assertTrue(automaton.accepts("w"));
        assertTrue(automaton.accepts("o"));

        assertFalse(automaton.accepts("W"));
        assertFalse(automaton.accepts("I"));
        assertFalse(automaton.accepts("N"));
        assertFalse(automaton.accepts("O"));
        assertFalse(automaton.accepts("!"));
        assertFalse(automaton.accepts("sobota"));
    }
View Full Code Here

        RegexpOperatorTree tree = new RegexpOperatorTree(root, subtrees);

        //Tworzymy automat dla tego drzewa.
        AutomatonSpecification automaton =
                RegexpUtilities.createAutomatonFromOperatorTree(tree);
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(automaton);

        //Testujemy.
        assertTrue(result.accepts("a"));
        assertFalse(result.accepts("b"));
        assertFalse(result.accepts(""));
        assertFalse(result.accepts("aa"));
        assertFalse(result.accepts("testujtest"));

    }
View Full Code Here

        RegexpOperatorTree tree = new RegexpOperatorTree(root, subtrees);

        //Tworzymy automat dla tego drzewa.
        AutomatonSpecification automaton =
                RegexpUtilities.createAutomatonFromOperatorTree(tree);
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(automaton);

        //Testujemy.
        assertTrue(result.accepts("a"));
        assertTrue(result.accepts("b"));
        assertFalse(result.accepts(""));
        assertFalse(result.accepts("ab"));
        assertFalse(result.accepts("aaaaa"));
        assertFalse(result.accepts("testujtest"));
    }
View Full Code Here

        RegexpOperatorTree tree = new RegexpOperatorTree(root, subtrees);

         //Tworzymy automat dla tego drzewa.
        AutomatonSpecification automaton =
                RegexpUtilities.createAutomatonFromOperatorTree(tree);
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(automaton);

        //Testujemy.
        assertTrue(result.accepts("ab"));
        assertFalse(result.accepts("a"));
        assertFalse(result.accepts("b"));
        assertFalse(result.accepts(""));
        assertFalse(result.accepts("aaaaa"));
        assertFalse(result.accepts("testujtest"));


    }
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.