Exemplo n.º 1
0
def search(pattern, directory='C:/Users/Prestigio/Desktop/awarl/new/'):
    errors = []
    folders = os.listdir(directory)
    for folder in folders:
        print(folder)
        files = os.listdir(directory + folder)
        for file in files:
            text = inversion.open_file(directory + folder + '/' + file)
            sentences = text.split('@')
            for sent in sentences:
                errexp = re.search(pattern, sent, flags=re.IGNORECASE)  #!
                if errexp:  #re.search(pattern, sent, flags=re.IGNORECASE)
                    errors.append([
                        re.sub('^\n', '', sent), file, folder,
                        errexp.group()
                    ])  #!
    return errors
Exemplo n.º 2
0
def search(pattern, directory='C:/Users/Prestigio/Desktop/awarl/new/'):
    errors = []
    folders = os.listdir(directory)
    for folder in folders:
        print(folder)
        files = os.listdir(directory + folder)
        for file in files:
            text = open_file(directory + folder + '/' + file)
            sentences = text.split('@')
            for sent in sentences:
                for clause in sent.split(';'):
                    a = re.search(pattern, clause, flags=re.IGNORECASE)
                    if a:
                        if 'DTQ>' not in a.groups(1)[0]:
                            errors.append(
                                [re.sub('^\n', '', sent), file, folder])
    return errors
Exemplo n.º 3
0
def pattern():
    ##Prep + for example/for instance/maybe/however/possibly/probably +
    ##NP (in (,)for example (,)the course of syntax)

    start = '(?:<[^>]+\s(?:PR.|AVP)>)'
    verbs = open_file('trans.txt').split(', ')
    an_start = '(?:<(?:' + '|'.join(verbs) + ')\s[^N]..>)'
    f_e = '(?:<for\s...><(?:example\s...>))'
    f_i = '(?:<for\s...><(?:instance\s...>))'
    mb = '(?:<maybe\s...>)'
    pr = '(?:<perhaps\s...>)'
    hw = '(?:<however\s...>)'
    psb = '(?:<possibly\s...>)'
    prb = '(?:<probably\s...>)'
    var = '|'.join([f_e, f_i, mb, pr, hw, psb, prb])
    p = '(?:' + start + '|' + an_start + ')' + '(?:<,\sPUN>)?' + '(?:' + var + ')' + '(?:<,\sPUN>)?' + '(' + nounp(
    ) + ')'
    return p
Exemplo n.º 4
0
def search(pattern, directory='tags/'):
    errors = []
    folders = os.listdir(directory)
    for folder in folders:
        print(folder)
        if folder != '.DS_Store':
            folder_address = directory + folder
            files = os.listdir(folder_address)
            for file in files:
                if file != '.DS_Store':
                    text = inversion.open_file(folder_address + '/' + file)
                    sentences = text.split('@')
                    for sent in sentences:
                        for clause in sent.split(';'):
                            a = re.search(pattern, clause, flags=re.IGNORECASE)
                            if a:
                                if 'DTQ>' not in a.groups(1)[0]:
                                    errors.append([
                                        re.sub('^\n', '', sent), file, folder
                                    ])
    return errors
Exemplo n.º 5
0
def pattern():
    ##Prep + for example/for instance/maybe/however/possibly/probably +
    ##(Det (+ Adj)) N (in (,)for example (,)the course of syntax)

    ## убрать such as и like
    ##добавить TRANSITIVE for example OBJECT
    #(?!<such\s...><as\s...>)(?!<like\s...>)
    start = '(?:<[^>]+\s(?:PR.|AVP)>)'
    verbs = open_file('trans.txt').split(', ')
    an_start = '(?:<(?:' + '|'.join(
        verbs
    ) + ')' + '\sV..>)'  #+ '(?:' + nounp() + ')?' #i need a list of bi-transitive verbs to make a better model
    f_e = '(?:<for\s...><(?:example\s...>))'
    f_i = '(?:<for\s...><(?:instance\s...>))'
    mb = '(?:<maybe\s...>)'
    pr = '(?:<perhaps\s...>)'
    hw = '(?:<however\s...>)'
    psb = '(?:<possibly\s...>)'
    prb = '(?:<probably\s...>)'
    var = '|'.join([f_e, f_i, mb, pr, hw, psb, prb])
    p = '(?:' + start + '|' + an_start + ')' + '(?:<,\sPUN>)?' + '(?:' + var + ')' + '(?:<,\sPUN>)?' + '(' + nounp(
    ) + ')'
    return p