From 43659f7e20e70d4245a42436c66b324dfdfded93 Mon Sep 17 00:00:00 2001 From: yovisto Date: Wed, 28 Sep 2022 13:52:01 +0200 Subject: [PATCH] Update topic_assistant2.py added threshold --- src/topic_assistant2.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/topic_assistant2.py b/src/topic_assistant2.py index bafcc23..f5eb851 100644 --- a/src/topic_assistant2.py +++ b/src/topic_assistant2.py @@ -154,10 +154,11 @@ 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) @@ -165,9 +166,9 @@ def go(self, exampleText): #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))