mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
* Working DecisionMemory class
This commit is contained in:
parent
7920ea72b4
commit
a0408e1758
|
@ -1,5 +1,6 @@
|
|||
from libcpp.vector cimport vector
|
||||
from libcpp.pair cimport pair
|
||||
|
||||
from preshed.counter cimport count_t
|
||||
from preshed.maps cimport PreshMap
|
||||
from preshed.counter cimport PreshCounter
|
||||
|
@ -36,3 +37,8 @@ cdef class DecisionMemory:
|
|||
|
||||
cdef int inc(self, hash_t context_key, hash_t clas, count_t inc) except -1
|
||||
cdef int find_best_class(self, count_t* counts, hash_t context_key) except -1
|
||||
|
||||
cdef inline int get(self, hash_t context_key) nogil:
|
||||
return <int><size_t>self.memos.get(context_key) - 1
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ cdef class DecisionMemory:
|
|||
self._class_counts = PreshCounter()
|
||||
self.memos = PreshMap()
|
||||
|
||||
def load(self, loc, thresh=0):
|
||||
def load(self, loc, thresh=50):
|
||||
cdef:
|
||||
count_t freq
|
||||
hash_t key
|
||||
|
@ -54,9 +54,6 @@ cdef class DecisionMemory:
|
|||
if thresh == 0 or freq >= thresh:
|
||||
self.memos.set(key, <void*>(clas+1))
|
||||
|
||||
def get(self, hash_t context_key):
|
||||
return <int64_t>self.memos.get(context_key) - 1
|
||||
|
||||
def __getitem__(self, ids):
|
||||
cdef id_t[2] context
|
||||
context[0] = context[0]
|
||||
|
|
Loading…
Reference in New Issue
Block a user