From 54d039435ce20d66b8e08a708d42e214a3e55c63 Mon Sep 17 00:00:00 2001 From: Alexander Polynomdivision Date: Sun, 21 Oct 2018 22:44:20 +0200 Subject: [PATCH] scripts: Include mnemonics --- scripts/csv_vocab_to_mongo.py | 37 +++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/csv_vocab_to_mongo.py b/scripts/csv_vocab_to_mongo.py index e2747cd..e956ed2 100644 --- a/scripts/csv_vocab_to_mongo.py +++ b/scripts/csv_vocab_to_mongo.py @@ -43,11 +43,8 @@ def csv_to_vocab(filename, type, from_id): if (skip < 4): continue - # The nouns are special - row = preprocess_row(raw) if type == TYPE_NOUNS else raw - # Remove any whitespaces in front of or after the string - row = [col.strip() for col in row] + row = [col.strip() for col in raw] grundform = row[0] hint = "" @@ -68,22 +65,28 @@ def csv_to_vocab(filename, type, from_id): bedeutungen.append(row[4]) if (row[5] != ""): bedeutungen.append(row[5]) + if (row[6] != ""): + bedeutungen.append(row[6]) + if (row[7] != ""): + mnemonic = row[7] + latin["genitiv"] = genitiv latin["genus"] = genus elif (type == TYPE_VERBS): # Verb praesens = row[1] - perfekt = row[2] - bedeutungen = [row[3]] + bedeutungen = [row[2]] + if (row[3] != ""): + bedeutungen.append(row[3]) if (row[4] != ""): bedeutungen.append(row[4]) - if (row[5] != ""): - bedeutungen.append(row[5]) + if (row[6] != ""): + mnemonic = row[6] + latin["praesens"] = praesens - latin["perfekt"] = perfekt - latin["ppp"] = "" + #latin["perfekt"] = perfekt elif (type == TYPE_ADJECTIVES): # Adjektiv endung_f = row[1] @@ -94,6 +97,9 @@ def csv_to_vocab(filename, type, from_id): if (row[5] != ""): bedeutungen.append(row[5]) + if (row[6] != ""): + mnemonic = row[6] + latin["endung_f"] = endung_f latin["endung_n"] = endung_n elif (type == TYPE_ADVERBS): @@ -103,8 +109,15 @@ def csv_to_vocab(filename, type, from_id): bedeutungen.append(row[2]) if (row[3] != ""): bedeutungen.append(row[3]) - - # TODO: Hints and mnemonics + if (row[4] != ""): + bedeutungen.append(row[4]) + + if (row[5] != ""): + mnemonic = row[5] + + if mnemonic != "": + print("Found mnemonic for:", latin["grundform"]) + vocab.append({ "id": id, "german": bedeutungen,