Fix for the preview and for dataset streaming

#1
by lhoestq HF staff - opened
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]