IBM / zshot

Zero and Few shot named entity & relationships recognition
https://ibm.github.io/zshot
MIT License
350 stars 20 forks source link

:sparkles: Add regen wikification #44

Closed GabrielePicco closed 1 year ago

GabrielePicco commented 1 year ago

Add easy Wikification for the Regen model

Status Type ⚠️ Core Change Issue
Hold Feature No #11

Description

Examples

import spacy

from zshot import PipelineConfig
from zshot.linker.linker_regen.linker_regen import LinkerRegen
from zshot.linker.linker_regen.utils import load_wikipedia_trie, spans_to_wikipedia
from zshot.mentions_extractor import MentionsExtractorSpacy
from zshot.tests.config import EX_DOCS

nlp = spacy.load("en_core_web_sm")
trie = load_wikipedia_trie()
config = PipelineConfig(
    mentions_extractor=MentionsExtractorSpacy(),
    linker=LinkerRegen(trie=trie),
)
nlp.add_pipe("zshot", config=config, last=True)
assert "zshot" in nlp.pipe_names

doc = nlp(EX_DOCS[1])
print(doc.ents)
print(spans_to_wikipedia(doc._.spans))

Issues

Closes #11

codecov[bot] commented 1 year ago

Codecov Report

Base: 92.93% // Head: 93.03% // Increases project coverage by +0.10% :tada:

Coverage data is based on head (07f7920) compared to base (b2c2a27). Patch coverage: 98.48% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #44 +/- ## ========================================== + Coverage 92.93% 93.03% +0.10% ========================================== Files 67 67 Lines 2773 2830 +57 ========================================== + Hits 2577 2633 +56 - Misses 196 197 +1 ``` | [Impacted Files](https://codecov.io/gh/IBM/zshot/pull/44?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM) | Coverage Δ | | |---|---|---| | [zshot/linker/linker\_regen/utils.py](https://codecov.io/gh/IBM/zshot/pull/44/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM#diff-enNob3QvbGlua2VyL2xpbmtlcl9yZWdlbi91dGlscy5weQ==) | `78.04% <96.55%> (+44.71%)` | :arrow_up: | | [zshot/linker/linker\_regen/linker\_regen.py](https://codecov.io/gh/IBM/zshot/pull/44/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM#diff-enNob3QvbGlua2VyL2xpbmtlcl9yZWdlbi9saW5rZXJfcmVnZW4ucHk=) | `98.30% <100.00%> (+0.05%)` | :arrow_up: | | [zshot/linker/linker\_regen/trie.py](https://codecov.io/gh/IBM/zshot/pull/44/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM#diff-enNob3QvbGlua2VyL2xpbmtlcl9yZWdlbi90cmllLnB5) | `100.00% <100.00%> (ø)` | | | [zshot/tests/linker/test\_regen\_linker.py](https://codecov.io/gh/IBM/zshot/pull/44/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM#diff-enNob3QvdGVzdHMvbGlua2VyL3Rlc3RfcmVnZW5fbGlua2VyLnB5) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=IBM)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.