Added container Category for conllu generation

This commit is contained in:
Jonas Weinz 2019-07-27 15:08:25 +02:00
parent 777cbde605
commit 0c1d0c4451
3 changed files with 19 additions and 2 deletions

View File

@ -36,10 +36,16 @@
"\n",
"# loading actions:\n",
"spec = importlib.util.spec_from_file_location(\n",
" \"ingredients\", \"../\" + settings.actions_file)\n",
" \"actions\", \"../\" + settings.actions_file)\n",
"actions = importlib.util.module_from_spec(spec)\n",
"spec.loader.exec_module(actions)\n",
"\n",
"# loading containers\n",
"spec = importlib.util.spec_from_file_location(\n",
" \"containers\", \"../\" + settings.container_file)\n",
"containers = importlib.util.module_from_spec(spec)\n",
"spec.loader.exec_module(containers)\n",
"\n",
"# skipping recipes:\n",
"n_skipped_recipes = int(sys.argv[1]) if len(sys.argv) > 1 else 0\n",
"print(\"start reading at recipe \" + str(n_skipped_recipes))\n",
@ -72,6 +78,7 @@
" cg.pos_tagging()\n",
" cg.add_misc_value_by_list(\"food_type\", \"ingredient\", [w.replace(\" \",\"_\") for w in ingredients.multi_word_ingredients_stemmed] + ingredients.ingredients_stemmed)\n",
" cg.add_misc_value_by_list(\"food_type\", \"action\", actions.stemmed_cooking_verbs)\n",
" cg.add_misc_value_by_list(\"food_type\", \"containers\", containers.containers)\n",
"\n",
" savefile.write(str(cg))"
]

View File

@ -20,10 +20,16 @@ spec.loader.exec_module(ingredients)
# loading actions:
spec = importlib.util.spec_from_file_location(
"ingredients", "../" + settings.actions_file)
"actions", "../" + settings.actions_file)
actions = importlib.util.module_from_spec(spec)
spec.loader.exec_module(actions)
# loading containers
spec = importlib.util.spec_from_file_location(
"containers", "../" + settings.container_file)
containers = importlib.util.module_from_spec(spec)
spec.loader.exec_module(containers)
# skipping recipes:
n_skipped_recipes = int(sys.argv[1]) if len(sys.argv) > 1 else 0
print("start reading at recipe " + str(n_skipped_recipes))
@ -50,6 +56,7 @@ def process_instructions(instructions: list, document_ids=None):
cg.pos_tagging()
cg.add_misc_value_by_list("food_type", "ingredient", [w.replace(" ","_") for w in ingredients.multi_word_ingredients_stemmed] + ingredients.ingredients_stemmed)
cg.add_misc_value_by_list("food_type", "action", actions.stemmed_cooking_verbs)
cg.add_misc_value_by_list("food_type", "containers", containers.containers)
savefile.write(str(cg))

View File

@ -8,3 +8,6 @@ fooddb_folder = data_root + "foodb_2017_06_29_csv/"
ingredients_file = data_root + "ingredients.py"
actions_file = data_root + "actions.py"
container_file = data_root + "containers.py"
gzipped_conllu_data_root = data_root + "1M_recipes_conllu/"