mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 21:57:15 +03:00
756b66b7c0
* Move Turkish lemmas to a json file Rather than a large dict in Python source, the data is now a big json file. This includes a method for loading the json file, falling back to a compressed file, and an update to MANIFEST.in that excludes json in the spacy/lang directory. This focuses on Turkish specifically because it has the most language data in core. * Transition all lemmatizer.py files to json This covers all lemmatizer.py files of a significant size (>500k or so). Small files were left alone. None of the affected files have logic, so this was pretty straightforward. One unusual thing is that the lemma data for Urdu doesn't seem to be used anywhere. That may require further investigation. * Move large lang data to json for fr/nb/nl/sv These are the languages that use a lemmatizer directory (rather than a single file) and are larger than English. For most of these languages there were many language data files, in which case only the large ones (>500k or so) were converted to json. It may or may not be a good idea to migrate the remaining Python files to json in the future. * Fix id lemmas.json The contents of this file were originally just copied from the Python source, but that used single quotes, so it had to be properly converted to json first. * Add .json.gz to gitignore This covers the json.gz files built as part of distribution. * Add language data gzip to build process Currently this gzip data on every build; it works, but it should be changed to only gzip when the source file has been updated. * Remove Danish lemmatizer.py Missed this when I added the json. * Update to match latest explosion/srsly#9 The way gzipped json is loaded/saved in srsly changed a bit. * Only compress language data if necessary If a .json.gz file exists and is newer than the corresponding json file, it's not recompressed. * Move en/el language data to json This only affected files >500kb, which was nouns for both languages and the generic lookup table for English. * Remove empty files in Norwegian tokenizer It's unclear why, but the Norwegian (nb) tokenizer had empty files for adj/adv/noun/verb lemmas. This may have been a result of copying the structure of the English lemmatizer. This removed the files, but still creates the empty sets in the lemmatizer. That may not actually be necessary. * Remove dubious entries in English lookup.json " furthest" and " skilled" - both prefixed with a space - were in the English lookup table. That seems obviously wrong so I have removed them. * Fix small issues with en/fr lemmatizers The en tokenizer was including the removed _nouns.py file, so that's removed. The fr tokenizer is unusual in that it has a lemmatizer directory with both __init__.py and lemmatizer.py. lemmatizer.py had not been converted to load the json language data, so that was fixed. * Auto-format * Auto-format * Update srsly pin * Consistently use pathlib paths
35 lines
918 B
Python
35 lines
918 B
Python
# coding: utf8
|
|
from __future__ import unicode_literals
|
|
|
|
from pathlib import Path
|
|
|
|
from ._adjectives import ADJECTIVES
|
|
from ._adjectives_irreg import ADJECTIVES_IRREG
|
|
from ._adverbs import ADVERBS
|
|
from ._adverbs_irreg import ADVERBS_IRREG
|
|
from ._nouns_irreg import NOUNS_IRREG
|
|
from ._verbs import VERBS
|
|
from ._verbs_irreg import VERBS_IRREG
|
|
from ._lemma_rules import ADJECTIVE_RULES, NOUN_RULES, VERB_RULES, PUNCT_RULES
|
|
|
|
from ....util import load_language_data
|
|
|
|
LOOKUP = load_language_data(Path(__file__).parent / "lookup.json")
|
|
NOUNS = load_language_data(Path(__file__).parent / "_nouns.json")
|
|
|
|
LEMMA_INDEX = {"adj": ADJECTIVES, "adv": ADVERBS, "noun": NOUNS, "verb": VERBS}
|
|
|
|
LEMMA_EXC = {
|
|
"adj": ADJECTIVES_IRREG,
|
|
"adv": ADVERBS_IRREG,
|
|
"noun": NOUNS_IRREG,
|
|
"verb": VERBS_IRREG,
|
|
}
|
|
|
|
LEMMA_RULES = {
|
|
"adj": ADJECTIVE_RULES,
|
|
"noun": NOUN_RULES,
|
|
"verb": VERB_RULES,
|
|
"punct": PUNCT_RULES,
|
|
}
|