Exemple #1
0
    so = sys.stdout
    si = sys.stdin

#   print 'stdin=' , si.encoding , 'stdout=' , so.encoding

    syst = sys.argv[1] if len(sys.argv) > 1 else 'test'
    print 'system=' , syst
    try:
        eb = EllyBase(syst)
#       print 'eb=' , eb
    except ellyException.TableFailure:
        print >> sys.stderr , 'cannot initialize rules and vocabulary'
        sys.exit(1)

    print ""
    dumpEllyGrammar.dumpCategories(eb.rul.stb)
    dumpEllyGrammar.dumpExtensions(eb.rul.stb,eb.rul.gtb.extens,False)
    dumpEllyGrammar.dumpSplits(eb.rul.stb,eb.rul.gtb.splits,False)
    dumpEllyGrammar.dumpDictionary(eb.rul.stb,eb.rul.gtb.dctn,False)

    eb.symbolCheck()

    so.write('\n')
    so.write('> ')

    while True:  # translate successive lines of text as sentences for testing

        line = si.readline()
        l = line.decode('utf8')
        if len(l) == 0 or l[0] == '\n': break
#       print 'input:' , type(line) , '->' , type(l)
Exemple #2
0
    if inp.error != None:
        print inp.error
        sys.exit(1)

    patn = None
    try:
        patn = PatternTable(ctx.syms,inp) # try to define FSA
    except ellyException.TableFailure:
        print 'no pattern table generated'
        sys.exit(1)

    print len(patn.indx) , 'distinct FSA state(s)'

    print ''
    dumpEllyGrammar.dumpCategories(ctx.syms)
    print ''
    patn.dump()

    print 'enter tokens in context to recognize'

    while True: # try FSA with test examples

        if interact: sys.stdout.write('> ')
        t = sys.stdin.readline().strip()
        if len(t) == 0: break
        print 'text=' , '[' , t , ']'
        nma = patn.match(list(t),tre)
        print '    from <'+ t + '>' , nma , 'chars matched' , '| leaving <' + t[nma:] + '>'

    if interact: sys.stdout.write('\n')
Exemple #3
0
    print('release  =', 'PyElly', release)
    print('system   =', syst)

    print('language =  ', ellyConfiguration.language)
    try:
        eb = EllyBase(syst)
#       print ( 'eb=' , eb )
    except ellyException.TableFailure:
        print('cannot initialize rules and vocabulary', file=sys.stderr)
        sys.exit(1)

    if dpth >= 0: eb.ptr.setDepth(dpth)  # for parse trees

    print()
    dumpEllyGrammar.dumpCategories(eb.rul.stb)
    eb.symbolCheck()
    dumpEllyGrammar.dumpExtensions(eb.rul.stb, eb.rul.gtb.extens, False)
    dumpEllyGrammar.dumpSplits(eb.rul.stb, eb.rul.gtb.splits, False)
    dumpEllyGrammar.dumpDictionary(eb.rul.stb, eb.rul.gtb.dctn, False)

    so.write('\n')

    print('Extractors')
    print('----------')
    eb.iex.dump()

    so.write('\n')
    so.flush()
    sys.stderr.flush()
Exemple #4
0
    if inp.error != None:
        print inp.error
        sys.exit(1)

    patn = None
    try:
        patn = PatternTable(ctx.syms, inp)  # try to define FSA
    except ellyException.TableFailure:
        print 'no pattern table generated'
        sys.exit(1)

    print len(patn.indx), 'distinct FSA state(s)'

    print ''
    dumpEllyGrammar.dumpCategories(ctx.syms)
    print ''
    patn.dump()

    print 'enter tokens in context to recognize'

    while True:  # try FSA with test examples

        if interact: sys.stdout.write('> ')
        t = sys.stdin.readline().decode('utf8').strip()
        if len(t) == 0: break
        print 'text=', '[', t, ']'
        nma = patn.match(list(t), tre)

    if interact: sys.stdout.write('\n')