Hi,pal! I wanna use networkx to calculate the sentiment strength of a
wordnet by a propagation algorithm(it seems to be belief
propagation),but didnt get a good result. Is there a problem of my
implement?Any guidance would be greatly appreciated.
here is my code :
/#init the strength //
//for n in DG://
// if DG.in_degree(n)==0://
// if dictpos.get(n.encode('utf8'))://
// DG.node[n]['s'] = 1//
// else://
// DG.node[n]['s'] = -1//
// else://
// DG.node[n]['s']=0//
//#iter 12 times//
//for i in range(12)://
// maxs=0//
// for n in DG://
// if DG.in_degree(n)==0://
// continue//
// else://
// neighbors=DG.predecessors(n)//
// for nb in neighbors: //
// w=DG[nb][n]['weight'] /
DG.out_degree(nb,weight='weight')//
// DG.node[n]['s']+=w*DG.node[nb]['s']//
// if abs(DG.node[n]['s'])>maxs://
// maxs=abs(DG.node[n]['s'])//
// #normalize the strength//
// for n in DG://
// DG.node[n]['s']/=maxs/