Entity Mention Linker #2082
Annotations
10 errors and 1 warning
Run tests:
flair/data.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/data.py 2024-01-29 12:07:08.368519+00:00
+++ /home/runner/work/flair/flair/flair/data.py 2024-01-29 12:09:33.726731+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/file_utils.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/file_utils.py 2024-01-29 12:07:08.372519+00:00
+++ /home/runner/work/flair/flair/flair/file_utils.py 2024-01-29 12:09:40.971333+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-01-29 12:07:08.372519+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_linker_model.py 2024-01-29 12:09:41.956176+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#L1
Black format check
--- /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-29 12:07:08.372519+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-29 12:09:42.602282+00:00
@@ -441,13 +441,15 @@
}
@classmethod
def _from_state(cls, state_dict: Dict[str, Any]) -> "EntityPreprocessor":
return cls(
- 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.
@@ -901,13 +903,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)
|
Run tests:
flair/models/entity_mention_linking.py#L345
ruff
pytest_ruff.RuffError: flair/models/entity_mention_linking.py:840:17: PGH002 `warn` is deprecated in favor of `warning`
|
838 | if any(label in ["diseases", "genes", "species", "chemical"] for label in sentence.annotation_layers):
839 | if not self._warned_legacy_sequence_tagger:
840 | logger.warn(
| ^^^^^^^^^^^ PGH002
841 | "The tagger `Classifier.load('hunflair') is deprecated. Please update to: `Classifier.load('hunflair2')`."
842 | )
|
= help: Replace with `warning`
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:
flair/nn/distance/euclidean.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/nn/distance/euclidean.py 2024-01-29 12:07:08.376519+00:00
+++ /home/runner/work/flair/flair/flair/nn/distance/euclidean.py 2024-01-29 12:09:47.845291+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
|
Run tests:
flair/nn/model.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/nn/model.py 2024-01-29 12:07:08.376519+00:00
+++ /home/runner/work/flair/flair/flair/nn/model.py 2024-01-29 12:09:48.848367+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,
)
|
Run tests:
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.
|
Run tests:
tests/embeddings/test_transformer_word_embeddings.py#L182
TestTransformerWordEmbeddings.test_layoutlmv3_embeddings[False]
OSError: Unable to load weights from pytorch checkpoint file for './cache/transformers/hub/models--microsoft--layoutlmv3-base/snapshots/ba7716c277fb9b49bba6c3c4cad84123b689acf2/pytorch_model.bin' at './cache/transformers/hub/models--microsoft--layoutlmv3-base/snapshots/ba7716c277fb9b49bba6c3c4cad84123b689acf2/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
|
Run tests:
tests/embeddings/test_transformer_word_embeddings.py#L198
TestTransformerWordEmbeddings.test_layoutlmv3_embeddings_with_long_context[False]
OSError: Unable to load weights from pytorch checkpoint file for './cache/transformers/hub/models--microsoft--layoutlmv3-base/snapshots/ba7716c277fb9b49bba6c3c4cad84123b689acf2/pytorch_model.bin' at './cache/transformers/hub/models--microsoft--layoutlmv3-base/snapshots/ba7716c277fb9b49bba6c3c4cad84123b689acf2/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
|
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