Skip to content

Commit

Permalink
close file and compare the result with the old way.
Browse files Browse the repository at this point in the history
  • Loading branch information
qingqing01 committed Mar 2, 2017
1 parent 0dd5329 commit ba1c978
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions python/paddle/v2/dataset/conll05.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import paddle.v2.dataset.common
#import paddle.v2.dataset.common
import common
import tarfile
import gzip
import itertools
Expand Down Expand Up @@ -49,11 +50,9 @@ def load_dict(filename):

def corpus_reader(data_path, words_name, props_name):
"""
Read one corpus by corpus name. It returns an iterator. Each element of
Read one corpus. It returns an iterator. Each element of
this iterator is a tuple including sentence and labels. The sentence is
consist of a list of word IDs. The labels include a list of label IDs.
:param name: corpus name.
:type name: basestring
:return: a iterator of data.
:rtype: iterator
"""
Expand Down Expand Up @@ -104,7 +103,8 @@ def reader():
lbl_seq.append('B-' + cur_tag)
is_in_bracket = True
else:
print 'error:', l
raise RuntimeError('Unexpected label: %s' %
l)

yield sentences, verb_list[i], lbl_seq

Expand All @@ -115,6 +115,10 @@ def reader():
sentences.append(word)
one_seg.append(label)

pf.close()
wf.close()
tf.close()

return reader


Expand Down

0 comments on commit ba1c978

Please sign in to comment.