@ -1,8 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<module type="PYTHON_MODULE" version="4"> | |||||
<component name="NewModuleRootManager"> | |||||
<content url="file://$MODULE_DIR$" /> | |||||
<orderEntry type="inheritedJdk" /> | |||||
<orderEntry type="sourceFolder" forTests="false" /> | |||||
</component> | |||||
</module> |
@ -0,0 +1,105 @@ | |||||
# import re | |||||
# import torch | |||||
# import torch.nn as nn | |||||
# import jieba | |||||
# import pandas as pd | |||||
# # from torchtext import data | |||||
# | |||||
# class LSTMNet(nn.Module): | |||||
# def __init__(self,vocab_size,embedding_dim,hidden_dim,layer_dim,output_dim): | |||||
# super(LSTMNet,self).__init__() | |||||
# self.hidden_dim= hidden_dim | |||||
# self.layer_dim = layer_dim | |||||
# self.embedding = nn.Embedding(vocab_size,embedding_dim) | |||||
# # LSTM+全连接 | |||||
# self.lstm = nn.LSTM(embedding_dim,hidden_dim,layer_dim, | |||||
# batch_first=True) | |||||
# self.fcl= nn.Linear(hidden_dim,output_dim) | |||||
# def forward(self,x): | |||||
# embeds = self.embedding(x) | |||||
# r_out,(h_n,h_c)=self.lstm(embeds,None) | |||||
# out = self.fcl(r_out[:,-1,:]) | |||||
# return out | |||||
# | |||||
# def Chinese_pre(text_data,stopwords): | |||||
# # 字母转化为小写, 去掉数字 | |||||
# text_data = text_data.lower() | |||||
# text_data = re.sub("\d+","",text_data) | |||||
# # 分词,使用精确模式 | |||||
# text_data = list(jieba.cut(text_data,cut_all = False)) | |||||
# # 去除停用词和多余空格 | |||||
# text_data = [word.strip() for word in text_data if word not in stopwords] | |||||
# # 处理后的词语使用空格连接为字符串 | |||||
# text_data = " ".join(text_data) | |||||
# return text_data | |||||
# | |||||
# def TexttoLable(textdata): | |||||
# # 将输入文本转为tensor | |||||
# # 首先对文本进行分词 | |||||
# from nltk.corpus import stopwords | |||||
# import nltk | |||||
# nltk.download('stopwords') | |||||
# words = stopwords.words('english') | |||||
# stopwords = set() | |||||
# with open("stop.txt",encoding="utf-8") as infile: | |||||
# for line in infile: | |||||
# line = line.rstrip('\n') | |||||
# if line: | |||||
# stopwords.add(line.lower()) | |||||
# for i in words: | |||||
# stopwords.add(i) | |||||
# textdata=Chinese_pre(textdata,stopwords) | |||||
# | |||||
# data1=[] | |||||
# for i in range(128): | |||||
# data1.append(textdata) | |||||
# df = pd.DataFrame({'cutword':data1}) | |||||
# | |||||
# df.to_csv("tmp.csv") | |||||
# | |||||
# mytokenize = lambda x:x.split() | |||||
# from torchtext.legacy import data | |||||
# TEXT = data.Field(sequential = True,tokenize = mytokenize, | |||||
# include_lengths=True,use_vocab=True, | |||||
# batch_first=True,fix_length=40) | |||||
# | |||||
# LABEL = data.Field(sequential =False,use_vocab=False, | |||||
# pad_token=None,unk_token=None) | |||||
# # 对所有读取的数据集的列进行处理 | |||||
# text_data_fields = [ | |||||
# ("labelcode",LABEL), | |||||
# ("cutword",TEXT) | |||||
# ] | |||||
# # 读取数据 | |||||
# # 读取数据 | |||||
# traindata,valdata,testdata = data.TabularDataset.splits( | |||||
# path="./",format="csv",train="tmp.csv",fields = text_data_fields, | |||||
# validation = "tmp.csv", | |||||
# test ="tmp.csv",skip_header=True | |||||
# ) | |||||
# | |||||
# em = testdata.examples[0] | |||||
# TEXT.build_vocab(traindata,max_size=100,vectors=None) | |||||
# | |||||
# # 定义一个迭代器,将类似长度的示例一起批处理 | |||||
# BATCH_SIZE=128 | |||||
# test_iter = data.BucketIterator(testdata,batch_size=128) | |||||
# | |||||
# | |||||
# vocab_size=len(TEXT.vocab) | |||||
# embedding_dim=50 | |||||
# hidden_dim=256 | |||||
# layer_dim=1 | |||||
# output_dim=4 | |||||
# lstmmodel = LSTMNet(vocab_size, embedding_dim, hidden_dim, layer_dim, output_dim) | |||||
# | |||||
# res=0 | |||||
# model = torch.load("model.pkl") | |||||
# for step,batch in enumerate(test_iter): | |||||
# textfinal = batch.cutword[0] | |||||
# out = model(textfinal) | |||||
# pre_lab = torch.argmax(out,1) | |||||
# res = pre_lab[0] | |||||
# print(res.numpy()) | |||||
# | |||||
# TexttoLable("萝卜云服交流群等3个会话 ") |
@ -0,0 +1,129 @@ | |||||
,cutword | |||||
0,萝卜 云服 交流 群等个 话 | |||||
1,萝卜 云服 交流 群等个 话 | |||||
2,萝卜 云服 交流 群等个 话 | |||||
3,萝卜 云服 交流 群等个 话 | |||||
4,萝卜 云服 交流 群等个 话 | |||||
5,萝卜 云服 交流 群等个 话 | |||||
6,萝卜 云服 交流 群等个 话 | |||||
7,萝卜 云服 交流 群等个 话 | |||||
8,萝卜 云服 交流 群等个 话 | |||||
9,萝卜 云服 交流 群等个 话 | |||||
10,萝卜 云服 交流 群等个 话 | |||||
11,萝卜 云服 交流 群等个 话 | |||||
12,萝卜 云服 交流 群等个 话 | |||||
13,萝卜 云服 交流 群等个 话 | |||||
14,萝卜 云服 交流 群等个 话 | |||||
15,萝卜 云服 交流 群等个 话 | |||||
16,萝卜 云服 交流 群等个 话 | |||||
17,萝卜 云服 交流 群等个 话 | |||||
18,萝卜 云服 交流 群等个 话 | |||||
19,萝卜 云服 交流 群等个 话 | |||||
20,萝卜 云服 交流 群等个 话 | |||||
21,萝卜 云服 交流 群等个 话 | |||||
22,萝卜 云服 交流 群等个 话 | |||||
23,萝卜 云服 交流 群等个 话 | |||||
24,萝卜 云服 交流 群等个 话 | |||||
25,萝卜 云服 交流 群等个 话 | |||||
26,萝卜 云服 交流 群等个 话 | |||||
27,萝卜 云服 交流 群等个 话 | |||||
28,萝卜 云服 交流 群等个 话 | |||||
29,萝卜 云服 交流 群等个 话 | |||||
30,萝卜 云服 交流 群等个 话 | |||||
31,萝卜 云服 交流 群等个 话 | |||||
32,萝卜 云服 交流 群等个 话 | |||||
33,萝卜 云服 交流 群等个 话 | |||||
34,萝卜 云服 交流 群等个 话 | |||||
35,萝卜 云服 交流 群等个 话 | |||||
36,萝卜 云服 交流 群等个 话 | |||||
37,萝卜 云服 交流 群等个 话 | |||||
38,萝卜 云服 交流 群等个 话 | |||||
39,萝卜 云服 交流 群等个 话 | |||||
40,萝卜 云服 交流 群等个 话 | |||||
41,萝卜 云服 交流 群等个 话 | |||||
42,萝卜 云服 交流 群等个 话 | |||||
43,萝卜 云服 交流 群等个 话 | |||||
44,萝卜 云服 交流 群等个 话 | |||||
45,萝卜 云服 交流 群等个 话 | |||||
46,萝卜 云服 交流 群等个 话 | |||||
47,萝卜 云服 交流 群等个 话 | |||||
48,萝卜 云服 交流 群等个 话 | |||||
49,萝卜 云服 交流 群等个 话 | |||||
50,萝卜 云服 交流 群等个 话 | |||||
51,萝卜 云服 交流 群等个 话 | |||||
52,萝卜 云服 交流 群等个 话 | |||||
53,萝卜 云服 交流 群等个 话 | |||||
54,萝卜 云服 交流 群等个 话 | |||||
55,萝卜 云服 交流 群等个 话 | |||||
56,萝卜 云服 交流 群等个 话 | |||||
57,萝卜 云服 交流 群等个 话 | |||||
58,萝卜 云服 交流 群等个 话 | |||||
59,萝卜 云服 交流 群等个 话 | |||||
60,萝卜 云服 交流 群等个 话 | |||||
61,萝卜 云服 交流 群等个 话 | |||||
62,萝卜 云服 交流 群等个 话 | |||||
63,萝卜 云服 交流 群等个 话 | |||||
64,萝卜 云服 交流 群等个 话 | |||||
65,萝卜 云服 交流 群等个 话 | |||||
66,萝卜 云服 交流 群等个 话 | |||||
67,萝卜 云服 交流 群等个 话 | |||||
68,萝卜 云服 交流 群等个 话 | |||||
69,萝卜 云服 交流 群等个 话 | |||||
70,萝卜 云服 交流 群等个 话 | |||||
71,萝卜 云服 交流 群等个 话 | |||||
72,萝卜 云服 交流 群等个 话 | |||||
73,萝卜 云服 交流 群等个 话 | |||||
74,萝卜 云服 交流 群等个 话 | |||||
75,萝卜 云服 交流 群等个 话 | |||||
76,萝卜 云服 交流 群等个 话 | |||||
77,萝卜 云服 交流 群等个 话 | |||||
78,萝卜 云服 交流 群等个 话 | |||||
79,萝卜 云服 交流 群等个 话 | |||||
80,萝卜 云服 交流 群等个 话 | |||||
81,萝卜 云服 交流 群等个 话 | |||||
82,萝卜 云服 交流 群等个 话 | |||||
83,萝卜 云服 交流 群等个 话 | |||||
84,萝卜 云服 交流 群等个 话 | |||||
85,萝卜 云服 交流 群等个 话 | |||||
86,萝卜 云服 交流 群等个 话 | |||||
87,萝卜 云服 交流 群等个 话 | |||||
88,萝卜 云服 交流 群等个 话 | |||||
89,萝卜 云服 交流 群等个 话 | |||||
90,萝卜 云服 交流 群等个 话 | |||||
91,萝卜 云服 交流 群等个 话 | |||||
92,萝卜 云服 交流 群等个 话 | |||||
93,萝卜 云服 交流 群等个 话 | |||||
94,萝卜 云服 交流 群等个 话 | |||||
95,萝卜 云服 交流 群等个 话 | |||||
96,萝卜 云服 交流 群等个 话 | |||||
97,萝卜 云服 交流 群等个 话 | |||||
98,萝卜 云服 交流 群等个 话 | |||||
99,萝卜 云服 交流 群等个 话 | |||||
100,萝卜 云服 交流 群等个 话 | |||||
101,萝卜 云服 交流 群等个 话 | |||||
102,萝卜 云服 交流 群等个 话 | |||||
103,萝卜 云服 交流 群等个 话 | |||||
104,萝卜 云服 交流 群等个 话 | |||||
105,萝卜 云服 交流 群等个 话 | |||||
106,萝卜 云服 交流 群等个 话 | |||||
107,萝卜 云服 交流 群等个 话 | |||||
108,萝卜 云服 交流 群等个 话 | |||||
109,萝卜 云服 交流 群等个 话 | |||||
110,萝卜 云服 交流 群等个 话 | |||||
111,萝卜 云服 交流 群等个 话 | |||||
112,萝卜 云服 交流 群等个 话 | |||||
113,萝卜 云服 交流 群等个 话 | |||||
114,萝卜 云服 交流 群等个 话 | |||||
115,萝卜 云服 交流 群等个 话 | |||||
116,萝卜 云服 交流 群等个 话 | |||||
117,萝卜 云服 交流 群等个 话 | |||||
118,萝卜 云服 交流 群等个 话 | |||||
119,萝卜 云服 交流 群等个 话 | |||||
120,萝卜 云服 交流 群等个 话 | |||||
121,萝卜 云服 交流 群等个 话 | |||||
122,萝卜 云服 交流 群等个 话 | |||||
123,萝卜 云服 交流 群等个 话 | |||||
124,萝卜 云服 交流 群等个 话 | |||||
125,萝卜 云服 交流 群等个 话 | |||||
126,萝卜 云服 交流 群等个 话 | |||||
127,萝卜 云服 交流 群等个 话 |