Spaces:
Running
Running
update sentences and names
Browse files- src/streamlit_app.py +24 -22
src/streamlit_app.py
CHANGED
@@ -281,7 +281,7 @@ def add_example_topic(topic_id, topic_title, topic_description, comments_list):
|
|
281 |
def add_dummy_topic():
|
282 |
example_topic_id = "15736626"
|
283 |
example_topic_title = "New Civic Tech Initiative"
|
284 |
-
example_topic_description = "
|
285 |
example_comments = [
|
286 |
"Finally! A system to track rebel scum more efficiently. This will be a glorious day for the Empire!",
|
287 |
"This is clearly a data-mining operation. They're going to use it to crush the Rebellion. We need to sabotage it!",
|
@@ -664,7 +664,8 @@ def estimate_group_voting_diversity(user_ids, topic_id):
|
|
664 |
def name_user_group(user_ids, topic_id):
|
665 |
"""
|
666 |
Generates a descriptive name and description for a group of users within a
|
667 |
-
specific topic based on their participation level and voting diversity
|
|
|
668 |
|
669 |
Args:
|
670 |
user_ids (list[str]): A list of user IDs belonging to the group.
|
@@ -672,15 +673,15 @@ def name_user_group(user_ids, topic_id):
|
|
672 |
|
673 |
Returns:
|
674 |
tuple[str, str]: A tuple containing the name and description for the group.
|
675 |
-
Returns ("Silent
|
676 |
-
or ("
|
677 |
-
or ("
|
678 |
-
or ("
|
679 |
in edge cases or on error.
|
680 |
"""
|
681 |
-
# Handle empty user list
|
682 |
if not user_ids:
|
683 |
-
return "Silent
|
684 |
|
685 |
local_con = None
|
686 |
try:
|
@@ -712,13 +713,14 @@ def name_user_group(user_ids, topic_id):
|
|
712 |
group_voters_count = group_voters_result[0] if group_voters_result else 0
|
713 |
|
714 |
# Handle case where no one in the group has voted on this topic
|
|
|
715 |
if group_voters_count == 0:
|
716 |
-
return "
|
717 |
|
718 |
-
# Handle case where topic has no voters
|
719 |
if total_voters_in_topic == 0:
|
720 |
# This case is unlikely if group_voters_count > 0, but for safety
|
721 |
-
return "
|
722 |
|
723 |
|
724 |
# 3. Calculate significance (proportion of group voters among all topic voters)
|
@@ -746,32 +748,32 @@ def name_user_group(user_ids, topic_id):
|
|
746 |
elif diversity_score > DIV_LOW_THRESHOLD:
|
747 |
diversity_level = "medium"
|
748 |
|
749 |
-
# Assign names and descriptions based on levels
|
750 |
if significance_level == "high":
|
751 |
if diversity_level == "low":
|
752 |
-
return "
|
753 |
elif diversity_level == "medium":
|
754 |
-
return "
|
755 |
else: # high diversity
|
756 |
-
return "
|
757 |
elif significance_level == "medium":
|
758 |
if diversity_level == "low":
|
759 |
-
return "Quiet
|
760 |
elif diversity_level == "medium":
|
761 |
-
return "
|
762 |
else: # high diversity
|
763 |
-
return "
|
764 |
else: # low significance
|
765 |
if diversity_level == "low":
|
766 |
-
return "
|
767 |
elif diversity_level == "medium":
|
768 |
-
return "Scattered
|
769 |
else: # high diversity
|
770 |
-
return "Whispering
|
771 |
|
772 |
except Exception as e:
|
773 |
st.error(f"Error naming user group for topic {topic_id} and users {user_ids}: {e}")
|
774 |
-
return "
|
775 |
finally:
|
776 |
if local_con:
|
777 |
local_con.close()
|
|
|
281 |
def add_dummy_topic():
|
282 |
example_topic_id = "15736626"
|
283 |
example_topic_title = "New Civic Tech Initiative"
|
284 |
+
example_topic_description = "Seeker, your mission is to assess the true sentiment regarding the Emperor's new 'Civic Tech' initiative. While officially presented as a means for streamlined governance, enhanced citizen engagement, and a more user-friendly experience, the Emperor requires a candid report on public perception. Gather intelligence on whether citizens view this as a path to order or harbor suspicions of a darker purpose. Report their unfiltered opinions."
|
285 |
example_comments = [
|
286 |
"Finally! A system to track rebel scum more efficiently. This will be a glorious day for the Empire!",
|
287 |
"This is clearly a data-mining operation. They're going to use it to crush the Rebellion. We need to sabotage it!",
|
|
|
664 |
def name_user_group(user_ids, topic_id):
|
665 |
"""
|
666 |
Generates a descriptive name and description for a group of users within a
|
667 |
+
specific topic based on their participation level and voting diversity,
|
668 |
+
themed around a seeker's journey through different settlements.
|
669 |
|
670 |
Args:
|
671 |
user_ids (list[str]): A list of user IDs belonging to the group.
|
|
|
673 |
|
674 |
Returns:
|
675 |
tuple[str, str]: A tuple containing the name and description for the group.
|
676 |
+
Returns ("The Silent Threshold", "You sense a presence, but no clear voices emerge from this place.")
|
677 |
+
or ("The Silent Valley", "A valley where the inhabitants reside, but their voices are silent on this matter.")
|
678 |
+
or ("The Untrodden Path", "This path has not yet been explored by any travelers.")
|
679 |
+
or ("The Shrouded Keep", "A place hidden by mystery and uncertainty.")
|
680 |
in edge cases or on error.
|
681 |
"""
|
682 |
+
# Handle empty user list - implies no specific group is being considered, but not necessarily an empty world
|
683 |
if not user_ids:
|
684 |
+
return "The Silent Threshold", "You sense a presence, but no clear voices emerge from this place."
|
685 |
|
686 |
local_con = None
|
687 |
try:
|
|
|
713 |
group_voters_count = group_voters_result[0] if group_voters_result else 0
|
714 |
|
715 |
# Handle case where no one in the group has voted on this topic
|
716 |
+
# The group members exist, but are silent on this specific matter
|
717 |
if group_voters_count == 0:
|
718 |
+
return "The Silent Valley", "A valley where the inhabitants reside, but their voices are silent on this matter."
|
719 |
|
720 |
+
# Handle case where topic has no voters at all (the path hasn't been explored)
|
721 |
if total_voters_in_topic == 0:
|
722 |
# This case is unlikely if group_voters_count > 0, but for safety
|
723 |
+
return "The Untrodden Path", "This path has not yet been explored by any travelers."
|
724 |
|
725 |
|
726 |
# 3. Calculate significance (proportion of group voters among all topic voters)
|
|
|
748 |
elif diversity_score > DIV_LOW_THRESHOLD:
|
749 |
diversity_level = "medium"
|
750 |
|
751 |
+
# Assign names and descriptions based on levels (Themed for seeker quest)
|
752 |
if significance_level == "high":
|
753 |
if diversity_level == "low":
|
754 |
+
return "The Village of Unity", "A large settlement where the inhabitants share a common, strong belief."
|
755 |
elif diversity_level == "medium":
|
756 |
+
return "The Town of Common Ground", "A bustling town where most agree, though minor differences are acknowledged."
|
757 |
else: # high diversity
|
758 |
+
return "The City of Many Voices", "A major city where travelers from all paths meet and share a wide array of perspectives."
|
759 |
elif significance_level == "medium":
|
760 |
if diversity_level == "low":
|
761 |
+
return "The Hamlet of Quiet Accord", "A peaceful hamlet of moderate size where opinions align with little dissent."
|
762 |
elif diversity_level == "medium":
|
763 |
+
return "The Crossroads Inn", "An inn of moderate size where various travelers pause, sharing somewhat varied views."
|
764 |
else: # high diversity
|
765 |
+
return "The Debating Circle", "A gathering place of moderate size known for its spirited and diverse discussions."
|
766 |
else: # low significance
|
767 |
if diversity_level == "low":
|
768 |
+
return "The Like-Minded Few", "A small, isolated group whose thoughts resonate closely."
|
769 |
elif diversity_level == "medium":
|
770 |
+
return "The Scattered Camps", "A few scattered camps where different, quiet thoughts reside."
|
771 |
else: # high diversity
|
772 |
+
return "The Whispering Caves", "A small, hidden network of caves where many different ideas are shared in hushed tones."
|
773 |
|
774 |
except Exception as e:
|
775 |
st.error(f"Error naming user group for topic {topic_id} and users {user_ids}: {e}")
|
776 |
+
return "The Shrouded Keep", "A place hidden by mystery and uncertainty." # Default name and description on error
|
777 |
finally:
|
778 |
if local_con:
|
779 |
local_con.close()
|