Skip to content

Commit

Permalink
Update topic_assistant2.py
Browse files Browse the repository at this point in the history
added threshold
  • Loading branch information
yovisto committed Sep 28, 2022
1 parent 2243b06 commit 43659f7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/topic_assistant2.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,21 @@ def go(self, exampleText):

for i in reversed(ix):
#print ( str(sim[i]), df.iloc[i]["id"], df.iloc[i]["path"])
for n in self.df.iloc[i]["path"].split():
nodes.add(n)
if (newTree.contains(URIRef(n))):
newTree.get_node(URIRef(n)).data['w']=newTree.get_node(URIRef(n)).data['w'] + sim[i][0]
if sim[i][0] >= 0.3:
for n in self.df.iloc[i]["path"].split():
nodes.add(n)
if newTree.contains(URIRef(n)):
newTree.get_node(URIRef(n)).data['w']=newTree.get_node(URIRef(n)).data['w'] + sim[i][0]

formatter = "{0:.2f}"
#print (nodes)
for node in newTree.all_nodes():
#print (node.identifier), node.identifier in nodes)
if node.tag!="WLO":
node.tag = node.tag + " (" + formatter.format(node.data['w']) + ")"
if not str(node.identifier) in nodes:
if (newTree.contains(node.identifier)):
newTree.remove_node(node.identifier)
if not str(node.identifier) in nodes:
if (newTree.contains(node.identifier)):
newTree.remove_node(node.identifier)


#print (len(newTree))
Expand Down

0 comments on commit 43659f7

Please sign in to comment.