Entity Mention Linker #2081
Annotations
10 errors and 1 warning
test:
flair/data.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/data.py 2024-01-26 17:36:58.540049+00:00
+++ /home/runner/work/flair/flair/flair/data.py 2024-01-26 17:39:09.462028+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:
|
test:
flair/file_utils.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/file_utils.py 2024-01-26 17:36:58.548049+00:00
+++ /home/runner/work/flair/flair/flair/file_utils.py 2024-01-26 17:39:09.992706+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
|
test:
flair/models/entity_linker_model.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/models/entity_linker_model.py 2024-01-26 17:36:58.548049+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_linker_model.py 2024-01-26 17:39:19.389890+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
|
test:
flair/models/entity_mention_linking.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-26 17:36:58.548049+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-26 17:39:20.069283+00:00
@@ -445,13 +445,15 @@
@classmethod
def _from_state(cls, state_dict: Dict[str, Any]) -> "EntityPreprocessor":
return cls(
ab3p_path=Path(state_dict["ab3p_path"]),
word_data_dir=Path(state_dict["word_data_dir"]),
- preprocessor=None
- if state_dict["preprocessor"] is None
- else EntityPreprocessor._from_state(state_dict["preprocessor"]),
+ preprocessor=(
+ None
+ if state_dict["preprocessor"] is None
+ else EntityPreprocessor._from_state(state_dict["preprocessor"])
+ ),
)
class CandidateSearchIndex(ABC):
"""Base class for a candidate generator.
@@ -898,13 +900,15 @@
# Preprocess entity mentions
for entity in entities_mentions:
data_points.append(entity.data_point)
mentions.append(
- self.preprocessor.process_mention(entity.data_point.text, sentence)
- if self.preprocessor is not None
- else entity.data_point.text,
+ (
+ self.preprocessor.process_mention(entity.data_point.text, sentence)
+ if self.preprocessor is not None
+ else entity.data_point.text
+ ),
)
# Retrieve top-k concept / entity candidates
for i in range(0, len(mentions), batch_size):
candidates = self.candidate_generator.search(entity_mentions=mentions[i : i + batch_size], top_k=top_k)
|
test:
flair/models/entity_mention_linking.py#L341
ruff
pytest_ruff.RuffError: flair/models/entity_mention_linking.py:1163:24: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1161 | spans = sentence.get_spans(gold_label_type)
1162 | for span in spans:
1163 | exps = set(exp.value for exp in span.get_labels(gold_label_type) if exp.value not in exclude_labels)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401
1164 |
1165 | predictions = set(pred.value for pred in span.get_labels("predicted"))
|
= help: Rewrite as a `set` comprehension
flair/models/entity_mention_linking.py:1165:31: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1163 | exps = set(exp.value for exp in span.get_labels(gold_label_type) if exp.value not in exclude_labels)
1164 |
1165 | predictions = set(pred.value for pred in span.get_labels("predicted"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401
1166 | total += 1
1167 | if exps & predictions:
|
= help: Rewrite as a `set` comprehension
|
test:
flair/nn/model.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/nn/model.py 2024-01-26 17:36:58.548049+00:00
+++ /home/runner/work/flair/flair/flair/nn/model.py 2024-01-26 17:39:25.475635+00:00
@@ -699,13 +699,15 @@
device=flair.device,
)
else:
return torch.tensor(
[
- self.label_dictionary.get_idx_for_item(label[0])
- if len(label) > 0
- else self.label_dictionary.get_idx_for_item("O")
+ (
+ self.label_dictionary.get_idx_for_item(label[0])
+ if len(label) > 0
+ else self.label_dictionary.get_idx_for_item("O")
+ )
for label in labels
],
dtype=torch.long,
device=flair.device,
)
|
test:
flair/nn/distance/euclidean.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/nn/distance/euclidean.py 2024-01-26 17:36:58.548049+00:00
+++ /home/runner/work/flair/flair/flair/nn/distance/euclidean.py 2024-01-26 17:39:26.583775+00:00
@@ -14,11 +14,10 @@
It was published under MIT License:
https://github.com/asappresearch/dynamic-classification/blob/master/LICENSE.md
Source: https://github.com/asappresearch/dynamic-classification/blob/55beb5a48406c187674bea40487c011e8fa45aab/distance/euclidean.py
"""
-
import torch
from torch import Tensor, nn
|
test:
tests/test_biomedical_entity_linking.py#L17
test_bel_dictionary[False]
ValueError: When loading a custom dictionary, you need to specify a dataset_name!
|
test:
tests/test_tars.py#L51
test_train_tars[False]
OSError: Unable to load weights from pytorch checkpoint file for './cache/transformers/hub/models--sshleifer--tiny-distilroberta-base/snapshots/d305c58110158c865cb6746c62d4511d4148a934/pytorch_model.bin' at './cache/transformers/hub/models--sshleifer--tiny-distilroberta-base/snapshots/d305c58110158c865cb6746c62d4511d4148a934/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
|
test:
tests/embeddings/test_transformer_word_embeddings.py#L149
TestTransformerWordEmbeddings.test_layoutlm_embeddings[False]
OSError: Unable to load weights from pytorch checkpoint file for './cache/transformers/hub/models--microsoft--layoutlm-base-uncased/snapshots/8290fe08a848303616911d513e66ec192840ffbd/pytorch_model.bin' at './cache/transformers/hub/models--microsoft--layoutlm-base-uncased/snapshots/8290fe08a848303616911d513e66ec192840ffbd/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
|
test
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/.
|