def test(): dictionary = get_dict('cn') tokenizer = Tokenizer(dictionary) lines = [ '南京市长江大桥', '独立自主和平等独立的原则', '讨论战争与和平等问题', '他骑在马上', '马上过来', '我今晚得到达南京', '我得到达克宁公司去', '从小学电脑', '他从小学毕业后', '幼儿园地节目', '一阵风吹过来', '今天有阵风', '他学会了解数学难题', '乒乓球拍卖完了', ] for line in lines: print(line) print(tokenizer.tokenize(line)) dictionary.save_model()
def run(): dictionary = get_dict('cn') tokenizer = Tokenizer(dictionary) try: while True: line = input('>> Quid negoti est: ').strip() tokens = tokenizer.tokenize(line) print(' '.join(tokens)) except (KeyboardInterrupt, EOFError): dictionary.save_model() logging.info('[System] bye')
def test(): dictionary = get_dict('en') lemmatizer = Lemmatizer(dictionary) words = [ 'were', 'had', 'done', 'did', 'saith', 'thee', 'lies', 'studies', 'flying', 'liked', 'took', 'went', 'gone', 'sat', 'geese', 'tomatoes', 'photos', 'friends', 'stones', 'leaves', ] for word in words: print('[%s] -> ' % word, end='') print(dictionary.lookup(lemmatizer.lemmatize(word))) dictionary.save_model()
def run(): dictionary = get_dict('en') lemmatizer = Lemmatizer(dictionary) try: while True: line = input('>> Quid negoti est: ').strip() if line.startswith(EXEC_MARK): # take as shellcmd shell(line[1:]) else: for word in line.split(): fword = lemmatizer.lemmatize(word) print(dictionary.lookup(fword)) except (KeyboardInterrupt, EOFError): dictionary.save_model() logging.info('[System] bye')
def start_game(file): """ This function @param file """ word = dictionary.get_dict(file) info = { 'guess': INITIAL_GUESSES, 'lives': INITIAL_LIVES, 'score': 0, 'correct': 0, 'skip': 1 } info = dictionary.get_word(word, info) graphic_gui.make_gui(word, info)
def run(): dictionary = get_dict('en') parser = Parser(dictionary) try: print('============================================================================') print(' You are high recommended to use these words ONLY for sentence weaving, but ') print(' you could still type whaterver you like, since output is not guaranteed. ') print('----------------------------------------------------------------------------') pp(VOCABULARY, compact=True) print('============================================================================') while True: line = input('>> Quid negoti est: ').strip() print(line) print(parser.parse(line)) except (KeyboardInterrupt, EOFError): dictionary.save_model() logging.info('[System] bye')
def test(): dictionary = get_dict('en') parser = Parser(dictionary) sents = [ # no punctuations please 'are you OK', 'where is my knife', 'I will push if you pop', 'you play basketball like CaiXukun', 'my inner heart has no fluctuations even I want to laugh', 'would you like to swim with me tomorrow', 'nothing happened eventually because you run away', 'he has read an interesting book at home yesterday if you die', ] for sent in sents: print(sent) print(parser.parse(sent)) dictionary.save_model()