def convert_adj_to_digit(adj_list):
    """
    returns the list of adjectives after change number to digit                           
    :param the adjective                            
    :return: the adjective            
    """

    for i in adj_list:
        if i.endswith('th') and other_functions.number(i) == 2:
            adj_list[adj_list.index(i)] = other_functions.convert_to_digit(i) + 'th'

    return adj_list
def convert_adj_to_digit(adj_list):
    """
    returns the list of adjectives after change number to digit                           
    :param the adjective                            
    :return: the adjective            
    """

    for i in adj_list:
        if i.endswith('th') and other_functions.number(i) == 2:
            adj_list[adj_list.index(
                i)] = other_functions.convert_to_digit(i) + 'th'

    return adj_list
def recover_quantifier(nom_gr):
    """
    recovers the quantifier and put the noun in singular form if it's in plural
    Input=nominal group class                     Output=nominal group class
    """

    #init
    flg = 0

    #The default case is 'ONE'
    if not nom_gr.det:
        #If the noun is 'anything' => SOME 
        if nom_gr.noun and nom_gr.noun[0] in ["anything"]:
            nom_gr._quantifier = 'SOME'
            #If the noun is 'everything' => ALL
        if nom_gr.noun and nom_gr.noun[0] in ["everything"]:
            nom_gr._quantifier = 'ALL'
            #If the noun starts with 'any' => we have 'all'
        if nom_gr.noun and nom_gr.noun[0].startswith('any'):
            nom_gr._quantifier = 'SOME'
            #If the noun starts with 'no' => we have 'none'
        if nom_gr.noun and nom_gr.noun[0].startswith('no'):
            nom_gr._quantifier = 'NONE'

    else:

        #If it is a number
        if other_functions.number(nom_gr.det[0]) == 1:
            nom_gr._quantifier = 'DIGIT'
            nom_gr.det = [other_functions.convert_to_digit(nom_gr.det[0])]

        #Here we will use the quantifier list
        for i in ResourcePool().det_quantifiers:
            if i[0] == nom_gr.det[0]:
                nom_gr._quantifier = i[1]

        #If we have a plural
        if nom_gr.noun != [] and nom_gr.noun[0].endswith('s'):
            for x in ResourcePool().nouns_end_s:
                if x == nom_gr.noun[0]:
                    #It is a noun singular with 's' at the end
                    flg = 1
                    break
            if flg == 0:
                #We delete determinant added in processing with his quantifier
                if nom_gr.det[0] == 'a':
                    nom_gr.det = []
                    nom_gr._quantifier = 'ONE'
                elif nom_gr.det[0] == 'no':
                    nom_gr._quantifier = 'ANY'

                #We have to put the noun in singular form
                for y in ResourcePool().plural_nouns:
                    #If it is an irregular noun
                    if y[0] == nom_gr.noun[0]:
                        nom_gr.noun[0] = y[1]
                        if nom_gr._quantifier == 'ONE':
                            nom_gr._quantifier = 'ALL'
                        return nom_gr
                    #Else
                nom_gr.noun[0] = nom_gr.noun[0][:len(nom_gr.noun[0]) - 1]
                if nom_gr._quantifier == 'ONE':
                    nom_gr._quantifier = 'ALL'
                return nom_gr

        return nom_gr
def recover_quantifier(nom_gr):
    """
    recovers the quantifier and put the noun in singular form if it's in plural
    Input=nominal group class                     Output=nominal group class
    """

    #init
    flg = 0

    #The default case is 'ONE'
    if not nom_gr.det:
        #If the noun is 'anything' => SOME 
        if nom_gr.noun and nom_gr.noun[0] in ["anything"]:
            nom_gr._quantifier = 'SOME'
            #If the noun is 'everything' => ALL
        if nom_gr.noun and nom_gr.noun[0] in ["everything"]:
            nom_gr._quantifier = 'ALL'
            #If the noun starts with 'any' => we have 'all'
        if nom_gr.noun and nom_gr.noun[0].startswith('any'):
            nom_gr._quantifier = 'SOME'
            #If the noun starts with 'no' => we have 'none'
        if nom_gr.noun and nom_gr.noun[0].startswith('no'):
            nom_gr._quantifier = 'NONE'

    else:

        #If it is a number
        if other_functions.number(nom_gr.det[0]) == 1:
            nom_gr._quantifier = 'DIGIT'
            nom_gr.det = [other_functions.convert_to_digit(nom_gr.det[0])]

        #Here we will use the quantifier list
        for i in ResourcePool().det_quantifiers:
            if i[0] == nom_gr.det[0]:
                nom_gr._quantifier = i[1]

        #If we have a plural
        if nom_gr.noun != [] and nom_gr.noun[0].endswith('s'):
            for x in ResourcePool().nouns_end_s:
                if x == nom_gr.noun[0]:
                    #It is a noun singular with 's' at the end
                    flg = 1
                    break
            if flg == 0:
                #We delete determinant added in processing with his quantifier
                if nom_gr.det[0] == 'a':
                    nom_gr.det = []
                    nom_gr._quantifier = 'ONE'
                elif nom_gr.det[0] == 'no':
                    nom_gr._quantifier = 'ANY'

                #We have to put the noun in singular form
                for y in ResourcePool().plural_nouns:
                    #If it is an irregular noun
                    if y[0] == nom_gr.noun[0]:
                        nom_gr.noun[0] = y[1]
                        if nom_gr._quantifier == 'ONE':
                            nom_gr._quantifier = 'ALL'
                        return nom_gr
                    #Else
                nom_gr.noun[0] = nom_gr.noun[0][:len(nom_gr.noun[0]) - 1]
                if nom_gr._quantifier == 'ONE':
                    nom_gr._quantifier = 'ALL'
                return nom_gr

        return nom_gr