def reorganize_adj(sentence): """ deletes ',' and 'and' if it is between adjectives Input=sentence Output=sentence """ #init i = 0 while i < len(sentence) - 1: if sentence[i] == ',' or sentence[i] == 'and': if analyse_nominal_group.is_an_adj(sentence[i + 1]) and analyse_nominal_group.is_an_adj(sentence[i - 1]): if other_functions.number(sentence[i + 1]) == 0 and other_functions.number(sentence[i - 1]) == 0: sentence = sentence[:i] + sentence[i + 1:] i += 1 return sentence
def reorganize_adj(sentence): """ deletes ',' and 'and' if it is between adjectives Input=sentence Output=sentence """ # init i = 0 while i < len(sentence) - 1: if sentence[i] == ',' or sentence[i] == 'and': if analyse_nominal_group.is_an_adj( sentence[i + 1]) and analyse_nominal_group.is_an_adj( sentence[i - 1]): if other_functions.number( sentence[i + 1]) == 0 and other_functions.number( sentence[i - 1]) == 0: sentence = sentence[:i] + sentence[i + 1:] i += 1 return sentence
def upper_to_lower(sentence): """ converts the upper case to lower case Input=sentence, beginning sentence list Output=sentence """ # If the sentence begins with upper case if other_functions.find_cap_lettre(sentence[0]): # We convert upper case to lower case if it is not 'I' if sentence[0] == 'I': sentence = expand_contractions(sentence) return sentence else: sentence[0] = sentence[0][0].lower() + sentence[0][1:] #We make changes here because we need lower case and not upper case sentence = expand_contractions(sentence) sentence = adverbial_or_subsentence(sentence) stc = process_and_beginning_sentence(sentence) #If sentence is modified we can return it if stc != sentence: return stc #We find an action verb => it is an imperative sentence if sentence[0] in ThematicRolesDict().get_all_verbs(): return sentence #If we find the word in the Beginning_sentence list for v in ResourcePool().sentence_starts: if sentence[0] == v[0]: return sentence #We find a number if other_functions.number(sentence[0]) == 1: return sentence #If there is plural sentence = analyse_nominal_group.find_plural(sentence) #If it still start with adjective if analyse_nominal_group.is_an_adj(sentence[0]) == 1: sentence = ['the'] + sentence #If there is a nominal group if analyse_nominal_group.find_sn_pos(sentence, 0): return sentence #Default case: we assume a proper name, we convert lowercase to uppercase sentence[0] = sentence[0][0].upper() + sentence[0][1:] # If the sentence begins with lower case else: #We make changes here because we need lower case and not upper case sentence = expand_contractions(sentence) sentence = adverbial_or_subsentence(sentence) sentence = process_and_beginning_sentence(sentence) #If we find the word in the Beginning_sentence list so we can return it for v in ResourcePool().sentence_starts: if sentence[0] == v[0]: return sentence #If there is plural sentence = analyse_nominal_group.find_plural(sentence) #If it still start with adjective if analyse_nominal_group.is_an_adj(sentence[0]) == 1: sentence = ['the'] + sentence return sentence
def upper_to_lower(sentence): """ converts the upper case to lower case Input=sentence, beginning sentence list Output=sentence """ #If the sentence begins with upper case if other_functions.find_cap_lettre(sentence[0]): #We convert upper case to lower case if it is not 'I' if sentence[0] == 'I': sentence = expand_contractions(sentence) return sentence else: sentence[0] = sentence[0][0].lower() + sentence[0][1:] #We make changes here because we need lower case and not upper case sentence = expand_contractions(sentence) sentence = adverbial_or_subsentence(sentence) stc = process_and_beginning_sentence(sentence) #If sentence is modified we can return it if stc != sentence: return stc #We find an action verb => it is an imperative sentence if sentence[0] in ThematicRolesDict().get_all_verbs(): return sentence #If we find the word in the Beginning_sentence list for v in ResourcePool().sentence_starts: if sentence[0] == v[0]: return sentence #We find a number if other_functions.number(sentence[0]) == 1: return sentence #If there is plural sentence = analyse_nominal_group.find_plural(sentence) #If it still start with adjective if analyse_nominal_group.is_an_adj(sentence[0]) == 1: sentence = ['the'] + sentence #If there is a nominal group if analyse_nominal_group.find_sn_pos(sentence, 0): return sentence #Default case: we assume a proper name, we convert lowercase to uppercase sentence[0] = sentence[0][0].upper() + sentence[0][1:] #If the sentence begins with lower case else: #We make changes here because we need lower case and not upper case sentence = expand_contractions(sentence) sentence = adverbial_or_subsentence(sentence) sentence = process_and_beginning_sentence(sentence) #If we find the word in the Beginning_sentence list so we can return it for v in ResourcePool().sentence_starts: if sentence[0] == v[0]: return sentence #If there is plural sentence = analyse_nominal_group.find_plural(sentence) #If it still start with adjective if analyse_nominal_group.is_an_adj(sentence[0]) == 1: sentence = ['the'] + sentence return sentence