Entity Mention Linker #2078
Annotations
3 errors
test:
flair/models/entity_mention_linking.py#L341
ruff
pytest_ruff.RuffError: flair/models/entity_mention_linking.py:1:8: F401 [*] `copy` imported but unused
|
1 | import copy
| ^^^^ F401
2 | import inspect
3 | import logging
|
= help: Remove unused import: `copy`
flair/models/entity_mention_linking.py:761:9: D417 Missing argument description in the docstring for `__init__`: `batch_size`
|
759 | """Entity linking model for the biomedical domain."""
760 |
761 | def __init__(
| ^^^^^^^^ D417
762 | self,
763 | candidate_generator: CandidateSearchIndex,
|
flair/models/entity_mention_linking.py:795:9: D417 Missing argument description in the docstring for `predict`: `batch_size`
|
793 | return self._dictionary
794 |
795 | def predict(
| ^^^^^^^ D417
796 | self,
797 | sentences: Union[List[Sentence], Sentence],
|
flair/models/entity_mention_linking.py:1099:24: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1097 | spans = sentence.get_spans(gold_label_type)
1098 | for span in spans:
1099 | exps = set(exp.value for exp in span.get_labels(gold_label_type) if exp.value not in exclude_labels)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401
1100 |
1101 | predictions = set(pred.value for pred in span.get_labels("predicted"))
|
= help: Rewrite as a `set` comprehension
flair/models/entity_mention_linking.py:1101:31: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1099 | exps = set(exp.value for exp in span.get_labels(gold_label_type) if exp.value not in exclude_labels)
1100 |
1101 | predictions = set(pred.value for pred in span.get_labels("predicted"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401
1102 | total += 1
1103 | if exps & predictions:
|
= help: Rewrite as a `set` comprehension
|
test:
flair/models/entity_mention_linking.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-21 21:38:23.594197+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-21 21:40:46.453971+00:00
@@ -1087,11 +1087,17 @@
raise NotImplementedError("evaluating an EntityMentionLinker with a gold_label_dictionary is not supported")
if isinstance(data_points, Dataset):
data_points = list(_iter_dataset(data_points))
- self.predict(data_points, top_k=k, pred_label_type="predicted", entity_label_types=gold_label_type, batch_size=mini_batch_size)
+ self.predict(
+ data_points,
+ top_k=k,
+ pred_label_type="predicted",
+ entity_label_types=gold_label_type,
+ batch_size=mini_batch_size,
+ )
hits = 0
total = 0
for sentence in data_points:
spans = sentence.get_spans(gold_label_type)
@@ -1106,10 +1112,6 @@
accuracy = hits / total
detailed_results = f"Accuracy@{k}: {accuracy:0.2%}"
scores = {"accuracy": accuracy, f"accuracy@{k}": accuracy, "loss": 0.0}
- return Result(
- main_score=accuracy,
- detailed_results=detailed_results,
- scores=scores
- )
+ return Result(main_score=accuracy, detailed_results=detailed_results, scores=scores)
|
test
Process completed with exit code 1.
|