mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Removed mapStr
This commit is contained in:
parent
1bb364a3b5
commit
9c809efc25
|
@ -35,7 +35,6 @@ def test_spans_string_fn(doc):
|
|||
span = doc[0:4]
|
||||
assert len(span) == 4
|
||||
assert span.text == 'This is a sentence'
|
||||
assert span.mapStr((lambda x, i, arg="_": x + i + arg), "y", "z") == 'This yzis yza yzsentence yz'
|
||||
assert span.upper_ == 'THIS IS A SENTENCE'
|
||||
assert span.lower_ == 'this is a sentence'
|
||||
|
||||
|
|
|
@ -118,17 +118,6 @@ cdef class Span:
|
|||
return 0.0
|
||||
return numpy.dot(self.vector, other.vector) / (self.vector_norm * other.vector_norm)
|
||||
|
||||
def mapStr(self, fn, *argv, **kargs):
|
||||
'''Perform a function on the string representation of each token in this span.
|
||||
|
||||
Arguments:
|
||||
fn (function): First argument will always be string of a token. Additional arguments
|
||||
will be defined according to *argv and **kargs passed to this mapStr() method.
|
||||
*argv (unpacked tuple): Arguments to be passed to fn
|
||||
**kargs (unpacked dict): Arguments to be passed to fn
|
||||
'''
|
||||
return ''.join([fn(t.string, *argv, **kargs) for t in self]).strip()
|
||||
|
||||
cpdef int _recalculate_indices(self) except -1:
|
||||
if self.end > self.doc.length \
|
||||
or self.doc.c[self.start].idx != self.start_char \
|
||||
|
|
Loading…
Reference in New Issue
Block a user