zoukankan      html  css  js  c++  java
  • 文本分析 笔记

    Python 文本分析 笔记

    中文停用词处理

    自行下载 shotwords.txt,代码如下:

    def stopwordslist(filepath): 
        stopwords = [line.strip() for line in open(filepath, 'r', encoding='utf-8').readlines()] 
        return stopwords 
     
     
    # 对句子进行分词 
    def seg_sentence(sentence): 
        sentence_seged = jieba.cut(sentence.strip()) 
        stopwords = stopwordslist('/root/stopwords.txt')  # 这里加载停用词的路径 
        outstr = '' 
        for word in sentence_seged: 
            if word not in stopwords: 
                if word != ' '
                    outstr += word 
                    outstr += " " 
        return outstr
     
  • 相关阅读:
    约瑟夫问题
    再谈Bellman-Ford
    Uva 11478 Halum操作
    Uva 11090 在环中
    Bellman-Ford
    Uva 10537 过路费
    Uva 10917
    LA 3713 宇航员分组
    2-SAT
    LA 3211 飞机调度
  • 原文地址:https://www.cnblogs.com/dalton/p/11354027.html
Copyright © 2011-2022 走看看