* Rename ATTR_IDS to attrs.IDS. Rename ATTR_NAMES to attrs.NAMES. Rename UNIV_POS_IDS to parts_of_speech.IDS

This commit is contained in:
Matthew Honnibal 2015-10-10 17:55:55 +11:00
parent 3cea417852
commit 94bafc1417
5 changed files with 10 additions and 11 deletions

View File

@ -1,4 +1,4 @@
ATTR_IDS = { IDS = {
"NULL_ATTR": NULL_ATTR, "NULL_ATTR": NULL_ATTR,
"IS_ALPHA": IS_ALPHA, "IS_ALPHA": IS_ALPHA,
"IS_ASCII": IS_ASCII, "IS_ASCII": IS_ASCII,
@ -87,4 +87,4 @@ ATTR_IDS = {
} }
# ATTR IDs, in order of the symbol # ATTR IDs, in order of the symbol
ATTR_NAMES = [key for key, value in sorted(ATTR_IDS.items(), key=lambda item: item[1])] NAMES = [key for key, value in sorted(IDS.items(), key=lambda item: item[1])]

View File

@ -6,7 +6,7 @@ try:
except ImportError: except ImportError:
import json import json
from .parts_of_speech import UNIV_POS_NAMES from .parts_of_speech import IDS as POS_IDS
from .parts_of_speech cimport ADJ, VERB, NOUN, PUNCT from .parts_of_speech cimport ADJ, VERB, NOUN, PUNCT
@ -24,7 +24,7 @@ cdef class Morphology:
self.rich_tags[i].id = i self.rich_tags[i].id = i
self.rich_tags[i].name = self.strings[tag_str] self.rich_tags[i].name = self.strings[tag_str]
self.rich_tags[i].morph = 0 self.rich_tags[i].morph = 0
self.rich_tags[i].pos = UNIV_POS_NAMES[props['pos'].upper()] self.rich_tags[i].pos = POS_IDS[props['pos'].upper()]
self.reverse_index[self.rich_tags[i].name] = i self.reverse_index[self.rich_tags[i].name] = i
self._cache = PreshMapArray(self.n_tags) self._cache = PreshMapArray(self.n_tags)

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
UNIV_POS_NAMES = { IDS = {
"NO_TAG": NO_TAG, "NO_TAG": NO_TAG,
"ADJ": ADJ, "ADJ": ADJ,
"ADP": ADP, "ADP": ADP,
@ -23,3 +23,6 @@ UNIV_POS_NAMES = {
"EOL": EOL, "EOL": EOL,
"SPACE": SPACE "SPACE": SPACE
} }
NAMES = [key for key, value in sorted(IDS.items(), key=lambda item: item[1])]

View File

@ -14,7 +14,6 @@ from ..typedefs cimport attr_t, flags_t
from ..attrs cimport attr_id_t from ..attrs cimport attr_id_t
from ..attrs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER from ..attrs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER
from ..attrs cimport POS, LEMMA, TAG, DEP, HEAD, SPACY, ENT_IOB, ENT_TYPE from ..attrs cimport POS, LEMMA, TAG, DEP, HEAD, SPACY, ENT_IOB, ENT_TYPE
from ..parts_of_speech import UNIV_POS_NAMES
from ..parts_of_speech cimport CONJ, PUNCT, NOUN from ..parts_of_speech cimport CONJ, PUNCT, NOUN
from ..parts_of_speech cimport univ_pos_t from ..parts_of_speech cimport univ_pos_t
from ..lexeme cimport Lexeme from ..lexeme cimport Lexeme

View File

@ -9,7 +9,7 @@ import numpy
from ..lexeme cimport Lexeme from ..lexeme cimport Lexeme
from ..parts_of_speech import UNIV_POS_NAMES from .. import parts_of_speech
from ..attrs cimport LEMMA from ..attrs cimport LEMMA
from ..attrs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER from ..attrs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER
@ -318,7 +318,7 @@ cdef class Token:
property pos_: property pos_:
def __get__(self): def __get__(self):
return _pos_id_to_string[self.c.pos] return parts_of_speech.NAMES[self.c.pos]
property tag_: property tag_:
def __get__(self): def __get__(self):
@ -363,6 +363,3 @@ cdef class Token:
property like_email: property like_email:
def __get__(self): return Lexeme.c_check_flag(self.c.lex, LIKE_EMAIL) def __get__(self): return Lexeme.c_check_flag(self.c.lex, LIKE_EMAIL)
_pos_id_to_string = {id_: string for string, id_ in UNIV_POS_NAMES.items()}