def extract_rels(subjclass, objclass, doc, corpus='ace', pattern=None, window=10):

    if subjclass and subjclass not in NE_CLASSES[corpus]:
        if _expand(subjclass) in NE_CLASSES[corpus]:
            subjclass = _expand(subjclass)
        else:
            raise ValueError("your value for the subject type has not been recognized: %s" % subjclass)
    if objclass and objclass not in NE_CLASSES[corpus]:
        if _expand(objclass) in NE_CLASSES[corpus]:
            objclass = _expand(objclass)
        else:
            raise ValueError("your value for the object type has not been recognized: %s" % objclass)
        
    if corpus == 'ace' or corpus == 'conll2002':
        pairs = tree2semi_rel(doc)
    elif corpus == 'ieer':
        pairs = tree2semi_rel(doc.text) + tree2semi_rel(doc.headline)
    else:
        raise ValueError("corpus type not recognized")

    reldicts = semi_rel2reldict(pairs)

    relfilter = lambda x: (x['subjclass'] == subjclass and
                           len(x['filler'].split()) <= window and
                           pattern.match(x['filler']) and
                           x['objclass'] == objclass)

    return list(filter(relfilter, reldicts))
Filter the output of ``semi_rel2reldict`` according to specified NE classes and a filler pattern.
dataset/ETHPy150Open nltk/nltk/nltk/sem/relextract.py/extract_rels