#------------------------------------------------------------------------------------ sentence=open(path+"SemanticRoleMiner/code/input/test_input.txt","r") sent=sentence.readline() sentence.close() OrgSent=sent #handling 's inputFile="srl/SemanticRoleMiner/code/input" myTestFile=SenSta(inputFile) myTestFile.makeStanf() stanfile=path+"SemanticRoleMiner/code/input"+"/stanoutput.txt" Stan=modifyStanf(stanfile) # Fixing 's, using poss dependecy , it Only works if stanford recognizes poss dependecy Poss=[] for key,val in Stan.items(): for i, prep in val.items(): pred=prep.keys()[0] rel=prep.values()[0] token1=rel[0] token2=rel[1] if pred=="poss": Poss.append((str(token2.split("-")[0])+str(token1.split("-")[0]),str(token2.split("-")[0]),str(token1.split("-")[0]))) #print "***********Posessins: ",Poss sent=sent.replace(str(token2.split("-")[0])+"'s "+str(token1.split("-")[0]),str(token2.split("-")[0])+str(token1.split("-")[0])) #print sent
def makeStanf(self): cmd=os.system('cd /home/kimia/srl/stanford-parser/ \n ./lexparser.sh '+self.inputFile+' >'+self.stanOutFile+'output.txt') self.stanfDict=modifyStanf(self.stanOutFile+'output.txt') return self.stanfDict