import re


def sequencesAgreeProPerWithVerb(seq):
    """ Selects sequences where word 1 is a personal pronoun and word 2 is a verb that can follow it.
    For example, 'il aime' is possible in French but not *'il aiment' """
    seq = seq.reset_index(drop=True)
    dropouts = []
    p = re.compile('[123][sp]')
    if len(seq) != 0:
        for row in range(len(seq)):
            sequence = seq.loc[row]
            gpersons1= p.findall(sequence.infover_1)
            gpersons2= p.findall(sequence.infover_2)
            if sequence.ortho_0 == 'nous':
                if not (('1p' in gpersons1) & ('1p' in gpersons2)):
                    dropouts.append(row)
            if sequence.ortho_0 == 'vous':
                if not (('2p' in gpersons1) & ('2p' in gpersons2)):
                    dropouts.append(row)
            if (sequence.ortho_0 == 'ils') | (sequence.ortho_0 == 'elles'):
                if not (('3p' in gpersons1) & ('3p' in gpersons2)):
                    dropouts.append(row)
    pairs = seq.drop(dropouts)
    pairs = pairs.reset_index(drop=True)
    return pairs

    # 
    # Functions to select the confusing sequences for a given liaison consonant
    #