Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions REL/generate_train_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,17 @@ def process_wned(self, dataset):

contents = {}
exist_doc_names = []
cnt_replaced = 0
for doc in root:
doc_name = doc.attrib["docName"].replace("&", "&")

# Replacement in string to makeup for mismatch in doc_names present in annotations_xml and generic folder
doc_name = doc_name.replace("'","_").replace("É","Р").replace("í","б").replace(
"_&_","___").replace("ü","Б").replace("â","Г").replace("ö","Ф").replace(
"é","В").replace("ó","в")
if doc_name.endswith("."):
doc_name = doc_name[:-1]+"_"

if doc_name in exist_doc_names:
print(
"Duplicate document found, will be removed later in the process: {}".format(
Expand All @@ -87,13 +96,17 @@ def process_wned(self, dataset):
doc_path = os.path.join(
self.wned_path, "{}/RawText/{}".format(dataset, doc_name)
)
with open(doc_path, "r", encoding="utf-8") as cf:
doc_text = " ".join(cf.readlines())
cf.close()

try:
with open(doc_path, "r", encoding="utf-8") as cf:
doc_text = " ".join(cf.readlines())
except:
print("Couldn't find: ", doc_path)
continue

doc_text = doc_text.replace("&", "&")
split_text = re.split(r"{}".format(split), doc_text)

cnt_replaced = 0
sentences = {}
mentions_gt = {}
total_gt = 0
Expand Down
6 changes: 3 additions & 3 deletions REL/wikipedia_yago_freq.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ def __wiki_counts(self):

print("Calculating Wikipedia mention/entity occurrences")

last_processed_id = -1
exist_id_found = False

wiki_anchor_files = os.listdir(
os.path.join(self.base_url, self.wiki_version, "basic_data/anchor_files/")
)
Expand All @@ -249,6 +246,9 @@ def __wiki_counts(self):
"basic_data/anchor_files/",
wiki_anchor,
)

last_processed_id = -1
exist_id_found = False

with open(wiki_file, "r", encoding="utf-8") as f:
for line in f:
Expand Down