lhoestq HF staff commited on
Commit
d477d3a
·
1 Parent(s): 46319c5

Fix for the preview and for dataset streaming

Browse files

Since the dataset viewer uses dataset streaming to show the first rows of your dataset, you have to make the dataset compatible with streaming for the preview to work.

However `xml.dom.minidom.parse` does not support streaming out-of-the-box (it can't read a remote file). To fix it, you need to `open` the file first, before passing it to `xml.dom.minidom.parse`.

This works because `open` in the dataset script is extended to support reading remote files over HTTP, especially to enable streaming.

Files changed (1) hide show
  1. SemEval2015.py +2 -1
SemEval2015.py CHANGED
@@ -143,7 +143,8 @@ class SemEvalXMLDataset():
143
  self.SentenceWithOpinions = []
144
  self.xml_path = file_name
145
 
146
- self.sentenceXmlList = parse(self.xml_path).getElementsByTagName('sentence')
 
147
 
148
  for sentenceXml in self.sentenceXmlList:
149
  reviewId = sentenceXml.getAttribute("id").split(':')[0]
 
143
  self.SentenceWithOpinions = []
144
  self.xml_path = file_name
145
 
146
+ with open(self.xml_path) as f:
147
+ self.sentenceXmlList = parse(f).getElementsByTagName('sentence')
148
 
149
  for sentenceXml in self.sentenceXmlList:
150
  reviewId = sentenceXml.getAttribute("id").split(':')[0]