dynamic-learning-model 2.0__tar.gz → 2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 2.0
3
+ Version: 2.1
4
4
  Summary: A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.
5
5
  Home-page: https://github.com/VigneshT24/Dynamic_Learning_Model
6
6
  Author: Vignesh Thondikulam
@@ -9,7 +9,7 @@ License: MIT
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: License :: OSI Approved :: MIT License
12
- Requires-Python: >=3.7
12
+ Requires-Python: >=3.12
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: nltk
@@ -23,7 +23,8 @@ class DLM:
23
23
  __unsure_while_thinking = False # if uncertain while thinking, then it will let the user know that
24
24
  __nlp_similarity_value = None # saves the similarity value by doing SpaCy calculation (for debugging)
25
25
  __special_stripped_query = None # saves query without any special words for reduced interference while vector calculating
26
- __nltk_names = set(name.lower() for name in names.words())
26
+ __nltk_names = set(name.lower() for name in names.words()) # list of name corpus to be identified in complex word problems
27
+ __refuse_to_respond = False # if profanity or all caps-lock frustration is detected, refuse to respond and suggest user to try again (bot respect)
27
28
 
28
29
  # personalized responses to let the user know that the bot doesn't know the answer
29
30
  __fallback_responses = [
@@ -334,6 +335,19 @@ class DLM:
334
335
  "quarter": 0.25, "quarters": 0.25
335
336
  }
336
337
 
338
+ # Response for when user uses profanity and all caps, indicating extreme anger
339
+ __refuse_to_respond_statements = [
340
+ "I understand you may be upset. However, I can’t respond to messages expressed in anger. Please rephrase calmly so I can assist you.",
341
+ "Your message seems written in frustration. For a constructive exchange, I need you to restate it respectfully.",
342
+ "I want to help, but I won’t respond to hostile language. Please rewrite your query in a calmer tone.",
343
+ "I can see this might be frustrating. I can’t respond while the message is written in anger, but if you rephrase, I’ll gladly help.",
344
+ "I know emotions can run high, but I need a calmer phrasing to continue. Please try rewording your question.",
345
+ "It sounds like you’re upset. Let’s take a step back — rephrase your question respectfully and I’ll do my best to answer.",
346
+ "Looks like the tone came across strongly. Please rephrase in a calmer way so I can give you the best answer.",
347
+ "I can’t respond to messages phrased in anger. Try again in a clearer, more respectful tone, and I’ll assist right away.",
348
+ "Let’s reset. Rephrase your question without the frustration, and I’ll be able to help you effectively."
349
+ ]
350
+
337
351
  def __init__(self, mode, db_filename="dlm_database.db"): # initializes SQL database & SpaCy NLP
338
352
  """
339
353
  Initialize the Dynamic-Learning Model (DLM) chatbot.
@@ -585,8 +599,8 @@ class DLM:
585
599
  Behavior:
586
600
  - Detects aggressive language using profanity filtering.
587
601
  - Analyzes punctuation and casing to infer emotional tone such as:
588
- - 'angry aggressive' for profane content
589
- - 'angry frustrated' for all-uppercase text
602
+ - 'angry aggressive' for profane content - refuse to respond
603
+ - 'angry frustrated' for all-uppercase text - refuse to respond
590
604
  - 'angry confused' for combined "?" and "!"
591
605
  - 'angry excited' for "!" only
592
606
  - 'confused unclear' for "?" only
@@ -594,20 +608,24 @@ class DLM:
594
608
  - Stores the result in self.__tone as a string label.
595
609
  """
596
610
  is_profane = profanity.contains_profanity(orig_input)
597
- if is_profane:
598
- self.__tone = "angry aggressive"
599
- elif orig_input == orig_input.upper():
600
- self.__tone = "angry frustrated"
601
- elif orig_input.__contains__("?") and orig_input.__contains__("!"):
602
- self.__tone = "angry confused"
603
- elif orig_input.__contains__("!"):
604
- self.__tone = "angry excited"
605
- elif orig_input.__contains__("?"):
606
- self.__tone = "confused unclear"
607
- elif orig_input.__contains__("...") or orig_input.__contains__(".."):
608
- self.__tone = "doubtful uncertain"
611
+ if is_profane and orig_input == orig_input.upper(): # too inappropriate to respond
612
+ self.__refuse_to_respond = True
609
613
  else:
610
- self.__tone = ""
614
+ self.__refuse_to_respond = False
615
+ if is_profane:
616
+ self.__tone = "angry aggressive"
617
+ elif orig_input == orig_input.upper():
618
+ self.__tone = "angry frustrated"
619
+ elif orig_input.__contains__("?") and orig_input.__contains__("!"):
620
+ self.__tone = "angry confused"
621
+ elif orig_input.__contains__("!"):
622
+ self.__tone = "angry excited"
623
+ elif orig_input.__contains__("?"):
624
+ self.__tone = "confused unclear"
625
+ elif orig_input.__contains__("...") or orig_input.__contains__(".."):
626
+ self.__tone = "doubtful uncertain"
627
+ else:
628
+ self.__tone = ""
611
629
 
612
630
  def __geometric_calculation(self, filtered_query, display_thought): # returns float result or None
613
631
  """
@@ -1551,6 +1569,13 @@ class DLM:
1551
1569
  self.__query = input("Empty input is unacceptable. Please enter something: ")
1552
1570
 
1553
1571
  self.__set_sentiment_tone(self.__query) # sets global variable sentiment tone
1572
+ while self.__refuse_to_respond:
1573
+ print()
1574
+ self.__query = input(random.choice(self.__refuse_to_respond_statements) + "\nTry again: ")
1575
+ while self.__query is None or self.__query == "":
1576
+ self.__query = input("Empty input is unacceptable. Please enter something: ")
1577
+ self.__set_sentiment_tone(self.__query)
1578
+
1554
1579
 
1555
1580
  # storing the user-query (filtered, lower-case, no punctuation)
1556
1581
  if self.__mode == "compute":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 2.0
3
+ Version: 2.1
4
4
  Summary: A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.
5
5
  Home-page: https://github.com/VigneshT24/Dynamic_Learning_Model
6
6
  Author: Vignesh Thondikulam
@@ -9,7 +9,7 @@ License: MIT
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: License :: OSI Approved :: MIT License
12
- Requires-Python: >=3.7
12
+ Requires-Python: >=3.12
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: nltk
@@ -5,7 +5,7 @@ with open('README.md', 'r', encoding='utf-8') as f:
5
5
 
6
6
  setup(
7
7
  name='dynamic-learning-model',
8
- version='2.0',
8
+ version='2.1',
9
9
  author='Vignesh Thondikulam',
10
10
  author_email='vignesh.tho2006@gmail.com',
11
11
  description='A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.',
@@ -25,6 +25,6 @@ setup(
25
25
  'Operating System :: OS Independent',
26
26
  'License :: OSI Approved :: MIT License',
27
27
  ],
28
- python_requires='>=3.7',
28
+ python_requires='>=3.12',
29
29
  license='MIT',
30
30
  )