Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 62b2b11

Browse files
committed
workaround for Spotlight availability
1 parent fcec30d commit 62b2b11

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
TODO:
22

3+
* can we build a causal graph of the provenance?
4+
- https://www.pywhy.org/dowhy/v0.11.1/
5+
6+
* target publications:
7+
- https://drops.dagstuhl.de/entities/issue/TGDK-volume-1-issue-1
8+
39
* impl a _semantic random walk_ from a source KG
410

511
* link entities for lemmas, noun chunks using MediaWiki lookups?

textgraphs/kg.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ def dbpedia_wikidata_equiv (
848848
######################################################################
849849
## entity linking
850850

851-
def _link_spotlight_entities ( # pylint: disable=R0914
851+
def _link_spotlight_entities ( # pylint: disable=R0912,R0914
852852
self,
853853
pipe: Pipeline,
854854
*,
@@ -867,7 +867,10 @@ def _link_spotlight_entities ( # pylint: disable=R0914
867867
yields:
868868
candidates linked entities
869869
"""
870-
ents: typing.List[ spacy.tokens.span.Span ] = list(pipe.aux_doc.ents)
870+
ents: typing.List[ spacy.tokens.span.Span ] = []
871+
872+
if pipe.aux_doc is not None:
873+
list(pipe.aux_doc.ents)
871874

872875
if debug:
873876
ic(ents)

textgraphs/pipe.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,14 @@ def __init__ ( # pylint: disable=R0913
251251
# `ner_doc` provides the merged-entity spans from NER
252252
self.ner_doc: spacy.tokens.Doc = ner_pipe(self.text)
253253

254-
# `aux_doc` e.g., span re-indexing for Spotlight entity linking
255-
self.aux_doc: spacy.tokens.Doc = aux_pipe(self.text)
254+
# `aux_doc` e.g., re-indexing spans for Spotlight entity linking
255+
# NB: this is optional, in case the Spotlight service is down
256+
self.aux_doc: typing.Optional[ spacy.tokens.Doc ] = None
257+
258+
try:
259+
self.aux_doc = aux_pipe(self.text)
260+
except Exception as ex: # pylint: disable=W0718
261+
ic(ex)
256262

257263
self.kg: KnowledgeGraph = kg # pylint: disable=C0103
258264
self.infer_rels: typing.List[ InferRel ] = infer_rels

0 commit comments

Comments
 (0)