Commit 6c6b9c44 authored by Davide Liga's avatar Davide Liga

some fix

parent b5f5f042
......@@ -132,14 +132,18 @@ class ParagraphQualifier(SpacyModelUser):
return first_tokens
TOKEN_SLOT_SIZE = 2
def qualify(self, p):
"""
This function qualify a given string as preambular or operational
"""
if p == '':
return [None, None, None, (0, 0)]
p = p.strip()
qualification = None
term = None
TOKEN_SLOT_SIZE = 2
list_of_prep = [
'at',
......@@ -232,7 +236,7 @@ class ParagraphQualifier(SpacyModelUser):
case = "__ING"
# [[ Considering paragraphs of at least 4 tokens ]]
if len(first_tokens) >= 4 * 2:
if len(first_tokens) >= 4 * TOKEN_SLOT_SIZE:
# e.g. "Continuing to underline"
if first_tokens.get('label_2', '') == "TO" and first_tokens.get('label_3', '').lower().startswith('v'):
......@@ -441,7 +445,7 @@ class ParagraphQualifier(SpacyModelUser):
qualification = "operational"
case = "__PRP"
if first_tokens.get('label_2', '') is not None and first_tokens.get('label_3', '') is not None:
if len(first_tokens) >= 2*TOKEN_SLOT_SIZE and len(first_tokens) >= 3*TOKEN_SLOT_SIZE:
if first_tokens.get('token_2', '').lower() == "also" and first_tokens.get('label_3', '').lower().startswith("v"):
term = first_tokens.get('token_2', '').capitalize() + first_tokens.get('token_3', '').capitalize()
......@@ -768,7 +772,7 @@ class ParagraphQualifier(SpacyModelUser):
if qualification is not None:
# Cecking in positions 2-3
if len(first_tokens) >= 3 * 2:
if len(first_tokens) >= 3 * TOKEN_SLOT_SIZE:
# with concern
if first_tokens.get('token_2', '').lower() == 'with' and first_tokens.get('token_3', '').lower() in list_of_nouns:
......@@ -788,7 +792,7 @@ class ParagraphQualifier(SpacyModelUser):
case = case + "_JJVBNVBDnns"
# Cecking in positions 2-3-4
if len(first_tokens) >= 4 * 2:
if len(first_tokens) >= 4 * TOKEN_SLOT_SIZE:
# with deep concern
if first_tokens.get('token_2', '').lower() == 'with' and (
......@@ -820,7 +824,7 @@ class ParagraphQualifier(SpacyModelUser):
case = case + "_JJVBNVBDnns"
# Cecking in positions 3-4-5
if len(first_tokens) >= 5 * 2:
if len(first_tokens) >= 5 * TOKEN_SLOT_SIZE:
# with deep concern
if first_tokens.get('token_3', '').lower() == 'with' and (
......@@ -852,7 +856,7 @@ class ParagraphQualifier(SpacyModelUser):
case = case + "_JJVBNVBDnns"
# Cecking in positions 4-5-6 [rare]
if len(first_tokens) >= 6 * 2:
if len(first_tokens) >= 6 * TOKEN_SLOT_SIZE:
# with deep concern
if first_tokens.get('token_4', '').lower() == 'with' and (
......@@ -884,7 +888,7 @@ class ParagraphQualifier(SpacyModelUser):
case = case + "_JJVBNVBDnns"
# Cecking in positions 5-6-7 [rare]
if len(first_tokens) >= 7 * 2:
if len(first_tokens) >= 7 * TOKEN_SLOT_SIZE:
# with deep concern
if first_tokens.get('token_5', '').lower() == 'with' and (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment