创建 TabularDataSet 但没有给出列名 (Torchtext)

问题描述

我有一个看起来像这样的 TSV 文件

3   It 's a lovely film with lovely performances by Buy and Accorsi .
2   No one goes unindicted here,which is probably for the best .
3   And if you 're not nearly moved to tears by a couple of scenes,you 've got ice water in your veins .
4   A warm,funny,engaging film .

没有列名,但我想用 tsv 文件创建一个 TabularDataSet。 这怎么可能?在我看到的所有文档和教程中,都需要文件的列名(如本教程中的第 3 点:http://mlexplained.com/2018/02/08/a-comprehensive-tutorial-to-torchtext/),或者在本例中的“字段”变量中:

import torch
import torch.nn as nn
import torch.optim as optim
from torchtext.data import Field,TabularDataset,BucketIterator

tokenize = lambda x: x.split()

text = Field(sequential=True,use_vocab=True,tokenize=tokenize,lower=True)
score = Field(sequential=False,use_vocab=False)

fields = {"quote": ("q",quote),"score": ("s",score)}

train_data,test_data,dev_data = TabularDataset.splits(
                                         path='mypath',train='sentiment.train.tsv',test= 'sentiment.test.tsv',dev = 'sentiment.dev.tsv',format='tsv',fields=fields)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)