# Encoding = UTF-8 # Import psyco # Psyco. full () Words = [x. rstrip () for x in open ("main. dic", mode = 'R', encoding = 'utf-8')] From smallseg import SEG Seg = SEG () Print ('Load dict ...') Seg. set (words) Print ("Dict is OK .") Def cuttest (text ): Wlist = seg. cut (text) Wlist. reverse () Tmp = "". join (wlist) Print (tmp) Print ("================================== ") If _ name __= = "_ main __": Cuttest ("this is a dark night without a finger. My name is Sun Wukong. I love Beijing. I love Python and C ++. ") Cuttest ("I don't like Japanese kimono. ") Cuttest ("the Thunder Monkey returns to the human world. ") Cuttest ") Cuttest ("I need rent a house ") Cuttest ("Yonghe clothing & accessories Co., Ltd ") Cuttest ("I Love Tiananmen Square, Beijing ") Cuttest ("abc ") Cuttest ("Hidden Markov ") Cuttest ("Ray monkey is a good website ") Cuttest (the word "Microsoft" consists of "MICROcomputer" and "SOFTware ") Cuttest ("grass mud horse and deception horse are popular words this year ") Cuttest ("Ito Yang huatang Head Office Store ") Cuttest ("Institute of computing technology, Chinese Emy of Sciences ") Cuttest ("Romeo and Juliette ") Cuttest ("I bought items and costumes ") |