Skip to content
Snippets Groups Projects
Commit 235a47fb authored by nwarslan's avatar nwarslan
Browse files

code comentation

parent 2d7f26d5
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
"""
Created on Fri Aug 9 16:54:02 2019
@author: nadia
@author: Nadia Arslan
This module joins the german keywords of spektrum articles with their
corresponding englisch google translation to a dictionary
......@@ -15,6 +15,22 @@ INPUT_PATH = '../data/spektrum_keywords'
OUTPUT = '../data/spektrum_keywords/spektrum_keyword_dict.json'
def open_translation(filename):
"""
opens a keyword file containing lines of german keywords and lines of english translations seperated by '\n\n\n'
file needs to have as many german keywords as english translations
Parameters
----------
filename : str
name of file.
Returns
-------
d : dict
keyword_dict
Example: {german keyword : english translation, ...}.
"""
with open(filename,'r') as f:
data=f.read().strip()
d = data.split('\n\n\n')
......@@ -32,6 +48,20 @@ def open_translation(filename):
return d
def mk_dict(dir_path):
"""
iterates over files in path and makes a keyword dictionary
Parameters
----------
dir_path : str
path to keyword files.
Returns
-------
dictionary : dict
a keyword dictionary of all keywords.
"""
files = os.listdir(dir_path)
dictionary = {}
for file in files:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment