mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-13 09:33:18 +03:00
Fix remaining files. Reenable cython-lint check.
This commit is contained in:
parent
94110a1c6d
commit
56c1fd00eb
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
@ -48,7 +48,7 @@ jobs:
|
||||||
- name: cython-lint
|
- name: cython-lint
|
||||||
run: |
|
run: |
|
||||||
python -m pip install cython-lint -c requirements.txt
|
python -m pip install cython-lint -c requirements.txt
|
||||||
# cython-lint spacy --ignore E501,W291,E266
|
cython-lint spacy --ignore E501,W291,E266
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
name: Test
|
name: Test
|
||||||
|
|
|
@ -83,10 +83,11 @@ cdef class Morphology:
|
||||||
features = self.normalize_attrs(features)
|
features = self.normalize_attrs(features)
|
||||||
string_features = {self.strings.as_string(field): self.strings.as_string(values) for field, values in features.items()}
|
string_features = {self.strings.as_string(field): self.strings.as_string(values) for field, values in features.items()}
|
||||||
# normalized UFEATS string with sorted fields and values
|
# normalized UFEATS string with sorted fields and values
|
||||||
norm_feats_string = self.FEATURE_SEP.join(sorted([
|
norm_feats_string = self.FEATURE_SEP.join(
|
||||||
self.FIELD_SEP.join([field, values])
|
sorted(
|
||||||
for field, values in string_features.items()
|
[self.FIELD_SEP.join([field, values]) for field, values in string_features.items()]
|
||||||
]))
|
)
|
||||||
|
)
|
||||||
return norm_feats_string or self.EMPTY_MORPH
|
return norm_feats_string or self.EMPTY_MORPH
|
||||||
|
|
||||||
def normalize_attrs(self, attrs):
|
def normalize_attrs(self, attrs):
|
||||||
|
@ -192,6 +193,7 @@ cdef int get_n_by_field(attr_t* results, const MorphAnalysisC* morph, attr_t fie
|
||||||
n_results += 1
|
n_results += 1
|
||||||
return n_results
|
return n_results
|
||||||
|
|
||||||
|
|
||||||
def unpickle_morphology(strings, tags):
|
def unpickle_morphology(strings, tags):
|
||||||
cdef Morphology morphology = Morphology(strings)
|
cdef Morphology morphology = Morphology(strings)
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
cimport cython
|
cimport cython
|
||||||
from libc.stdint cimport uint32_t
|
from libc.stdint cimport uint32_t
|
||||||
from libc.string cimport memcpy
|
from libc.string cimport memcpy
|
||||||
from libcpp.set cimport set
|
|
||||||
from murmurhash.mrmr cimport hash32, hash64
|
from murmurhash.mrmr cimport hash32, hash64
|
||||||
|
|
||||||
import srsly
|
import srsly
|
||||||
|
@ -20,9 +19,10 @@ cdef inline bint _try_coerce_to_hash(object key, hash_t* out_hash):
|
||||||
try:
|
try:
|
||||||
out_hash[0] = key
|
out_hash[0] = key
|
||||||
return True
|
return True
|
||||||
except:
|
except: # no-cython-lint
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_string_id(key):
|
def get_string_id(key):
|
||||||
"""Get a string ID, handling the reserved symbols correctly. If the key is
|
"""Get a string ID, handling the reserved symbols correctly. If the key is
|
||||||
already an ID, return it.
|
already an ID, return it.
|
||||||
|
@ -87,7 +87,6 @@ cdef Utf8Str* _allocate(Pool mem, const unsigned char* chars, uint32_t length) e
|
||||||
cdef int n_length_bytes
|
cdef int n_length_bytes
|
||||||
cdef int i
|
cdef int i
|
||||||
cdef Utf8Str* string = <Utf8Str*>mem.alloc(1, sizeof(Utf8Str))
|
cdef Utf8Str* string = <Utf8Str*>mem.alloc(1, sizeof(Utf8Str))
|
||||||
cdef uint32_t ulength = length
|
|
||||||
if length < sizeof(string.s):
|
if length < sizeof(string.s):
|
||||||
string.s[0] = <unsigned char>length
|
string.s[0] = <unsigned char>length
|
||||||
memcpy(&string.s[1], chars, length)
|
memcpy(&string.s[1], chars, length)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user