コード例 #1
0
     exit()
 if merged_yn == 'yes':
     merged_use = True
 try:
     sbd = MaxentBasedSBD(dictpath)
     sbd.set(modelname, threshold, filename)
     document = sbd.get(filename)
     line = ''
     lineno = 1
     for id in range(document.length()):
         prev = document.prev(id)
         curr = document.token(id)
         next = document.next(id)
         eos = False
         if True: # 2008.10.13 문장경계후보를 모든위치로 변경 curr.isEoe():
             eos = sbd.eval(document, id, prev, curr, next, syllable_length, merged_use)
         else:
             assert(False == curr.isEos())
             eos = False
         if eos == None:
             continue; # null field found
         if functype == 'seg':
             line += curr.value
             if curr.isEoe():
                 line += ' '
             if eos and len(line.strip()) > 0:
                 if line[0:1] == ' ':
                     print ''
                 print line.strip() + '\n'
                 line = ''
         elif functype == 'eval':
コード例 #2
0
        exit()
    filename = sys.argv[1]
    functype = sys.argv[2]
    try:
        sbd = RuleBasedSBD()
        sbd.set(filename)
        document = sbd.get(filename)
        line = ''
        lineno = 1

        for id in range(document.length()):
            curr = document.token(id)
            prev = document.prev(id)
            next = document.next(id)
            if curr.isEoe():
                eos = sbd.eval(document, prev, curr, next)
            else:
                eos = False

            if functype == 'seg':
                line += curr.value
                if curr.isEoe():
                    line += ' '
                if eos:
                    print line
                    line = ''
            elif functype == 'eval':
                res = sbd.calc(curr.isEos(), eos)
                if curr.isEos():
                    lineno += 1
                if (lineno % 10000) == 0: