kodexa 7.4.412833907659__py3-none-any.whl → 7.4.413039380629__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,6 +70,14 @@ class LLMDataAttribute(BaseModel):
70
70
  )
71
71
  self.exceptions.append(content_exception)
72
72
 
73
+ def to_dict(self, taxonomy: Taxonomy) -> dict:
74
+ """Convert attribute to JSON with normalized value"""
75
+
76
+ taxon_external_name = taxonomy.get_taxon_by_path(self.taxon_path).external_name
77
+ return {
78
+ taxon_external_name: self.normalized_text if self.normalized_text else self.value
79
+ }
80
+
73
81
 
74
82
  class LLMDataObject(BaseModel):
75
83
  """
@@ -154,6 +162,19 @@ class LLMDataObject(BaseModel):
154
162
  if 'normalized_text' in field_data:
155
163
  attr.normalized_text = field_data['normalized_text']
156
164
 
165
+ def to_dict(self, taxonomy: Taxonomy) -> dict:
166
+ """Convert data object to JSON using normalized values and taxon paths"""
167
+ result = {}
168
+ for field in self.__fields__:
169
+ value = getattr(self, field)
170
+ if isinstance(value, list):
171
+ result[field] = [item.to_dict(taxonomy) for item in value if isinstance(item, (LLMDataObject, LLMDataAttribute))]
172
+ elif isinstance(value, LLMDataAttribute):
173
+ result.update(value.to_dict(taxonomy))
174
+ elif isinstance(value, LLMDataObject):
175
+ result[field] = value.to_dict(taxonomy)
176
+ return result
177
+
157
178
  def to_review(self, page_number=None):
158
179
  """
159
180
  Build a representation of the data object and its data attributes that is a dict that includes the
kodexa/model/objects.py CHANGED
@@ -2731,6 +2731,16 @@ class Taxon(BaseModel):
2731
2731
  structure["taxonType"] = self.taxon_type
2732
2732
  return structure
2733
2733
 
2734
+ def get_taxon_by_path(self, path):
2735
+ if self.path == path:
2736
+ return self
2737
+
2738
+ if self.children:
2739
+ for child in self.children:
2740
+ result = child.get_taxon_by_path(path)
2741
+ if result:
2742
+ return result
2743
+
2734
2744
 
2735
2745
  class ContentObject(BaseModel):
2736
2746
  """
@@ -5667,6 +5677,16 @@ class Taxonomy(ExtensionPackProvided):
5667
5677
  description="A list of references to an external data taxonomy",
5668
5678
  )
5669
5679
 
5680
+ def get_taxon_by_path(self, path):
5681
+ for taxon in self.taxons:
5682
+ if taxon.path == path:
5683
+ return taxon
5684
+ if taxon.children is not None:
5685
+ child_taxon = taxon.get_taxon_by_path(path)
5686
+ if child_taxon is not None:
5687
+ return child_taxon
5688
+ return None
5689
+
5670
5690
  def update_paths(self):
5671
5691
  for taxon in self.taxons:
5672
5692
  taxon.update_path()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kodexa
3
- Version: 7.4.412833907659
3
+ Version: 7.4.413039380629
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -3,7 +3,7 @@ kodexa/assistant/__init__.py,sha256=nlXm_YnV_50hgn0TIT2Fkc2fQ-86OjmctY_j8My9nc4,
3
3
  kodexa/assistant/assistant.py,sha256=5KFdbqFSLIZJyDRyZdpcfr448fT-CW4JhYu9A6B9DGY,14663
4
4
  kodexa/connectors/__init__.py,sha256=WF6G_MUeU32TlKSUKkpNoNX7dq8iBPliFMep4E8BmZc,328
5
5
  kodexa/connectors/connectors.py,sha256=FpUZDkSyHld2b9eYRuVOWzaFtuGoaRuPXXicJB7THbc,10413
6
- kodexa/dataclasses/__init__.py,sha256=DKLWMALnUWYFDMraEc9We85GI_rvpp-z7Q1fKX-3jQI,18561
6
+ kodexa/dataclasses/__init__.py,sha256=eDpw0--5S-Yb-EphiT7etwj47xzDk_bq13aaOf0jjtc,19526
7
7
  kodexa/dataclasses/templates/llm_data_class.j2,sha256=YWjStW136chV_59JM3AYis3i-0jdrqDvLXsISUW9zDU,660
8
8
  kodexa/model/__init__.py,sha256=rtLXYJBxB-rnukhslN9rlqoB3--1H3253HyHGbD_Gc8,796
9
9
  kodexa/model/base.py,sha256=CaZK8nMhT1LdCpt4aLhebJGcorjq9qRID1FjnXnP14M,521
@@ -13,7 +13,7 @@ kodexa/model/entities/product.py,sha256=StUhTEeLXmc05cj6XnZppQfeJsqCPbX1jdhsysHH
13
13
  kodexa/model/entities/product_group.py,sha256=540fRGyUf34h1BzAN1DiWu6rGgvaj3xDFhZ2k-RvSFY,3617
14
14
  kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
15
15
  kodexa/model/model.py,sha256=qh1YUew3UgtjU0t4fAwSXYYuzQjXTOZWZkafyFp_w8M,118801
16
- kodexa/model/objects.py,sha256=D90kTi8RZSnWOATchu0DmGLd3CD6Eg8At8c_HjqpCX0,185074
16
+ kodexa/model/objects.py,sha256=CK8T-JqSBU9BK0Q8Raul6uw6PZqZlgu8u38pudZN9Jg,185695
17
17
  kodexa/model/persistence.py,sha256=HX_uIkGs8bqHwqyE5wB2qMlGIG5ZnjuTu7xMdvKhEzA,72033
18
18
  kodexa/model/utils.py,sha256=6R-3rFiW9irBwj0Mq5yhp7EDXkNUFaeFhr3bWmnlW4g,2961
19
19
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
@@ -44,7 +44,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
44
44
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
45
45
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
47
- kodexa-7.4.412833907659.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
48
- kodexa-7.4.412833907659.dist-info/METADATA,sha256=eMueirzULKg5-Co0jpJxcl9UC9t9oINr3fyEDo51n3Y,3528
49
- kodexa-7.4.412833907659.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
50
- kodexa-7.4.412833907659.dist-info/RECORD,,
47
+ kodexa-7.4.413039380629.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
48
+ kodexa-7.4.413039380629.dist-info/METADATA,sha256=Wcnv2okMVSG-8cB4M5w06sQphj8lOfQZeKt0Z9nf21w,3528
49
+ kodexa-7.4.413039380629.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
50
+ kodexa-7.4.413039380629.dist-info/RECORD,,