"""
实现额外的方法
"""
import re

def tokenlize(sentence):
    """
    进行文本分词
    :param sentence: str
    :return: [str,str,str]
    """

    fileters = ['!', '"', '#', '$', '%', '&', '\(', '\)', '\*', '\+', ',', '-', '\.', '/', ':', ';', '<', '=', '>',
                '\?', '@', '\[', '\\', '\]', '^', '_', '`', '\{', '\|', '\}', '~', '\t', '\n', '\x97', '\x96', '”', '“', ]
    sentence = sentence.lower() #把大写转化为小写
    sentence = re.sub("<br />"," ",sentence)
    # sentence = re.sub("I'm","I am",sentence)
    # sentence = re.sub("isn't","is not",sentence)
    sentence = re.sub("|".join(fileters)," ",sentence)
    result = [i for i in sentence.split(" ") if len(i)>0]

    return result

  

相关文章:

  • 2022-01-03
  • 2021-11-18
  • 2021-11-16
  • 2021-12-17
  • 2022-01-23
  • 2022-12-23
  • 2021-06-04
  • 2021-04-04
猜你喜欢
  • 2022-12-23
  • 2021-07-24
  • 2021-10-20
  • 2022-12-23
  • 2021-12-19
  • 2022-01-15
  • 2021-04-05
相关资源
相似解决方案