ripple-down-rules 0.6.11__py3-none-any.whl → 0.6.13__py3-none-any.whl

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,4 +1,4 @@
1
- __version__ = "0.6.11"
1
+ __version__ = "0.6.13"
2
2
 
3
3
  import logging
4
4
  logger = logging.Logger("rdr")
@@ -161,7 +161,7 @@ class CallableExpression(SubclassJSONSerializer):
161
161
  else:
162
162
  raise ValueError("Either user_input or conclusion must be provided.")
163
163
  except Exception as e:
164
- raise ValueError(f"Error during evaluation: {e}")
164
+ raise ValueError(f"Error during evaluation: {e}, user_input: {self.user_input}")
165
165
 
166
166
  def combine_with(self, other: 'CallableExpression') -> 'CallableExpression':
167
167
  """
@@ -55,7 +55,7 @@ def general_rdr_classify(classifiers_dict: Dict[str, Union[ModuleType, RippleDow
55
55
  if attribute_name in new_conclusions:
56
56
  temp_case_query = CaseQuery(case_cp, attribute_name, rdr.conclusion_type, rdr.mutually_exclusive)
57
57
  update_case(temp_case_query, new_conclusions)
58
- if len(new_conclusions) == 0: #or (len(classifiers_dict) == 1 and all(rdr.mutually_exclusive for rdr in classifiers_dict.values())):
58
+ if len(new_conclusions) == 0 or len(classifiers_dict) == 1:
59
59
  break
60
60
  return conclusions
61
61
 
ripple_down_rules/rdr.py CHANGED
@@ -244,6 +244,7 @@ class RippleDownRules(SubclassJSONSerializer, ABC):
244
244
  expert: Optional[Expert] = None,
245
245
  update_existing_rules: bool = True,
246
246
  scenario: Optional[Callable] = None,
247
+ ask_now: Callable = lambda _: True,
247
248
  **kwargs) \
248
249
  -> Union[CallableExpression, Dict[str, CallableExpression]]:
249
250
  """
@@ -255,6 +256,7 @@ class RippleDownRules(SubclassJSONSerializer, ABC):
255
256
  :param update_existing_rules: Whether to update the existing same conclusion type rules that already gave
256
257
  some conclusions with the type required by the case query.
257
258
  :param scenario: The scenario at which the case was created, this is used to recreate the case if needed.
259
+ :ask_now: Whether to ask the expert for refinements or alternatives.
258
260
  :return: The category that the case belongs to.
259
261
  """
260
262
  if case_query is None:
@@ -271,7 +273,8 @@ class RippleDownRules(SubclassJSONSerializer, ABC):
271
273
  if case_query.target is None:
272
274
  case_query_cp = copy(case_query)
273
275
  conclusions = self.classify(case_query_cp.case, modify_case=True, case_query=case_query_cp)
274
- if self.should_i_ask_the_expert_for_a_target(conclusions, case_query_cp, update_existing_rules):
276
+ if (self.should_i_ask_the_expert_for_a_target(conclusions, case_query_cp, update_existing_rules)
277
+ and ask_now(case_query_cp.case)):
275
278
  expert.ask_for_conclusion(case_query_cp)
276
279
  case_query.target = case_query_cp.target
277
280
  if case_query.target is None:
@@ -33,7 +33,7 @@ class RDRDecorator:
33
33
  viewer: Optional[RDRCaseViewer] = None,
34
34
  package_name: Optional[str] = None,
35
35
  use_generated_classifier: bool = False,
36
- ask_now: Callable[[Any], bool] = lambda _: True,
36
+ ask_now: Callable[[Any, Any], bool] = lambda _,n: True,
37
37
  fitting_decorator: Optional[Callable] = None):
38
38
  """
39
39
  :param models_dir: The directory to save/load the RDR models.
@@ -94,13 +94,12 @@ class RDRDecorator:
94
94
  self.mutual_exclusive,
95
95
  case, case_dict,
96
96
  *args, **kwargs)
97
- # import pdb; pdb.set_trace()
98
97
  output = self.rdr.fit_case(case_query, expert=self.expert,
99
98
  update_existing_rules=self.update_existing_rules,
100
99
  viewer=self.viewer)
101
100
  return output
102
101
 
103
- if self.fit and not self.use_generated_classifier and self.ask_now(case_dict):
102
+ if self.fit and not self.use_generated_classifier and self.ask_now(case_dict, self.rdr.classify(case)):
104
103
  output = fit()
105
104
  else:
106
105
  if self.use_generated_classifier:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.6.11
3
+ Version: 0.6.13
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,13 +1,13 @@
1
- ripple_down_rules/__init__.py,sha256=HFiQNi2SqhUFClhVWHplxqW2PHHMj-43eIFUOxkn4as,100
1
+ ripple_down_rules/__init__.py,sha256=bHNnB4r5WRrjFPnOG4ulZdsLVSJHg3xarT5y9_woJ1A,100
2
2
  ripple_down_rules/experts.py,sha256=4-dMIVeMzFXCLYl_XBG_P7_Xs4sZih9-vZxCIPri6dA,12958
3
- ripple_down_rules/helpers.py,sha256=6njZZoxOa5MH47wky4w2llrGYFK_llfny7NQZCEejxU,4598
4
- ripple_down_rules/rdr.py,sha256=G0UWETaXddDOaNWTqfxPWkCSDiWkMEU_aBUWcsnJUN0,56147
5
- ripple_down_rules/rdr_decorators.py,sha256=cqfLaIDIyCjlR3tsIgOWJDdDsDk1nA1Atx-vlKFaIxY,10646
3
+ ripple_down_rules/helpers.py,sha256=X-pYuCsmuNraUFcIL450AsaOdGvGjotNPgSx8yu3NMg,4525
4
+ ripple_down_rules/rdr.py,sha256=I6NRZuXR_1lyWOHkN34HiLA-7dg-OLWEnHodKVjYTQI,56331
5
+ ripple_down_rules/rdr_decorators.py,sha256=SZ2ivGtT_2xuoGlTE9PtjqdC02AqZXkLh-MhgBBPcfw,10632
6
6
  ripple_down_rules/rules.py,sha256=Dk4yGCy5oV10mOv5rRLcmtIu9J60WBPol9b7ELFn6fY,21522
7
7
  ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
8
8
  ripple_down_rules/utils.py,sha256=vFoz5HcRgkf7_s-zdWSg54xI9PCMcdDzcdFGdas7KBA,62350
9
9
  ripple_down_rules/datastructures/__init__.py,sha256=V2aNgf5C96Y5-IGghra3n9uiefpoIm_QdT7cc_C8cxQ,111
10
- ripple_down_rules/datastructures/callable_expression.py,sha256=YHlEYc9Ye_4gYAqqj_TyCB363WpZ8lXH2LLRl1CCGe8,12934
10
+ ripple_down_rules/datastructures/callable_expression.py,sha256=pslqv9igc7d6s1TCKdJSfIdU98_L1BPKNmfLVlGdGHs,12965
11
11
  ripple_down_rules/datastructures/case.py,sha256=PJ7_-AdxYic6BO5z816piFODj6nU5J6Jt1YzTFH-dds,15510
12
12
  ripple_down_rules/datastructures/dataclasses.py,sha256=D-nrVEW_27njmDGkyiHRnq5lmqEdO8RHKnLb1mdnwrA,11054
13
13
  ripple_down_rules/datastructures/enums.py,sha256=ce7tqS0otfSTNAOwsnXlhsvIn4iW_Y_N3TNebF3YoZs,5700
@@ -17,8 +17,8 @@ ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=yp-F8YRWGhj1PLB3
17
17
  ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
18
18
  ripple_down_rules/user_interface/prompt.py,sha256=JceEUGYsd0lIvd-v2y3D3swoo96_C0lxfp3CxM7Vfts,8900
19
19
  ripple_down_rules/user_interface/template_file_creator.py,sha256=kwBbFLyN6Yx2NTIHPSwOoytWgbJDYhgrUOVFw_jkDQ4,13522
20
- ripple_down_rules-0.6.11.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
- ripple_down_rules-0.6.11.dist-info/METADATA,sha256=1pKWXY6fCKqe6fFgW_3fTrqh-hI2rODPa53cnU4K1RQ,48214
22
- ripple_down_rules-0.6.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- ripple_down_rules-0.6.11.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
- ripple_down_rules-0.6.11.dist-info/RECORD,,
20
+ ripple_down_rules-0.6.13.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
+ ripple_down_rules-0.6.13.dist-info/METADATA,sha256=paDmKM4LPfXdduNun6UH8pEn7XgdnWHuyY_Xi4bpDt8,48214
22
+ ripple_down_rules-0.6.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ ripple_down_rules-0.6.13.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
+ ripple_down_rules-0.6.13.dist-info/RECORD,,