Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
implement location heuristics, refs #43
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Jan 30, 2023
1 parent e806493 commit 7fe2a26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/screens/Linker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default function Linker() {
<Label>View articles that mention both:</Label>
<ArticleCorefList
clusters={[source.id, target.id]}
tags={[prediction.source.labels, prediction.source.labels]}
tags={[prediction.source.labels, prediction.target.labels]}
/>
</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion storyweb/logic/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,22 @@ def link_predict(conn: Conn, anchor_id: str, other_id: str) -> LinkPrediction:
type=link.type,
)

# Heuristic: if one of the two clusters is known to be an observer on most of
# their links, assume they are overall an observer (e.g. a media organisation,
# or a journalist).
anchor_observer = is_observer(conn, anchor.id)
other_observer = is_observer(conn, other.id)
print("OBSERVER", anchor_observer, other_observer)
if anchor_observer and not other_observer:
return LinkPrediction(source=anchor, target=other, type=LinkType.OBSERVER)
if other_observer and not anchor_observer:
return LinkPrediction(source=other, target=anchor, type=LinkType.OBSERVER)

# Heuristic: locations have very limited connection types they can enter into.
if anchor.type == "LOC" and other.type == "LOC":
return LinkPrediction(source=anchor, target=other, type="WITHIN")
if anchor.type == "LOC":
return LinkPrediction(source=other, target=anchor, type="LOCATED")
if other.type == "LOC":
return LinkPrediction(source=anchor, target=other, type="LOCATED")

return LinkPrediction(source=anchor, target=other, type=link_type)

0 comments on commit 7fe2a26

Please sign in to comment.