Entity Mention Linker #2085
Annotations
11 errors and 1 warning
|
Run tests:
flair/data.py#L345
ruff
pytest_ruff.RuffError: flair/data.py:366:16: SIM401 Use `self.annotation_layers.get(typename, [])` instead of an `if` block
|
364 | return self.labels
365 |
366 | return self.annotation_layers[typename] if typename in self.annotation_layers else []
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401
367 |
368 | @Property
|
= help: Replace with `self.annotation_layers.get(typename, [])`
|
Run tests:
flair/data.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/data.py 2024-02-02 13:06:35.274959+00:00
+++ /home/runner/work/flair/flair/flair/data.py 2024-02-02 13:08:50.537335+00:00
@@ -1042,16 +1042,14 @@
def get_span(self, start: int, stop: int):
span_slice = slice(start, stop)
return self[span_slice]
@typing.overload
- def __getitem__(self, idx: int) -> Token:
- ...
+ def __getitem__(self, idx: int) -> Token: ...
@typing.overload
- def __getitem__(self, s: slice) -> Span:
- ...
+ def __getitem__(self, s: slice) -> Span: ...
def __getitem__(self, subscript):
if isinstance(subscript, slice):
return Span(self.tokens[subscript])
else:
|
Run tests:
flair/datasets/base.py#L345
ruff
pytest_ruff.RuffError: flair/datasets/base.py:185:22: SIM401 Use `document.get(_, "")` instead of an `if` block
|
183 | sentence = self._parse_document_to_sentence(
184 | document[self.text],
185 | [document[_] if _ in document else "" for _ in self.categories],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401
186 | tokenizer,
187 | )
|
= help: Replace with `document.get(_, "")`
flair/datasets/base.py:228:18: SIM401 Use `document.get(_, "")` instead of an `if` block
|
226 | sentence = self._parse_document_to_sentence(
227 | document[self.text],
228 | [document[_] if _ in document else "" for _ in self.categories],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401
229 | self.tokenizer,
230 | )
|
= help: Replace with `document.get(_, "")`
|
Run tests:
flair/datasets/biomedical.py#L345
ruff
pytest_ruff.RuffError: flair/datasets/biomedical.py:2197:30: SIM401 Use `patch_lines.get(line_no, line)` instead of an `if` block
|
2196 | for line in input:
2197 | output.write(patch_lines[line_no] if line_no in patch_lines else line)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401
2198 | line_no += 1
|
= help: Replace with `patch_lines.get(line_no, line)`
|
Run tests:
flair/datasets/sequence_labeling.py#L345
ruff
pytest_ruff.RuffError: flair/datasets/sequence_labeling.py:2767:21: SIM113 Use `enumerate()` for index variable `k` in `for` loop
|
2765 | k = 0
2766 | for line in file.readlines():
2767 | k += 1
| ^^^^^^ SIM113
2768 | if k <= train_len:
2769 | train.write(line)
|
|
Run tests:
flair/datasets/text_image.py#L345
ruff
pytest_ruff.RuffError: flair/datasets/text_image.py:66:12: RUF019 [*] Unnecessary key check before dictionary access
|
65 | preprocessor = identity
66 | if "lowercase" in kwargs and kwargs["lowercase"]:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF019
67 | preprocessor = str.lower
|
= help: Replace with `dict.get`
|
Run tests:
flair/file_utils.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/file_utils.py 2024-02-02 13:06:35.278959+00:00
+++ /home/runner/work/flair/flair/flair/file_utils.py 2024-02-02 13:08:58.157822+00:00
@@ -1,6 +1,7 @@
"""Utilities for working with the local dataset cache. Copied from AllenNLP."""
+
import base64
import functools
import io
import logging
import mmap
|
Run tests:
flair/models/entity_linker_model.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/models/entity_linker_model.py 2024-02-02 13:06:35.278959+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_linker_model.py 2024-02-02 13:08:59.161383+00:00
@@ -106,13 +106,13 @@
**classifierargs: The arguments propagated to :meth:`flair.nn.DefaultClassifier.__init__`
"""
super().__init__(
embeddings=embeddings,
label_dictionary=label_dictionary,
- final_embedding_size=embeddings.embedding_length * 2
- if pooling_operation == "first_last"
- else embeddings.embedding_length,
+ final_embedding_size=(
+ embeddings.embedding_length * 2 if pooling_operation == "first_last" else embeddings.embedding_length
+ ),
**classifierargs,
)
self.pooling_operation = pooling_operation
self._label_type = label_type
|
Run tests:
flair/models/entity_mention_linking.py#L345
ruff
pytest_ruff.RuffError: flair/models/entity_mention_linking.py:605:13: SIM401 Use `HYBRID_MODELS_SPARSE_WEIGHT.get(model_name_or_path, sparse_weight)` instead of an `if` block
|
604 | sparse_weight = (
605 | sparse_weight
| _____________^
606 | | if model_name_or_path not in HYBRID_MODELS_SPARSE_WEIGHT
607 | | else HYBRID_MODELS_SPARSE_WEIGHT[model_name_or_path]
| |________________________________________________________________^ SIM401
608 | )
|
= help: Replace with `HYBRID_MODELS_SPARSE_WEIGHT.get(model_name_or_path, sparse_weight)`
flair/models/entity_mention_linking.py:1161:24: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1159 | spans = sentence.get_spans(gold_label_type)
1160 | for span in spans:
1161 | exps = set(exp.value for exp in span.get_labels(gold_label_type) if exp.value not in exclude_labels)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401
1162 |
1163 | predictions = set(pred.value for pred in span.get_labels("predicted"))
|
= help: Rewrite as a `set` comprehension
flair/models/entity_mention_linking.py:1163:31: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1161 | exps = set(exp.value for exp in span.get_labels(gold_label_type) if exp.value not in exclude_labels)
1162 |
1163 | predictions = set(pred.value for pred in span.get_labels("predicted"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401
1164 | total += 1
1165 | if exps & predictions:
|
= help: Rewrite as a `set` comprehension
|
Run tests
The operation was canceled.
|
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/setup-python@v4, actions/cache@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
|
The logs for this run have expired and are no longer available.
Loading