mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
lib: Rename *topic local variables to *topic_name.
This is preparatory work towards adding a Topic model. We plan to use the local variable name as 'topic' for the Topic model objects. Currently, we use *topic as the local variable name for topic names. We rename local variables of the form *topic to *topic_name so that we don't need to think about type collisions in individual code paths where we might want to talk about both Topic objects and strings for the topic name.
This commit is contained in:
committed by
Tim Abbott
parent
bc66eaee7d
commit
b7e56ccbdc
@@ -23,14 +23,14 @@ def generate_topics(num_topics: int) -> List[str]:
|
||||
# Single word topics are most common, thus
|
||||
# it is important we test on it.
|
||||
num_single_word_topics = num_topics // 3
|
||||
topics = random.choices(config["nouns"], k=num_single_word_topics)
|
||||
topic_names = random.choices(config["nouns"], k=num_single_word_topics)
|
||||
|
||||
sentence = ["adjectives", "nouns", "connectors", "verbs", "adverbs"]
|
||||
for pos in sentence:
|
||||
# Add an empty string so that we can generate variable length topics.
|
||||
config[pos].append("")
|
||||
|
||||
topics.extend(
|
||||
topic_names.extend(
|
||||
" ".join(word for pos in sentence if (word := random.choice(config[pos])) != "")
|
||||
for _ in range(num_topics - num_single_word_topics)
|
||||
)
|
||||
@@ -45,8 +45,10 @@ def generate_topics(num_topics: int) -> List[str]:
|
||||
resolved_topic_probability = 0.05
|
||||
|
||||
return [
|
||||
RESOLVED_TOPIC_PREFIX + topic if random.random() < resolved_topic_probability else topic
|
||||
for topic in topics
|
||||
RESOLVED_TOPIC_PREFIX + topic_name
|
||||
if random.random() < resolved_topic_probability
|
||||
else topic_name
|
||||
for topic_name in topic_names
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user