#NEWLINE# def roles_demo( trace = 0 ) : #NEWLINE# #INDENT# from nltk.corpus import ieer #NEWLINE# roles = '\n    (.*(                   # assorted roles\n    analyst|\n    chair(wo)?man|\n    commissioner|\n    counsel|\n    director|\n    economist|       \n    editor|\n    executive|\n    foreman|\n    governor|\n    head|\n    lawyer|\n    leader|\n    librarian).*)|\n    manager|\n    partner|\n    president|\n    producer|\n    professor|\n    researcher|\n    spokes(wo)?man|\n    writer|\n    ,\\sof\\sthe?\\s*  # "X, of (the) Y"\n    ' #NEWLINE# ROLES = re . compile ( roles , re . VERBOSE ) #NEWLINE# print ( ) #NEWLINE# print ( 'IEER: has_role(PER, ORG) -- raw rtuples:' ) #NEWLINE# print ( ( '=' * 45 ) ) #NEWLINE# for file in ieer . fileids ( ) : #NEWLINE# #INDENT# for doc in ieer . parsed_docs ( file ) : #NEWLINE# #INDENT# lcon = rcon = False #NEWLINE# if trace : #NEWLINE# #INDENT# print ( doc . docno ) #NEWLINE# print ( ( '=' * 15 ) ) #NEWLINE# lcon = rcon = True #NEWLINE# #UNINDENT# for rel in extract_rels ( 'PER' , 'ORG' , doc , corpus = 'ieer' , pattern = ROLES ) : #NEWLINE# #INDENT# print ( rtuple ( rel , lcon = lcon , rcon = rcon ) )