Пример #1
0
def run():
    # ds = AnnotatedDataset.parse_abbadingoformat("../../testdata/RPNIAndEDSMDataSample.txt")
    ds = AnnotatedDataset.parse_custom("testdata/language.txt")
    # print ds
    # ds = AnnotatedDataset.parse_abbadingoformat("../testdata/train170.txt")
    # labelspath = "../testdata/lol.labels"
    # datapath = "../testdata/lol.data"
    # ds = AnnotatedDataset.parse_sentence(labelspath, datapath)
    dfa = build_gold_DFA(ds)
    dfa.write_png()
    for sample in ds:
        assert (dfa.membership(sample[0]) == sample[1])
    print dfa
Пример #2
0
def run():
    # labelspath = "../testdata/cms.01.labels"
    # datapath = "../testdata/cms.01.data"
    # labelspath = "../testdata/fun.labels"
    # datapath = "../testdata/fun.data"
    # ds = AnnotatedDataset.parse_sentence(labelspath, datapath)
    # ds = AnnotatedDataset.parse_abbadingoformat("../testdata/train170.txt")
    # ds = AnnotatedDataset.parse_ewsformat_bin(labelspath, datapath)
    ds = AnnotatedDataset.parse_abbadingoformat(
        "testdata/RPNIAndEDSMDataSample.txt")
    pta = build_PTA(ds)
    # pta3 = pta.to_reverse_NFA().to_DFA().to_reverse_NFA().to_DFA()
    # pta.set_error_state()
    # print pta
    # print pta3 #89 states without error state --> 90
    # pta2 = pta.minimize()

    # print pta2
    # print pta == pta2

    # eqdfa = pta.symmetric_difference(pta2)
    # print eqdfa
    # for i in eqdfa.generate():
    #    print i, pta.is_member(i), pta2.is_member(i)
    # pta.minimize()
    # if not pta == pta2:
    #    print "not equal?"
    #    strng = (pta ^ pta2).shortest_example()
    #    print strng, pta.parse(strng), pta2.parse(strng)
    # else:
    #    print "equal"
    # print
    # for sample in ds:
    #    p = pta2.parse(sample[0])
    #    if p[0] != sample[1]:
    #        print p, sample
    # print pta == pta3
    # print pta2 == pta3
    # for sample in ds:
    #    assert(pta.is_member(sample[0]) == sample[1])
    # dfa = pta.minimize().rename().del_dead_states()
    dfa = pta
    dfa.write_png()
Пример #3
0
def run():
    # labelspath = "../testdata/fun.labels"
    # datapath = "../testdata/fun.data"
    # ds = AnnotatedDataset.parse_sentence(labelspath, datapath)
    ds = AnnotatedDataset.parse_abbadingoformat("../../testdata/train171.txt")
    # ds = AnnotatedDataset.parse_abbadingoformat("../testdata/RPNIAndEDSMDataSample.txt")
    # labelspath = "../testdata/cms.01.labels"
    # datapath = "../testdata/cms.01.data"
    # ds = AnnotatedDataset.parse_ewsformat_bin(labelspath, datapath)
    # labelspath = "../testdata/lol.labels"
    # datapath = "../testdata/lol.data"
    # ds = AnnotatedDataset.parse_sentence(labelspath, datapath)
    dfa = build_rpni_DFA(ds)
    # dfa.write_png()

    print dfa.states, dfa.accept, dfa.reject
    for sample in ds:
        # res, state = dfa.parse_final(sample[0])
        res = dfa.membership(sample[0])
        if res != sample[1]:
            print sample, res
    print dfa
Пример #4
0
def run():
    # datapath = "../testdata/fun.data"
    # ds = AnnotatedDataset.parse_sentence(labelspath, datapath)
    # ds = Dataset.parse_sentence(datapath)
    # ds = AnnotatedDataset.parse_ewsformat(labelspath, datapath)
    ds = AnnotatedDataset.parse_abbadingoformat("testdata/train173.txt")
    # ds = AnnotatedDataset.parse_abbadingoformat("../../testdata/RPNIAndEDSMDataSample.txt")
    oracle = MinAdequateTeacher.from_AnnotatedDataset(ds)
    pta = build_PTA(ds)
    dfa = build_lstar_DFA(oracle)
    print dfa
    print pta == dfa
    # eqdfa = pta.symmetric_difference(pta2)
    # print eqdfa
    # for i in eqdfa.generate():
    #    print i, pta.is_member(i), pta2.is_member(i)
    # pta.minimize()
    # print pta == pta2
    # print pta == pta3
    # print pta2 == pta3
    # for sample in ds:
    #    assert(pta.is_member(sample[0]) == sample[1])
    dfa.del_dead_states()
    dfa.write_png()
Пример #5
0
 def setUp(self):
     self.raw = [("bb", 1), ("abb", 1), ("bba", 1), ("bbb", 1), ("a", 0),
                 ("b", 0), ("aa", 0), ("bab", 0)]
     self.ds = AnnotatedDataset.from_tuples(self.raw)