From d5e1e36b669703c2b6bbc1926f6e6a0b8644d07c Mon Sep 17 00:00:00 2001 From: Lasse Studion Date: Thu, 30 May 2024 15:41:52 +0200 Subject: [PATCH] feat: Generate grouped arguments for electric vehicle speeches This commit adds code to generate grouped arguments for electric vehicle speeches. It retrieves speeches from the 'ev_speeches' collection and categorizes the arguments into negative, positive, and neutral sentiments. The grouped arguments are generated using the Ollama library and stored in separate lists. This enhancement improves the analysis of electric vehicle arguments and provides a clearer understanding of the sentiments expressed in the speeches. --- analyze_arguments.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 analyze_arguments.py diff --git a/analyze_arguments.py b/analyze_arguments.py new file mode 100644 index 0000000..6a9b6b1 --- /dev/null +++ b/analyze_arguments.py @@ -0,0 +1,37 @@ +from arango_class import ArangoDB +from ollama_class import Ollama +arango = ArangoDB() +db = arango.db + +ollama = Ollama() + +# Get all speeches from the 'ev_speeches' collection, containing the 400 speeches filtered out from the European Parliament +speeches = arango.all_ev_speeches() + +negative_arguments = [] +positive_arguments = [] +neutral_arguments = [] + +for speech in speeches: + if speech['llm_sentiment'] == 'negative': + negative_arguments.extend(speech['llm_arguments']) + elif speech['llm_sentiment'] == 'positive': + positive_arguments.extend(speech['llm_arguments']) + else: + neutral_arguments.extend(speech['llm_arguments']) + +negative_arguments = list(set(negative_arguments)) +positive_arguments = list(set(positive_arguments)) +neutral_arguments = list(set(neutral_arguments)) + + +for sentiment, arguments in zip(['negative', 'positive', 'neutral'], [negative_arguments, positive_arguments, neutral_arguments]): + prompt = f'''Below is a list of arguments related to electric vehicles. They are mostly {sentiment} towards electric vehicles. + \n{negative_arguments}\n + What arguments are there? Give me a list where you group the arguments into categories. + Answer ONLY with the grouped arguments, no greeting or explanation. Keep to the information in the list above. + ''' + grouped_arguments = ollama.generate(prompt=prompt) + print(sentiment.upper()) + print(grouped_arguments) + print('-'*30) \ No newline at end of file