QubitPi commited on
Commit
633c798
1 Parent(s): 38274dd

Specify languages in graph extract (#2)

Browse files
Files changed (1) hide show
  1. wiktionary/wiktextract/extract.py +4 -1
wiktionary/wiktextract/extract.py CHANGED
@@ -85,6 +85,9 @@ def extract_data(wiktextract_data_path: str):
85
  sanskrit.write("\n")
86
 
87
 
 
 
 
88
  def extract_graph(wiktextract_data_path: str):
89
  import json
90
  from wiktionary.wiktextract.parse import get_definitions
@@ -92,7 +95,7 @@ def extract_graph(wiktextract_data_path: str):
92
  with (open(wiktextract_data_path) as data, open("word-definition-graph-data.jsonl", "w") as graph):
93
  for line in data:
94
  vocabulary = json.loads(line)
95
- if "lang" in vocabulary:
96
  term = vocabulary["word"]
97
  if vocabulary["lang"] == "German":
98
  term = get_gender_modifier(vocabulary) + term
 
85
  sanskrit.write("\n")
86
 
87
 
88
+ LANGUAGES = ["German", "Latin", "Ancient Greek", "Korean", "Old Persian", "Akkadian", "Elamite", "Sanskrit"]
89
+
90
+
91
  def extract_graph(wiktextract_data_path: str):
92
  import json
93
  from wiktionary.wiktextract.parse import get_definitions
 
95
  with (open(wiktextract_data_path) as data, open("word-definition-graph-data.jsonl", "w") as graph):
96
  for line in data:
97
  vocabulary = json.loads(line)
98
+ if "lang" in vocabulary and vocabulary["lang"] in LANGUAGES:
99
  term = vocabulary["word"]
100
  if vocabulary["lang"] == "German":
101
  term = get_gender_modifier(vocabulary) + term