示例#1
0
 def msgpreprocess(self, text):
     at = False
     for t in jieba.cut(text, HMM=False):
         if t == '@':
             at = True
         elif at:
             yield '@' + t
             at = False
         elif t.lower() not in self.stopwords:
             # t.isidentifier() and
             yield t
示例#2
0
 def msgpreprocess(self, text):
     at = False
     for t in jieba.cut(text, HMM=False):
         if t == '@':
             at = True
         elif at:
             yield '@' + t
             at = False
         elif t.lower() not in self.stopwords:
             # t.isidentifier() and 
             yield t
示例#3
0
def getsayingbytext(text='', mode='r'):
    global SAY_P
    with SAY_LCK:
        text = (mode + ' '.join(mosesproxy.cut(zhconv.convert(text, 'zh-hans'), HMM=False)[:60]).strip()).encode('utf-8') + b'\n'
        try:
            SAY_P.stdin.write(text)
            SAY_P.stdin.flush()
            say = SAY_P.stdout.readline().strip().decode('utf-8')
        except BrokenPipeError:
            SAY_P = subprocess.Popen(SAY_CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd='vendor')
            SAY_P.stdin.write(text)
            SAY_P.stdin.flush()
            say = SAY_P.stdout.readline().strip().decode('utf-8')
    return say
示例#4
0
def cmd_cut(tinput, lang):
    if lang == 'c':
        return ' '.join(mosesproxy.jiebazhc.cut(tinput, HMM=False))
    else:
        return ' '.join(mosesproxy.cut(tinput, HMM=False))