Skip to content
Snippets Groups Projects
Commit 74dafadb authored by Caroline DE POURTALES's avatar Caroline DE POURTALES
Browse files

adding GOAL cat

parent df43ddab
No related branches found
No related tags found
2 merge requests!6Linker with transformer,!5Linker with transformer
This diff is collapsed.
No preview for this file type
...@@ -38,7 +38,10 @@ def get_axiom_links(max_atoms_in_one_type, atoms_polarity, batch_axiom_links): ...@@ -38,7 +38,10 @@ def get_axiom_links(max_atoms_in_one_type, atoms_polarity, batch_axiom_links):
def category_to_atoms_axiom_links(category, categories_to_atoms): def category_to_atoms_axiom_links(category, categories_to_atoms):
res = [bool(re.match(r'' + atom_type + "_\d+", category)) for atom_type in atom_map.keys()] res = [bool(re.match(r'' + atom_type + "_\d+", category)) for atom_type in atom_map.keys()]
if True in res: if category.startswith("GOAL:"):
word, cat = category.split(':')
return [cat]
elif True in res:
return [category] return [category]
else: else:
category_cut = regex.match(regex_categories, category).groups() category_cut = regex.match(regex_categories, category).groups()
...@@ -65,7 +68,11 @@ def get_atoms_links_batch(category_batch): ...@@ -65,7 +68,11 @@ def get_atoms_links_batch(category_batch):
def category_to_atoms(category, categories_to_atoms): def category_to_atoms(category, categories_to_atoms):
res = [bool(re.match(r'' + atom_type + "_\d+", category)) for atom_type in atom_map.keys()] res = [bool(re.match(r'' + atom_type + "_\d+", category)) for atom_type in atom_map.keys()]
if True in res: if category.startswith("GOAL:"):
word, cat = category.split(':')
category = re.match(r'([a-zA-Z|_]+)_\d+', cat).group(1)
return [category]
elif True in res:
category = re.match(r'([a-zA-Z|_]+)_\d+', category).group(1) category = re.match(r'([a-zA-Z|_]+)_\d+', category).group(1)
return [category] return [category]
else: else:
...@@ -99,7 +106,9 @@ def category_to_atoms_polarity(category, polarity): ...@@ -99,7 +106,9 @@ def category_to_atoms_polarity(category, polarity):
''' '''
category_to_polarity = [] category_to_polarity = []
res = [bool(re.match(r'' + atom_type + "_\d+", category)) for atom_type in atom_map.keys()] res = [bool(re.match(r'' + atom_type + "_\d+", category)) for atom_type in atom_map.keys()]
if True in res or category.startswith("dia") or category.startswith("box"): if category.startswith("GOAL:"):
category_to_polarity.append(True)
elif True in res or category.startswith("dia") or category.startswith("box"):
category_to_polarity.append(False) category_to_polarity.append(False)
else: else:
# dr = / # dr = /
......
...@@ -8,14 +8,14 @@ import pandas as pd ...@@ -8,14 +8,14 @@ import pandas as pd
# dl = \ # dl = \
def sub_tree_word(word_with_data: str): def sub_tree_word(word_with_data: str):
s = word_with_data.split('|') if word_with_data.startswith("GOAL"):
try: word = word_with_data
tree = word_with_data
else:
s = word_with_data.split('|')
word = s[0] word = s[0]
tree = s[1] tree = s[1]
return word, tree
return word, tree
except:
return s[0], []
def sub_tree_line(line_with_data: str): def sub_tree_line(line_with_data: str):
......
...@@ -61,7 +61,7 @@ print("sentence", sentences_batch[14]) ...@@ -61,7 +61,7 @@ print("sentence", sentences_batch[14])
print("categories ", df_axiom_links["sub_tree"][14]) print("categories ", df_axiom_links["sub_tree"][14])
print("atoms_batch", atoms_batch[14]) print("atoms_batch", atoms_batch[14])
print("atoms_polarity_batch", atoms_polarity_batch[14]) print("atoms_polarity_batch", atoms_polarity_batch[14])
print(" truth_links_batch example on a sentence class n", truth_links_batch[14][2]) print(" truth_links_batch example on a sentence class txt", truth_links_batch[14][16])
# Construction tensor dataset # Construction tensor dataset
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment