Extracting whole words

前端 未结 4 2110
借酒劲吻你
借酒劲吻你 2020-12-03 15:38

I have a large set of real-world text that I need to pull words out of to input into a spell checker. I\'d like to extract as many meaningful words as possible with

4条回答
  •  悲哀的现实
    2020-12-03 16:05

    Sample code

    print re.search(ur'(?u)ривет\b', ur'Привет')
    print re.search(ur'(?u)\bривет\b', ur'Привет')
    

    or

    s = ur"abcd ААБВ"
    import re
    rx1 = re.compile(ur"(?u)АБВ")
    rx2 = re.compile(ur"(?u)АБВ\b")
    rx3 = re.compile(ur"(?u)\bАБВ\b")
    print rx1.findall(s)
    print rx2.findall(s)
    print rx3.findall(s)
    

提交回复
热议问题