def __getitem__(self,word): if Dictionary.dict_words.has_key(word): return Dictionary.dict_words[word] elif is_chinese_number(word):#数字识别 return Word(word,0) elif len(word) == 1:#生僻字词频为0 return Word(word,0) else: return None
def __getitem__(self, word): if Dictionary.dict_words.has_key(word): return Dictionary.dict_words[word] elif is_chinese_number(word): #数字识别 return Word(word, 0) elif len(word) == 1: #生僻字词频为0 return Word(word, 0) else: return None
def combine_quantifier(words): pos = 0 words_length = len(words) result = [] while pos < words_length: word1 = words[pos] if (re.match('^%s$' % number_pattern, word1) or\ is_chinese_number(word1)) and pos < words_length -1: word2 = words[pos + 1] if word2 in Dictionary.quantifier_words: result.append(word1 + word2) pos += 2 continue result.append(word1) pos += 1 return result
def combine_quantifier(words): pos = 0 words_length = len(words) result = [] while pos < words_length: word1 = words[pos] if (re.match('^%s$' % number_pattern, word1) or\ is_chinese_number(word1)) and pos < words_length -1: word2 = words[pos+1] if word2 in Dictionary.quantifier_words: result.append(word1+word2) pos += 2 continue result.append(word1) pos += 1 return result