Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change a place of import io at onmt/io/TextDataset.py #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions craigslistbargain/model/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import numpy as np
import nltk
from nltk import ngrams
from nltk.corpus import stopwords
from collections import defaultdict
Expand All @@ -11,6 +12,7 @@
from core.tokenizer import tokenize

class Parser(BaseParser):
nltk.download('stopwords')
stopwords = set(stopwords.words('english'))
stopwords.update(['may', 'might', 'rent', 'new', 'brand', 'low', 'high', 'now', 'available'])

Expand Down
2 changes: 1 addition & 1 deletion onmt/io/TextDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from collections import Counter
from itertools import chain
import io
import codecs
import sys

Expand Down Expand Up @@ -297,6 +296,7 @@ def __init__(self, corpus_path, line_truncate, side, shard_size,
this iterator should align its step with.
"""
try:
import io
# The codecs module seems to have bugs with seek()/tell(),
# so we use io.open().
self.corpus = io.open(corpus_path, "r", encoding="utf-8")
Expand Down