You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where "fields" attribute is a list that contains a dictionary. This will lead to an AttributeError: 'list' object has no attribute 'items' because in torchtext/data/example.py we have:
@classmethod
def fromJSON(cls, data, **fields**):
return cls.fromdict(json.loads(data), **fields**)
@classmethod
def fromdict(cls, data, **fields**):
ex = cls()
for key, vals in **fields.items()**:
where the field value (currently a list) is processed by function fromdict with a ".item()" operator.
So the example in the README.md file should be changed to:
In README.md, the current example for data.TabularDataset with json file input looks like this:
sentiment = data.TabularDataset(
path='data/sentiment/train.json', format='json',
fields=[{'sentence_tokenized': ('text', data.Field(sequential=True)),
'sentiment_gold': ('labels', data.Field(sequential=False))}])
where "fields" attribute is a list that contains a dictionary. This will lead to an AttributeError: 'list' object has no attribute 'items' because in torchtext/data/example.py we have:
where the field value (currently a list) is processed by function fromdict with a ".item()" operator.
So the example in the README.md file should be changed to:
sentiment = data.TabularDataset(
path='data/sentiment/train.json', format='json',
fields={'sentence_tokenized': ('text', data.Field(sequential=True)),
'sentiment_gold': ('labels', data.Field(sequential=False))})
where "fields" attribute is fed with a dictionary directly.
The text was updated successfully, but these errors were encountered: