Added container Category for conllu generation
This commit is contained in:
parent
777cbde605
commit
0c1d0c4451
@ -36,10 +36,16 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"# loading actions:\n",
|
"# loading actions:\n",
|
||||||
"spec = importlib.util.spec_from_file_location(\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",
|
"actions = importlib.util.module_from_spec(spec)\n",
|
||||||
"spec.loader.exec_module(actions)\n",
|
"spec.loader.exec_module(actions)\n",
|
||||||
"\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",
|
"# skipping recipes:\n",
|
||||||
"n_skipped_recipes = int(sys.argv[1]) if len(sys.argv) > 1 else 0\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",
|
"print(\"start reading at recipe \" + str(n_skipped_recipes))\n",
|
||||||
@ -72,6 +78,7 @@
|
|||||||
" cg.pos_tagging()\n",
|
" 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\", \"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\", \"action\", actions.stemmed_cooking_verbs)\n",
|
||||||
|
" cg.add_misc_value_by_list(\"food_type\", \"containers\", containers.containers)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" savefile.write(str(cg))"
|
" savefile.write(str(cg))"
|
||||||
]
|
]
|
||||||
|
@ -20,10 +20,16 @@ spec.loader.exec_module(ingredients)
|
|||||||
|
|
||||||
# loading actions:
|
# loading actions:
|
||||||
spec = importlib.util.spec_from_file_location(
|
spec = importlib.util.spec_from_file_location(
|
||||||
"ingredients", "../" + settings.actions_file)
|
"actions", "../" + settings.actions_file)
|
||||||
actions = importlib.util.module_from_spec(spec)
|
actions = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(actions)
|
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:
|
# skipping recipes:
|
||||||
n_skipped_recipes = int(sys.argv[1]) if len(sys.argv) > 1 else 0
|
n_skipped_recipes = int(sys.argv[1]) if len(sys.argv) > 1 else 0
|
||||||
print("start reading at recipe " + str(n_skipped_recipes))
|
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.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", "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", "action", actions.stemmed_cooking_verbs)
|
||||||
|
cg.add_misc_value_by_list("food_type", "containers", containers.containers)
|
||||||
|
|
||||||
savefile.write(str(cg))
|
savefile.write(str(cg))
|
||||||
|
|
||||||
|
@ -8,3 +8,6 @@ fooddb_folder = data_root + "foodb_2017_06_29_csv/"
|
|||||||
|
|
||||||
ingredients_file = data_root + "ingredients.py"
|
ingredients_file = data_root + "ingredients.py"
|
||||||
actions_file = data_root + "actions.py"
|
actions_file = data_root + "actions.py"
|
||||||
|
container_file = data_root + "containers.py"
|
||||||
|
|
||||||
|
gzipped_conllu_data_root = data_root + "1M_recipes_conllu/"
|
||||||
|
Loading…
Reference in New Issue
Block a user