dynamic-learning-model 3.0__tar.gz → 3.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: 3.0
3
+ Version: 3.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
@@ -17,6 +17,7 @@ Requires-Dist: spacy
17
17
  Requires-Dist: better_profanity
18
18
  Requires-Dist: word2number
19
19
  Requires-Dist: transformers
20
+ Requires-Dist: hf_xet
20
21
  Dynamic: author
21
22
  Dynamic: author-email
22
23
  Dynamic: classifier
@@ -28,6 +28,8 @@ class DLM:
28
28
  __refuse_to_respond = False # if profanity or all caps-lock frustration is detected, refuse to respond and suggest user to try again (bot respect)
29
29
  __model = None # BETA: bot automatically chooses between "compute" or "memory" model based on query type
30
30
  __hf_classifier = None # loading huggingface model to determine the query type for auto_mode
31
+ __successfully_computed = False # for when computation model was able to give an answer to a mathematical problem
32
+ __second_run = False # if the bot tried "memory" model first then decided to try "compute" model
31
33
 
32
34
  # personalized responses to let the user know that the bot doesn't know the answer
33
35
  __fallback_responses = [
@@ -180,7 +182,7 @@ class DLM:
180
182
  "divide", "divided by", "split", "shared equally",
181
183
  "per", "share", "shared", "equal parts", "equal groups",
182
184
  "ratio", "quotient", "for each", "out of",
183
- "for every", "into", "average", "/", "÷"
185
+ "for every", "into", "/", "÷"
184
186
  ],
185
187
  # convert
186
188
  "=": [
@@ -825,7 +827,7 @@ class DLM:
825
827
  "sum", "combined", "add up", "accumulate", "bring to", "rise by", "grow by", "earned", "in all", "in total",
826
828
  "difference", "deduct", "decrease by", "fell by", "drop by", "ate",
827
829
  "multiply", "times", "product", "received", "pick", "paid", "gave", "pay",
828
- "split", "shared equally", "equal parts", "equal groups", "ratio", "quotient", "average", "out of", "into"
830
+ "split", "shared equally", "equal parts", "equal groups", "ratio", "quotient", "out of", "into"
829
831
  ]
830
832
  filtered_query = filtered_query.title()
831
833
  doc = self.__nlp(filtered_query)
@@ -901,9 +903,7 @@ class DLM:
901
903
  # Direct match or lemma match
902
904
  if (kw.lower() == fq.lower()) or p1[0].lemma_ == p2[0].lemma_:
903
905
  keywords_mentioned.append(kw.title())
904
- if kw.lower() == "average":
905
- operands_mentioned.append("+")
906
- elif kw.lower() == "out of":
906
+ if kw.lower() == "out of":
907
907
  if word_num_surrounded:
908
908
  operands_mentioned.append(operand)
909
909
  found_operand = True
@@ -918,9 +918,7 @@ class DLM:
918
918
  if p1.vector_norm != 0 and p2.vector_norm != 0 and (
919
919
  p1.similarity(p2) > 0.80 and difflib.SequenceMatcher(None, kw, fq_l).ratio() > 0.40):
920
920
  keywords_mentioned.append(kw.title())
921
- if kw.lower() == "average":
922
- operands_mentioned.append("+")
923
- elif kw.lower() == "out of":
921
+ if kw.lower() == "out of":
924
922
  if word_num_surrounded:
925
923
  operands_mentioned.append(operand)
926
924
  found_operand = True
@@ -934,9 +932,7 @@ class DLM:
934
932
  # Fallback: high string similarity
935
933
  elif difflib.SequenceMatcher(None, kw, fq_l).ratio() > 0.80:
936
934
  keywords_mentioned.append(kw.title())
937
- if kw.lower() == "average":
938
- operands_mentioned.append("+")
939
- elif kw.lower() == "out of":
935
+ if kw.lower() == "out of":
940
936
  if word_num_surrounded:
941
937
  operands_mentioned.append(operand)
942
938
  found_operand = True
@@ -1031,14 +1027,16 @@ class DLM:
1031
1027
  operands_mentioned = [op for op in operands_mentioned if op != '=']
1032
1028
 
1033
1029
  # verify and possibly print thoughts
1034
- if (not is_geometric_query) and (any(not lst for lst in (num_mentioned, operands_mentioned)) or (
1035
- '=' not in operands_mentioned and num_mentioned.__len__() < 2)): # don't compute if parts are missing
1036
- print(
1037
- f"{self.__loading_animation('Hmm', 0.8) or '' if display_thought else ''}{'\033[34m'}It looks like some essential details are missing, so I can’t complete this calculation right now.{'\033[0m'}")
1038
- print(
1039
- f"\033[34mIf you are asking a geometric query, try including geometric identifiers like \"{'\", \"'.join(geo_types)}\" in your query.\033[0m")
1040
- print(
1041
- f"\033[34mCurrently, I can only compute those identifiers aforementioned, but more geometric features are coming soon!\033[0m")
1030
+ if (not is_geometric_query) and (any(not lst for lst in (num_mentioned, operands_mentioned)) or ('=' not in operands_mentioned and num_mentioned.__len__() < 2)): # don't compute if parts are missing
1031
+ if (not self.__second_run):
1032
+ print(
1033
+ f"{self.__loading_animation('Hmm', 0.8) or '' if display_thought else ''}{'\033[34m'}It looks like some essential details are missing, so I can’t complete this calculation right now.{'\033[0m'}")
1034
+ print(
1035
+ f"\033[34mIf you are asking a geometric query, try including geometric identifiers like \"{'\", \"'.join(geo_types)}\" in your query.\033[0m")
1036
+ print(
1037
+ f"\033[34mCurrently, I can only compute those identifiers aforementioned, but more geometric features are coming soon!\033[0m")
1038
+ else:
1039
+ self.__loading_animation('Hmm', 0.8)
1042
1040
  else: # else, the bot needs to explain what it has tokenized
1043
1041
  if display_thought:
1044
1042
  self.__loading_animation(
@@ -1094,6 +1092,7 @@ class DLM:
1094
1092
  # geometric problem
1095
1093
  if is_geometric_query:
1096
1094
  print(f"{'\033[34m'}Geometric Answer: {geometric_ans}{'\033[0m'}")
1095
+ self.__successfully_computed = True
1097
1096
  # conversion problem
1098
1097
  elif len(num_mentioned) == 1 and len(operands_mentioned) == 1:
1099
1098
  try:
@@ -1173,6 +1172,7 @@ class DLM:
1173
1172
  0.2)
1174
1173
  expr = f"{num_mentioned[0]} {source_key}(s) ==> {round(result, 2)} {target_key}(s)"
1175
1174
  print(f"{'\033[34m'}Conversion Answer: {expr} {'\033[0m'}")
1175
+ self.__successfully_computed = True
1176
1176
  else:
1177
1177
  print(f"{'\033[33m'}Could not identify both source and target units.{'\033[0m'}")
1178
1178
  except SyntaxError:
@@ -1198,10 +1198,12 @@ class DLM:
1198
1198
  expr = "(" + expr + ") / " + str(len(num_mentioned))
1199
1199
  result /= len(num_mentioned)
1200
1200
  print(f"{'\033[34m'}Arithmetic Answer: {expr} = {result}{'\033[0m'}")
1201
+ self.__successfully_computed = True
1201
1202
  except SyntaxError:
1202
1203
  print(
1203
1204
  f"{'\033[34mAh'}, something about that stumped me. I’ll need to learn more to handle it properly.{'\033[0m'}")
1204
1205
  else:
1206
+ self.__successfully_computed = False
1205
1207
  print(f"{'\033[34m'}{random.choice(self.__fallback_responses)}{'\033[0m'}")
1206
1208
  print(
1207
1209
  f"{'\033[34m'}However, while I was trying to understand the math, I ran into \"{'" and "'.join(keywords_mentioned)}\", which I use to connect keywords to math operations.{'\033[0m'}")
@@ -1278,7 +1280,7 @@ class DLM:
1278
1280
  print(
1279
1281
  f"{'\033[33m'}Furthermore, an in-depth vector analysis revealed a similarity percentage of {int(self.__nlp_similarity_value * 100)}%.{'\033[0m'}")
1280
1282
  print(
1281
- f"{self.__loading_animation("Hmm", 0.8) or ''}{'\033[33m'}I don't think I know the answer, so I am going to let the user know that.{'\033[0m'}")
1283
+ f"{self.__loading_animation("Hmm", 0.8) or ''}{'\033[33m'}I don't think I know the answer.{'\033[0m'}")
1282
1284
  self.__unsure_while_thinking = True
1283
1285
  else:
1284
1286
  self.__unsure_while_thinking = False
@@ -1686,4 +1688,12 @@ class DLM:
1686
1688
  self.__category) # learn this new question and answer pair and add to knowledgebase
1687
1689
  print("I learned something new!") # confirmation that it went through the whole process
1688
1690
  else: # only executes when in apply mode and bot cannot find the answer
1689
- print(f"{'\033[34m'}{random.choice(self.__fallback_responses)}{'\033[0m'}")
1691
+ self.__loading_animation(f"Let me put this into my computation model, maybe it was a mathematical query", 0.5)
1692
+ self.__model = "compute"
1693
+ self.__second_run = True
1694
+ self.__generate_thought(filtered_query, best_match_question, best_match_answer, highest_similarity,
1695
+ display_thought)
1696
+ if not self.__successfully_computed:
1697
+ print(f"{'\033[34m'}{random.choice(self.__fallback_responses)}{'\033[0m'}")
1698
+ self.__second_run = False
1699
+ self.__successfully_computed = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 3.0
3
+ Version: 3.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
@@ -17,6 +17,7 @@ Requires-Dist: spacy
17
17
  Requires-Dist: better_profanity
18
18
  Requires-Dist: word2number
19
19
  Requires-Dist: transformers
20
+ Requires-Dist: hf_xet
20
21
  Dynamic: author
21
22
  Dynamic: author-email
22
23
  Dynamic: classifier
@@ -3,3 +3,4 @@ spacy
3
3
  better_profanity
4
4
  word2number
5
5
  transformers
6
+ hf_xet
@@ -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='3.0',
8
+ version='3.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.',
@@ -19,7 +19,8 @@ setup(
19
19
  'spacy',
20
20
  'better_profanity',
21
21
  'word2number',
22
- 'transformers'
22
+ 'transformers',
23
+ 'hf_xet'
23
24
  ],
24
25
  classifiers=[
25
26
  'Programming Language :: Python :: 3',