Entity Mention Linker #2068
This run and associated checks have been archived and are scheduled for deletion.
Learn more about checks retention
Annotations
8 errors
test:
flair/__init__.py#L1
mypy-status
mypy exited with status 1.
|
test:
flair/datasets/entity_linking.py#L341
ruff
pytest_ruff.RuffError: flair/datasets/entity_linking.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / import csv
2 | | import logging
3 | | import os
4 | | from pathlib import Path
5 | | from typing import Any, Dict, Iterable, Iterator, List, Optional, Union
6 | |
7 | | import requests
8 | |
9 | | import flair
10 | | from flair.data import Corpus, EntityCandidate, MultiCorpus, Sentence
11 | | from flair.datasets.sequence_labeling import (ColumnCorpus,
12 | | MultiFileColumnCorpus)
13 | | from flair.file_utils import cached_path, unpack_file
14 | | from flair.splitter import SegtokSentenceSplitter, SentenceSplitter
15 | |
16 | | log = logging.getLogger("flair")
| |_^ I001
|
= help: Organize imports
|
test:
flair/datasets/entity_linking.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/datasets/entity_linking.py 2024-01-12 11:13:01.193661+00:00
+++ /home/runner/work/flair/flair/flair/datasets/entity_linking.py 2024-01-12 11:16:34.739765+00:00
@@ -6,12 +6,11 @@
import requests
import flair
from flair.data import Corpus, EntityCandidate, MultiCorpus, Sentence
-from flair.datasets.sequence_labeling import (ColumnCorpus,
- MultiFileColumnCorpus)
+from flair.datasets.sequence_labeling import ColumnCorpus, MultiFileColumnCorpus
from flair.file_utils import cached_path, unpack_file
from flair.splitter import SegtokSentenceSplitter, SentenceSplitter
log = logging.getLogger("flair")
|
test:
flair/models/entity_mention_linking.py#L341
ruff
pytest_ruff.RuffError: flair/models/entity_mention_linking.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / import copy
2 | | import inspect
3 | | import logging
4 | | import os
5 | | import re
6 | | import stat
7 | | import string
8 | | import subprocess
9 | | import tempfile
10 | | from abc import ABC, abstractmethod
11 | | from collections import defaultdict
12 | | from enum import Enum, auto
13 | | from pathlib import Path
14 | | from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast, Sequence, Set
15 | | from collections.abc import Iterable
16 | |
17 | | import numpy as np
18 | | import torch
19 | | from scipy import sparse
20 | | from torch.utils.data import Dataset
21 | | from tqdm import tqdm
22 | |
23 | | import flair
24 | | from flair.class_utils import get_state_subclass_by_name
25 | | from flair.data import DT, Dictionary, Sentence
26 | | from flair.datasets import (
27 | | CTD_CHEMICALS_DICTIONARY,
28 | | CTD_DISEASES_DICTIONARY,
29 | | NCBI_GENE_HUMAN_DICTIONARY,
30 | | NCBI_TAXONOMY_DICTIONARY,
31 | | EntityLinkingDictionary,
32 | | HunerEntityLinkingDictionary,
33 | | )
34 | | from flair.datasets.entity_linking import InMemoryEntityLinkingDictionary
35 | | from flair.embeddings import DocumentEmbeddings, DocumentTFIDFEmbeddings, TransformerDocumentEmbeddings
36 | | from flair.embeddings.base import load_embeddings
37 | | from flair.file_utils import cached_path, hf_download
38 | | from flair.training_utils import Result
39 | |
40 | | logger = logging.getLogger("flair")
| |_^ I001
41 |
42 | PRETRAINED_DENSE_MODELS = [
|
= help: Organize imports
flair/models/entity_mention_linking.py:769:9: D212 [*] Multi-line docstring summary should start at the first line
|
767 | dictionary: EntityLinkingDictionary,
768 | ):
769 | """
| _________^
770 | | Initializes an entity mention linker
771 | |
772 | | Args:
773 | | candidate_generator: Strategy to find matching entities for a given mention
774 | | preprocessor: Pre-processing strategy to transform / clean entity mentions
775 | | entity_label_types: A label type or sequence of label types of the required relation entities. You can also specify a label filter in a dictionary with the label type as key and the valid entity labels as values in a set. E.g. to use only 'disease' and 'chemical' labels from a NER-tagger: `{'ner': {'disease', 'chemical'}}`. To use all labels from 'ner', pass 'ner'
776 | | label_type: The label under which the predictions of the linker should be stored
777 | | dictionary: The dictionary listing all entities
778 | | """
| |___________^ D212
779 | self.preprocessor = preprocessor
780 | self.candidate_generator = candidate_generator
|
= help: Remove whitespace after opening quotes
flair/models/entity_mention_linking.py:769:9: D415 First line should end with a period, question mark, or exclamation point
|
767 | dictionary: EntityLinkingDictionary,
768 | ):
769 | """
| _________^
770 | | Initializes an entity mention linker
771 | |
772 | | Args:
773 | | candidate_generator: Strategy to find matching entities for a given mention
774 | | preprocessor: Pre-processing strategy to transform / clean entity mentions
775 | | entity_label_types: A label type or sequence of label types of the required relation entities. You can also specify a label filter in a dictionary with the label type as key and the valid entity labels as values in a set. E.g. to use only 'disease' and 'chemical' labels from a NER-tagger: `{'ner': {'disease', 'chemical'}}`. To use all labels from 'ner', pass 'ner'
776 | | label_type: The label under which the predictions of the linker should be stored
777 | | dictionary: The dictionary listing all entities
778 | | """
|
test:
flair/models/entity_mention_linking.py#L1
flair/models/entity_mention_linking.py
816: error: Dict entry 0 has incompatible type "str": "List[Never]"; expected "str": "Optional[Set[str]]" [dict-item]
818: error: Value expression in dictionary comprehension has incompatible type "List[Never]"; expected type "Optional[Set[str]]" [misc]
833: error: Argument 1 to "len" has incompatible type "Optional[Set[str]]"; expected "Sized" [arg-type]
834: error: Unsupported right operand type for in ("Optional[Set[str]]") [operator]
|
test:
flair/models/entity_mention_linking.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-12 11:13:01.197661+00:00
+++ /home/runner/work/flair/flair/flair/models/entity_mention_linking.py 2024-01-12 11:16:40.604077+00:00
@@ -765,18 +765,18 @@
entity_label_types: Union[str, Sequence[str], Dict[str, Optional[Set[str]]]],
label_type: str,
dictionary: EntityLinkingDictionary,
):
"""
- Initializes an entity mention linker
-
- Args:
- candidate_generator: Strategy to find matching entities for a given mention
- preprocessor: Pre-processing strategy to transform / clean entity mentions
- entity_label_types: A label type or sequence of label types of the required relation entities. You can also specify a label filter in a dictionary with the label type as key and the valid entity labels as values in a set. E.g. to use only 'disease' and 'chemical' labels from a NER-tagger: `{'ner': {'disease', 'chemical'}}`. To use all labels from 'ner', pass 'ner'
- label_type: The label under which the predictions of the linker should be stored
- dictionary: The dictionary listing all entities
+ Initializes an entity mention linker
+
+ Args:
+ candidate_generator: Strategy to find matching entities for a given mention
+ preprocessor: Pre-processing strategy to transform / clean entity mentions
+ entity_label_types: A label type or sequence of label types of the required relation entities. You can also specify a label filter in a dictionary with the label type as key and the valid entity labels as values in a set. E.g. to use only 'disease' and 'chemical' labels from a NER-tagger: `{'ner': {'disease', 'chemical'}}`. To use all labels from 'ner', pass 'ner'
+ label_type: The label under which the predictions of the linker should be stored
+ dictionary: The dictionary listing all entities
"""
self.preprocessor = preprocessor
self.candidate_generator = candidate_generator
self.entity_label_types = entity_label_types
self._label_type = label_type
@@ -794,11 +794,11 @@
def predict(
self,
sentences: Union[List[Sentence], Sentence],
top_k: int = 1,
pred_label_type: Optional[str] = None,
- entity_label_types: Optional[Union[str, Sequence[str], Dict[str, Optional[Set[str]]]]] = None
+ entity_label_types: Optional[Union[str, Sequence[str], Dict[str, Optional[Set[str]]]]] = None,
) -> None:
"""Predicts the best matching top-k entity / concept identifiers of all named entities annotated with tag input_entity_annotation_layer.
Args:
sentences: One or more sentences to run the prediction on
|
test:
tests/test_biomedical_entity_linking.py#L1
Black format check
--- /home/runner/work/flair/flair/tests/test_biomedical_entity_linking.py 2024-01-12 11:13:01.217661+00:00
+++ /home/runner/work/flair/flair/tests/test_biomedical_entity_linking.py 2024-01-12 11:16:53.816970+00:00
@@ -87,11 +87,11 @@
disease_dictionary = disease_linker.dictionary
disease_linker.predict(sentence, pred_label_type="disease-nen", entity_label_types="diseases")
gene_linker = EntityMentionLinker.load("masaenger/bio-nen-gene")
gene_dictionary = gene_linker.dictionary
- gene_linker.predict(sentence, pred_label_type="gene-nen", entity_label_types="genes")
+ gene_linker.predict(sentence, pred_label_type="gene-nen", entity_label_types="genes")
print("Diseases")
for label in sentence.get_labels("disease-nen"):
candidate = disease_dictionary[label.value]
print(f"Candidate: {candidate.concept_name}")
|
test
Process completed with exit code 1.
|