This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"mentions": [ | |
{ | |
"name": "Robinson College", | |
"type": "string", | |
"start": "2898", | |
"end": "2914", | |
"context": "char=0,5253", | |
"uri": "https://en.wikipedia.org/wiki/The_New_York_Times" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[163]: | |
import codecs | |
from collections import defaultdict | |
tweets = defaultdict() | |
with io.open('/Users/xi/Downloads/NEEL2016-training.tsv', encoding='utf-8') as tw: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NIL138 | |
['Alan', 'Jasons', 'goonergang'] | |
NIL143 | |
['jfalconer', 'HopticalA', 'Alex'] | |
NIL840 | |
['BestProNews'] | |
NIL18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@torch.no_grad() | |
def buildSubgraph(self, head_index: Tensor, rel_type: Tensor, tail_index: Tensor) -> Tensor: | |
k = self.neighbors_topk # Number of top tails to find | |
M = self.neighbors_size | |
# Initialize a dictionary to store unique objects the triples | |
unique_nodes = {(h.item(), r.item(), t.item()): set() | |
for h, r, t in zip(head_index, rel_type, tail_index)} | |
# local utility that uses the KGE to find the nearest nodes. |