Skip to content

Commit

Permalink
Fix issues with graph.infertopics, closes #516
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmezzetti committed Aug 9, 2023
1 parent 2f73729 commit d8be34f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/txtai/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ def infertopics(self):
ids = self.edges(uid)

# Infer topic
topic = Counter(self.attribute(x, "topic") for x in ids).most_common(1)[0][0]
topic = Counter(self.attribute(x, "topic") for x in ids).most_common(1)[0][0] if ids else None
if topic:
# Add id to topic list and set topic attribute
self.topics[topic].append(uid)
self.addattribute(uid, "topic", topic)

# Set topic rank
self.addattribute(uid, "topicrank", len(self.topics[topic]))
self.addattribute(uid, "topicrank", len(self.topics[topic]) - 1)

# Infer category
category = Counter(self.attribute(x, "category") for x in ids).most_common(1)[0][0]
Expand Down

0 comments on commit d8be34f

Please sign in to comment.