mirror of https://github.com/explosion/spaCy.git
Improve label properties on pipes
This commit is contained in:
parent
9be4d1c105
commit
228bbf506d
|
@ -1062,8 +1062,15 @@ cdef class DependencyParser(Parser):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def labels(self):
|
def labels(self):
|
||||||
|
labels = set()
|
||||||
# Get the labels from the model by looking at the available moves
|
# Get the labels from the model by looking at the available moves
|
||||||
return tuple(set(move.split("-")[1] for move in self.move_names if "-" in move))
|
for move in self.move_names:
|
||||||
|
if "-" in move:
|
||||||
|
label = move.split("-")[1]
|
||||||
|
if "||" in label:
|
||||||
|
label = label.split("||")[1]
|
||||||
|
labels.add(label)
|
||||||
|
return tuple(sorted(labels))
|
||||||
|
|
||||||
|
|
||||||
cdef class EntityRecognizer(Parser):
|
cdef class EntityRecognizer(Parser):
|
||||||
|
@ -1098,8 +1105,9 @@ cdef class EntityRecognizer(Parser):
|
||||||
def labels(self):
|
def labels(self):
|
||||||
# Get the labels from the model by looking at the available moves, e.g.
|
# Get the labels from the model by looking at the available moves, e.g.
|
||||||
# B-PERSON, I-PERSON, L-PERSON, U-PERSON
|
# B-PERSON, I-PERSON, L-PERSON, U-PERSON
|
||||||
return tuple(set(move.split("-")[1] for move in self.move_names
|
labels = set(move.split("-")[1] for move in self.move_names
|
||||||
if move[0] in ("B", "I", "L", "U")))
|
if move[0] in ("B", "I", "L", "U"))
|
||||||
|
return tuple(sorted(labels))
|
||||||
|
|
||||||
|
|
||||||
class EntityLinker(Pipe):
|
class EntityLinker(Pipe):
|
||||||
|
|
Loading…
Reference in New Issue