dynamic-learning-model 1.3__tar.gz → 1.4__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: 1.3
3
+ Version: 1.4
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
@@ -40,7 +40,7 @@ Key capabilities include:
40
40
 
41
41
  * FAQ Handling: Learns and responds to frequently asked questions based on the knowledge it has been trained on.
42
42
 
43
- * Chain-of-Thought (CoT) Reasoning: Performs clear, step-by-step logic to solve non-ambiguous arithmetic and unit conversion problems.
43
+ * Chain-of-Thought (CoT) Reasoning: Performs clear, step-by-step logic to solve non-ambiguous arithmetic, geometric, and unit conversion problems.
44
44
 
45
45
  * Custom Knowledge Integration: DLM is fully extensible. You can initialize it with an empty SQL database and train it with your domain-specific knowledge.
46
46
 
@@ -10,7 +10,7 @@ Key capabilities include:
10
10
 
11
11
  * FAQ Handling: Learns and responds to frequently asked questions based on the knowledge it has been trained on.
12
12
 
13
- * Chain-of-Thought (CoT) Reasoning: Performs clear, step-by-step logic to solve non-ambiguous arithmetic and unit conversion problems.
13
+ * Chain-of-Thought (CoT) Reasoning: Performs clear, step-by-step logic to solve non-ambiguous arithmetic, geometric, and unit conversion problems.
14
14
 
15
15
  * Custom Knowledge Integration: DLM is fully extensible. You can initialize it with an empty SQL database and train it with your domain-specific knowledge.
16
16
 
@@ -216,10 +216,11 @@ class DLM:
216
216
 
217
217
  # to solve geometric problems (advanced CoT)
218
218
  __geometric_calculation_identifiers = {
219
+ # 2D Shapes – Area
219
220
  "triangle": {
220
- "keywords": ["area", "triangle"], # keyword that will be mentioned while in CoT
221
- "params": ["base", "height"], # helps with formula
222
- "formula": lambda d: 0.5 * d["base"] * d["height"] # formula to solve geometric problem
221
+ "keywords": ["area", "triangle"],
222
+ "params": ["base", "height"],
223
+ "formula": lambda d: 0.5 * d["base"] * d["height"]
223
224
  },
224
225
  "rectangle": {
225
226
  "keywords": ["area", "rectangle"],
@@ -244,7 +245,49 @@ class DLM:
244
245
  "circle": {
245
246
  "keywords": ["area", "circle"],
246
247
  "params": ["radius"],
247
- "formula": lambda d: (math.pow(d["radius"], 2)) * math.pi
248
+ "formula": lambda d: math.pi * math.pow(d["radius"], 2)
249
+ },
250
+ "ellipse": {
251
+ "keywords": ["area", "ellipse"],
252
+ "params": ["a", "b"],
253
+ "formula": lambda d: math.pi * d["a"] * d["b"]
254
+ },
255
+ "pentagon": {
256
+ "keywords": ["area", "pentagon"],
257
+ "params": ["side"],
258
+ "formula": lambda d: (1 / 4) * math.sqrt(5 * (5 + 2 * math.sqrt(5))) * math.pow(d["side"], 2)
259
+ },
260
+
261
+ # 3D Shapes – Volume
262
+ "cube": {
263
+ "keywords": ["volume", "cube"],
264
+ "params": ["side"],
265
+ "formula": lambda d: math.pow(d["side"], 3)
266
+ },
267
+ "rectangular prism": {
268
+ "keywords": ["volume", "rectangular prism"],
269
+ "params": ["length", "width", "height"],
270
+ "formula": lambda d: d["length"] * d["width"] * d["height"]
271
+ },
272
+ "cylinder": {
273
+ "keywords": ["volume", "cylinder"],
274
+ "params": ["radius", "height"],
275
+ "formula": lambda d: math.pi * math.pow(d["radius"], 2) * d["height"]
276
+ },
277
+ "cone": {
278
+ "keywords": ["volume", "cone"],
279
+ "params": ["radius", "height"],
280
+ "formula": lambda d: (1 / 3) * math.pi * math.pow(d["radius"], 2) * d["height"]
281
+ },
282
+ "sphere": {
283
+ "keywords": ["volume", "sphere"],
284
+ "params": ["radius"],
285
+ "formula": lambda d: (4 / 3) * math.pi * math.pow(d["radius"], 3)
286
+ },
287
+ "pyramid": {
288
+ "keywords": ["volume", "pyramid"],
289
+ "params": ["base_area", "height"],
290
+ "formula": lambda d: (1 / 3) * d["base_area"] * d["height"]
248
291
  }
249
292
  }
250
293
 
@@ -571,14 +614,14 @@ class DLM:
571
614
 
572
615
  def __geometric_calculation(self, filtered_query, display_thought):
573
616
  """
574
- Perform formula-related math and geometric problems that will be called inside perform_advanced_CoT
617
+ Perform geometric problems that will be called inside perform_advanced_CoT
575
618
 
576
619
  Parameters:
577
620
  filtered_query (str): user query that has been filtered to have mostly computational details
578
621
  display_thought (bool): Indicates whether the user wants to have the bot display its thought process or just give the answer
579
622
 
580
623
  Returns:
581
- float: The result after computing the formula calculation
624
+ float: The result after computing the geometric calculation
582
625
 
583
626
  Behavior:
584
627
  - Search through query to find specific keywords like 'area' or 'volume'
@@ -638,17 +681,41 @@ class DLM:
638
681
  other_values.append(float(token))
639
682
 
640
683
  # find the object name and what to compute about the object
641
- for token in lower_tokens:
684
+ bigrams = [" ".join([lower_tokens[i], lower_tokens[i + 1]]) for i in range(len(lower_tokens) - 1)]
685
+ end_check = False
686
+
687
+ # first check bi-grams
688
+ for phrase in bigrams:
642
689
  for obj in self.__geometric_calculation_identifiers:
643
- # remove common endings for better matching
644
690
  for ending in common_endings:
645
- if token.endswith(ending):
646
- token = token[: -len(ending)] # Remove the ending
691
+ if phrase[0].endswith(ending):
692
+ phrase = phrase[: -len(ending)]
647
693
  break
648
- is_similar = difflib.get_close_matches(token, [obj], n=1, cutoff=0.80)
694
+ is_similar = difflib.get_close_matches(phrase, [obj], n=1, cutoff=0.70)
649
695
  if is_similar and is_similar[0] == obj:
650
696
  object_intel.extend(self.__geometric_calculation_identifiers[obj]["keywords"])
651
-
697
+ end_check = True
698
+ break
699
+ if end_check:
700
+ break
701
+
702
+ # if no bi-gram match, check single words
703
+ if not end_check and not lower_tokens.__contains__("prism"):
704
+ for token in lower_tokens:
705
+ for obj in self.__geometric_calculation_identifiers:
706
+ for ending in common_endings:
707
+ if token.endswith(ending):
708
+ token = token[: -len(ending)]
709
+ break
710
+ is_similar = difflib.get_close_matches(token, [obj], n=1, cutoff=0.80)
711
+ if is_similar and is_similar[0] == obj:
712
+ object_intel.extend(self.__geometric_calculation_identifiers[obj]["keywords"])
713
+ end_check = True
714
+ break
715
+ if end_check:
716
+ break
717
+
718
+ # if allowed, display the inner thought process
652
719
  obj_name = object_intel[1]
653
720
  if display_thought:
654
721
  self.__loadingAnimation(f"It seems that the user wants to compute the {' of a '.join(object_intel)}", 0.5)
@@ -666,11 +733,12 @@ class DLM:
666
733
  params = self.__geometric_calculation_identifiers[obj_name]["params"]
667
734
 
668
735
  formula_inputs = {} # all data gathered to compute geometry
669
-
736
+
737
+ # gather and plug in values into the formula
670
738
  try:
671
739
  if "height" in params:
672
740
  formula_inputs["height"] = height_value
673
-
741
+
674
742
  value_idx = 0 # count how many values to be added in formula_inputs
675
743
  for param in params:
676
744
  if param == "height":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 1.3
3
+ Version: 1.4
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
@@ -40,7 +40,7 @@ Key capabilities include:
40
40
 
41
41
  * FAQ Handling: Learns and responds to frequently asked questions based on the knowledge it has been trained on.
42
42
 
43
- * Chain-of-Thought (CoT) Reasoning: Performs clear, step-by-step logic to solve non-ambiguous arithmetic and unit conversion problems.
43
+ * Chain-of-Thought (CoT) Reasoning: Performs clear, step-by-step logic to solve non-ambiguous arithmetic, geometric, and unit conversion problems.
44
44
 
45
45
  * Custom Knowledge Integration: DLM is fully extensible. You can initialize it with an empty SQL database and train it with your domain-specific knowledge.
46
46
 
@@ -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='1.3',
8
+ version='1.4',
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.',