Upload bookcoref.py with huggingface_hub
Browse files- bookcoref.py +6 -4
bookcoref.py
CHANGED
@@ -13,6 +13,8 @@
|
|
13 |
# limitations under the License.
|
14 |
"""BookCoref is a datasets for coreference resolution, with a manually annotated test set and an automatically generated training set."""
|
15 |
|
|
|
|
|
16 |
import json
|
17 |
import logging
|
18 |
import sys
|
@@ -99,15 +101,15 @@ class BookCoref(datasets.GeneratorBasedBuilder):
|
|
99 |
self.logger.info("Initializing BOOKCOREF dataset.")
|
100 |
# Download nltk if not already downloaded
|
101 |
nltk.download("punkt", quiet=True)
|
102 |
-
# Download spaCy model for tokenization if not already downloaded
|
103 |
try:
|
104 |
self.nlp = spacy.load("en_core_web_sm")
|
105 |
except OSError:
|
106 |
self.logger.info("Downloading spaCy model...")
|
107 |
-
|
|
|
108 |
self.nlp = spacy.load("en_core_web_sm")
|
109 |
-
|
110 |
-
self.nlp = spacy.load("en_core_web_sm", exclude=["lemmatizer", "ner", "textcat"])
|
111 |
|
112 |
def _info(self):
|
113 |
features = datasets.Features(
|
|
|
13 |
# limitations under the License.
|
14 |
"""BookCoref is a datasets for coreference resolution, with a manually annotated test set and an automatically generated training set."""
|
15 |
|
16 |
+
import contextlib
|
17 |
+
import io
|
18 |
import json
|
19 |
import logging
|
20 |
import sys
|
|
|
101 |
self.logger.info("Initializing BOOKCOREF dataset.")
|
102 |
# Download nltk if not already downloaded
|
103 |
nltk.download("punkt", quiet=True)
|
104 |
+
# Download and load spaCy model for tokenization if not already downloaded
|
105 |
try:
|
106 |
self.nlp = spacy.load("en_core_web_sm")
|
107 |
except OSError:
|
108 |
self.logger.info("Downloading spaCy model...")
|
109 |
+
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
|
110 |
+
spacy.cli.download("en_core_web_sm") # type: ignore
|
111 |
self.nlp = spacy.load("en_core_web_sm")
|
112 |
+
self.logger.info("spaCy model loaded.")
|
|
|
113 |
|
114 |
def _info(self):
|
115 |
features = datasets.Features(
|