From 83a3c7254c33effd06482651ea39a141024df5dc Mon Sep 17 00:00:00 2001 From: Daxton Caylor <164315771+daxcay@users.noreply.github.com> Date: Sat, 1 Mar 2025 10:54:50 +0530 Subject: [PATCH] Update DataSet_ConceptManager.py added a # to remove tags to all remove tags from everywhere in text in case someone needs it --- classes/DataSet_ConceptManager.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/classes/DataSet_ConceptManager.py b/classes/DataSet_ConceptManager.py index 9cf7e74..60e7225 100644 --- a/classes/DataSet_ConceptManager.py +++ b/classes/DataSet_ConceptManager.py @@ -42,21 +42,26 @@ def getWords(combined_texts, split): return joined_words + def remove_text(tags, combined_texts): + tags_list = [tag.strip() for tag in tags.split(',')] - text_pos_list = [text_pos.strip().split() - for text_pos in combined_texts.split(',')] + text_pos_list = [text_pos.strip().split() for text_pos in combined_texts.split(',')] for text_pos in text_pos_list: num_pos = len(text_pos) - 1 text = " ".join(text_pos[0:num_pos]) - if text in tags_list: - tags_list.remove(text) + pos_str = text_pos[num_pos] + + if pos_str == "#": # Remove all instances of the text + tags_list = [tag for tag in tags_list if tag != text] + else: + if text in tags_list: + tags_list.remove(text) # Remove only one instance new_tags = ', '.join(tags_list) return new_tags - class DataSet_ConceptManager: def __init__(self):