def possession_ques(analysis):
    """
    verbalises a question about possession                             
    Input=class sentence                              Output=sentence                
    """

    #processing as statement
    phrase = statement(analysis)

    #We have to know if it is plural or singular
    if other_functions.plural_noun(analysis.sn) == 1:
        return ['whose'] + phrase[:len(phrase) - 1] + ['these'] + ['?']
    else:
        return ['whose'] + phrase[1:len(phrase) - 1] + ['this'] + ['?']
def conjugate_vrb(tense, verb, sn, type, aim):
    """
    conjugates the verb                                                
    Input=tense, verb in infinitive form, the adverb and subject                     
    Output=the verb conjugated                                                       
    """

    #If there is no tense => we use the present simple
    if tense == '':
        tense = 'present simple'

    if aim.startswith('classification'):
        if not sn:
            sn = [NominalGroup([], [aim[15:]], [], [], [])]
        elif not sn[0].noun:
            sn[0].noun = [aim[15:]]

    if not sn:
        if type == IMPERATIVE:
            #If no subject, we use the third person of plural
            sn = [NominalGroup([], ['they'], [], [], [])]
        else:
            #If no subject, we use the third person of singular
            sn = [NominalGroup([], ['it'], [], [], [])]

    #For future simple
    if tense == 'future simple':
        return ['will'] + verb

    #For present simple
    elif tense == 'present simple':

        if verb[0] == 'be':
            #Plural nouns
            if sn[0].noun == ['I']:
                return ['am'] + verb[1:]
            elif other_functions.plural_noun(sn) == 1:
                return ['are'] + verb[1:]
            elif sn[0].noun == ['we'] or sn[0].noun == [
                    'you'
            ] or sn[0].noun == ['they']:
                return ['are'] + verb[1:]
            else:
                #Singular nouns
                return ['is'] + verb[1:]

        else:
            #Plural nouns
            if other_functions.plural_noun(sn) == 1:
                return verb
            else:
                #Singular nouns
                for i in ResourcePool().irregular_verbs_present:
                    if i[0] == verb[0]:
                        return [i[1]] + verb[1:]
                return [verb[0] + 's'] + verb[1:]

    #For past simple
    elif tense == 'past simple':

        if verb[0] == 'be':
            if sn[0].noun == ['I']:
                return ['was'] + verb[1:]
            #Plural nouns
            elif other_functions.plural_noun(sn) == 1:
                return ['were'] + verb[1:]
            else:
                #Singular nouns
                return ['was'] + verb[1:]

        else:
            for i in ResourcePool().irregular_verbs_past:
                if i[0] == verb[0]:
                    return [i[1]] + verb[1:]
            return [verb[0] + 'ed'] + verb[1:]

    #For progressive forms
    elif tense == 'present progressive':
        for m in ResourcePool().irregular_verbs_present:
            if m[0] == verb[0]:
                return conjugate_vrb('present simple', ['be'], sn, type,
                                     aim) + [m[2]] + verb[1:]
        return conjugate_vrb('present simple', ['be'], sn, type,
                             aim) + [verb[0] + 'ing'] + verb[1:]
    elif tense == 'past progressive':
        for m in ResourcePool().irregular_verbs_present:
            if m[0] == verb[0]:
                return conjugate_vrb('past simple', ['be'], sn, type,
                                     aim) + [m[2]] + verb[1:]
        return conjugate_vrb('past simple', ['be'], sn, type,
                             aim) + [verb[0] + 'ing'] + verb[1:]

    #For perfect forms
    elif tense == 'present perfect':
        for i in ResourcePool().irregular_verbs_past:
            if verb[0] == i[0]:
                return conjugate_vrb('present simple', ['have'], sn, type,
                                     aim) + [i[2]] + verb[1:]
        return conjugate_vrb('present simple', ['have'], sn, type,
                             aim) + [verb[0] + 'ed'] + verb[1:]
    elif tense == 'present perfect':
        for i in ResourcePool().irregular_verbs_past:
            if verb[0] == i[0]:
                return ['had'] + [i[2]] + verb[1:]
        return ['had'] + [verb[0] + 'ed'] + verb[1:]

    #For passive forms
    elif tense == 'present passive':
        return conjugate_vrb('present simple', ['be'], sn,
                             type, aim) + conjugate_vrb(
                                 'present perfect', verb, sn, type, aim)[1:]
    elif tense == 'past passive':
        return conjugate_vrb('past simple', ['be'], sn,
                             type, aim) + conjugate_vrb(
                                 'present perfect', verb, sn, type, aim)[1:]

    #For conditional forms
    elif tense == 'present conditional':
        return ['would'] + verb
    elif tense == 'past conditional':
        return ['would'] + conjugate_vrb('present perfect', verb, sn, type,
                                         aim)

    #Default case
    return []
Exemple #3
0
def conjugate_vrb(tense, verb, sn, type, aim):
    """
    conjugates the verb                                                
    Input=tense, verb in infinitive form, the adverb and subject                     
    Output=the verb conjugated                                                       
    """

    #If there is no tense => we use the present simple
    if tense == '':
        tense = 'present simple'

    if aim.startswith('classification'):
        if not sn:
            sn = [Nominal_Group([], [aim[15:]], [], [], [])]
        elif not sn[0].noun:
            sn[0].noun = [aim[15:]]

    if not sn:
        if type == IMPERATIVE:
            #If no subject, we use the third person of plural
            sn = [Nominal_Group([], ['they'], [], [], [])]
        else:
            #If no subject, we use the third person of singular
            sn = [Nominal_Group([], ['it'], [], [], [])]

    #For future simple
    if tense == 'future simple':
        return ['will'] + verb

    #For present simple
    elif tense == 'present simple':

        if verb[0] == 'be':
            #Plural nouns
            if sn[0].noun == ['I']:
                return ['am'] + verb[1:]
            elif other_functions.plural_noun(sn) == 1:
                return ['are'] + verb[1:]
            elif sn[0].noun == ['we'] or sn[0].noun == ['you'] or sn[0].noun == ['they']:
                return ['are'] + verb[1:]
            else:
                #Singular nouns
                return ['is'] + verb[1:]

        else:
            #Plural nouns
            if other_functions.plural_noun(sn) == 1:
                return verb
            else:
                #Singular nouns
                for i in ResourcePool().irregular_verbs_present:
                    if i[0] == verb[0]:
                        return [i[1]] + verb[1:]
                return [verb[0] + 's'] + verb[1:]

    #For past simple
    elif tense == 'past simple':

        if verb[0] == 'be':
            if sn[0].noun == ['I']:
                return ['was'] + verb[1:]
            #Plural nouns
            elif other_functions.plural_noun(sn) == 1:
                return ['were'] + verb[1:]
            else:
                #Singular nouns
                return ['was'] + verb[1:]

        else:
            for i in ResourcePool().irregular_verbs_past:
                if i[0] == verb[0]:
                    return [i[1]] + verb[1:]
            return [verb[0] + 'ed'] + verb[1:]

    #For progressive forms
    elif tense == 'present progressive':
        for m in ResourcePool().irregular_verbs_present:
            if m[0] == verb[0]:
                return conjugate_vrb('present simple', ['be'], sn, type, aim) + [m[2]] + verb[1:]
        return conjugate_vrb('present simple', ['be'], sn, type, aim) + [verb[0] + 'ing'] + verb[1:]
    elif tense == 'past progressive':
        for m in ResourcePool().irregular_verbs_present:
            if m[0] == verb[0]:
                return conjugate_vrb('past simple', ['be'], sn, type, aim) + [m[2]] + verb[1:]
        return conjugate_vrb('past simple', ['be'], sn, type, aim) + [verb[0] + 'ing'] + verb[1:]

    #For perfect forms
    elif tense == 'present perfect':
        for i in ResourcePool().irregular_verbs_past:
            if verb[0] == i[0]:
                return conjugate_vrb('present simple', ['have'], sn, type, aim) + [i[2]] + verb[1:]
        return conjugate_vrb('present simple', ['have'], sn, type, aim) + [verb[0] + 'ed'] + verb[1:]
    elif tense == 'present perfect':
        for i in ResourcePool().irregular_verbs_past:
            if verb[0] == i[0]:
                return ['had'] + [i[2]] + verb[1:]
        return ['had'] + [verb[0] + 'ed'] + verb[1:]

    #For passive forms
    elif tense == 'present passive':
        return conjugate_vrb('present simple', ['be'], sn, type, aim) + conjugate_vrb('present perfect', verb, sn, type,
                                                                                      aim)[1:]
    elif tense == 'past passive':
        return conjugate_vrb('past simple', ['be'], sn, type, aim) + conjugate_vrb('present perfect', verb, sn, type,
                                                                                   aim)[1:]

    #For conditional forms
    elif tense == 'present conditional':
        return ['would'] + verb
    elif tense == 'past conditional':
        return ['would'] + conjugate_vrb('present perfect', verb, sn, type, aim)

    #Default case
    return []