stanfordSentimentTreebank 的映射关系
来源:互联网 发布:科勒橱柜 知乎 编辑:程序博客网 时间:2024/06/05 05:48
在stanfordSentimentTreebank中 有好几个txt文件
下面我来梳理下这个东西
datasetSentences.txt: 里面分别是 sentence_index, sentence 对应为 句子的序号和 对应的句子
datasetSplit.txt: 里面分别是 sentence_index splitset_label 对应为 句子的序号 和 句子属于的数据集 (分为1:训练集, 2:测试集, 3:验证集)
dictionary.txt: 里面是不同字符,单词,短语,及句子 以及对应的标号 这些标签号可以在 sentiment_labels.txt 中找到一一对应的 sentiment values 其中值的分布为 [0, 0.2], (0.2, 0.4], (0.4, 0.6], (0.6, 0.8], (0.8, 1.0], 我这里直接映射分成1,2,3,4,5类
SOStr.txt: 为对应句子的切分的数据,用‘|’进行分割每个单词
STree.txt: 暂时还没研究
这里需要注意的是,datasetSentences.txt中的每个句子,都可以在dictionary.txt中找到对应的句子 以及标签
后面我会把对应的程序贴上来:主要由4个程序组成。第一个根据分数把标签分为5类。
第二个 到字典对应的标签。
第三个 把句子拆分
第四个 得到训练集测试集和验证集的标签
#coding:utf-8dictPath = '../treeData/sentiment_labels.txt'diction_num = dict()fp = open(dictPath,'r')for i in fp.readlines()[1:]: u = i.replace("\n","").split("|") nu = float(u[1]) if nu<=0.2: uu = 1 elif nu<=0.4: uu = 2 elif nu<=0.6: uu = 3 elif nu<=0.8: uu = 4 else: uu = 5 diction_num[u[0]] = uu #print (diction_num)
txtPath = '../treeData/dictionary.txt'diction = dict()fp=open(txtPath,'r')cc = 1for i in fp.readlines(): u = i.replace("\n","").split("|") diction[u[0]] = diction_num[u[1]] cc += 1fp.close()
txtpath = '../treeData/SOStr.txt'fpp=open(txtpath)arr=[]i = 0for lines in fpp.readlines(): lines = lines.replace("\n","").split("|") for line in lines: arr.append(line.split("|"))fpp.close()
path = 'datasetSplit.txt'fp = open(path)train = []test = []dev = []trainLabel = []testLabel = []devLabel = []k = 0#fptrain = open('train.txt','w')#fptest = open('test.txt','w')#fpdev = open('dev.txt','w')for i in fp.readlines()[1:]: a = i.replace("\n","").split(",") if a[1] == '1': train.append(int(a[0])) trainLabel.append(labels[k]) # fptrain.write(a[0]+" ") # fptrain.write(str(labels[k])) # fptrain.write("\n") elif a[1] == '2': test.append(int(a[0])) testLabel.append(labels[k]) # fptest.write(a[0]+" ") #fptest.write(str(labels[k])) #fptest.write("\n") else: dev.append(int(a[0])) devLabel.append(labels[k]) #fpdev.write(a[0]+" ") #fpdev.write(str(labels[k])) #fpdev.write("\n") k += 1
0 0
- stanfordSentimentTreebank 的映射关系
- 继承关系的映射
- hibernate 的映射关系
- Hibernate的关系映射
- hibernate的映射关系
- JPA的关系映射
- Hibernate的关系映射
- Hibernate的映射关系
- hibernate的关系映射
- Hibernate的关系映射
- Hibernate的关系映射
- Hibernate的映射关系
- hibernate的映射关系
- Hibernate的映射关系
- Hibernate的映射关系
- Hibernate的关联关系映射
- Hibernate的关联关系映射
- Hibernate的关联关系映射
- 1005. 继续(3n+1)猜想 (25)
- 工作组电脑申请域证书
- shell脚本
- 1.C#:数组、ArrayList和List三者的区别
- 魅族手机webview title获取不到
- stanfordSentimentTreebank 的映射关系
- 利用计算器 来转换二,十,十六进制
- python使用问题
- Codeforces 363C Fixing Typos 贪心+字符串模拟
- 以singleTask启动的activity会直接调用OnActivityResult()方法
- Introduction to Model View Presenter on Android
- 高效团队
- ESB
- xgboost笔记