- 博客(5)
- 问答 (5)
- 收藏
- 关注
原创 nltk情感分析、文本相似度、文本分类
import nltkfrom nltk.stem import WordNetLemmatizerfrom nltk.corpus import stopwordsfrom nltk.classify import NaiveBayesClassifiertext1 = 'I like the movie so much!'text2 = 'That is a good movie.'text3 = 'This is a great one.'text4 = 'That is a real
2020-09-26 13:37:50 2126
原创 英文分词nltk进行文本清洗
import nltknltk.download('punkt')#一个默认的方法,也可以用别的方法下载后可能会提示unzipped什么的,不用管,再运行一遍会发现已经satisfied了import nltksentence="python is a widely use high-level programing language"tokens=nltk.word_tokenize(sentence)print(tokens)结果:[‘python’, ‘is’, ‘a’, ‘wide
2020-09-23 20:25:13 1080
原创 聚类模型kmeans算法python实现
#main.pyimport randomfrom kmeans_tools import Cluster, get_distance, gen_random_sampleimport matplotlib.pyplot as pltfrom matplotlib import colors as mcolorsdef kmeans(samples, k, cutoff): """ kmeans函数 """ # 随机选k个样本点作为初始聚类中心
2020-09-19 15:06:16 256
原创 python读取多种格式文件(txt,csv,json,sqlite)
1、txt①读取全部内容txt_filename = './files/python_baidu.txt'# 打开文件file_obj = open(txt_filename, 'r', encoding='utf-8')# 读取整个文件内容all_content = file_obj.read()# 关闭文件file_obj.close()print(all_content)②按行读取txt_filename = './files/python_baidu.txt'# 打开文件
2020-09-18 20:21:32 484
原创 leetcode【简单】1、两数之和
题目:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。解法1:暴力解法,两层遍历,第二层只需遍历第一层取的数以后的数,用时6440msclass Solution: def twoSum(self,nums,target): n = len(nums) for x in range(n): for y in range(x+1,n):
2020-09-18 15:57:02 61
空空如也
启动springboot,localhost无法访问
2023-08-04
使用pygame为什么总是闪退?
2020-08-17
图像分类OpenCV中svm使用报错
2019-05-22
Python爬取小说 有些章节爬得到有些爬不到 分别爬取都是可以的
2018-12-19
Python爬取文本写入CSV,用replace替换br标签后,每个字后面都会换行?
2018-12-18
TA创建的收藏夹 TA关注的收藏夹
TA关注的人