kodexa 6.0.191__py3-none-any.whl → 6.0.192a0__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.
kodexa/model/model.py CHANGED
@@ -79,7 +79,7 @@ class Tag(Dict):
79
79
  """A string representing the value that was labelled in the node"""
80
80
  self.data: Optional[Any] = data
81
81
  """Any data object (JSON serializable) that you wish to associate with the label"""
82
- self.uuid: Optional[str] = uuid
82
+ self.uuid: Optional[str] = uuid or str(uuid.uuid4())
83
83
  """The UUID for this tag instance, this allows tags that are on different content nodes to be related through the same UUID"""
84
84
  self.confidence: Optional[float] = confidence
85
85
  """The confidence of the tag in a range of 0-1"""
@@ -1536,7 +1536,8 @@ class ContentNode(object):
1536
1536
  if not node:
1537
1537
  if (traverse == traverse.ALL or traverse == traverse.PARENT) and self.get_parent().get_parent():
1538
1538
  # can now traverse content-areas.. can add traversal of pages if needed, but don't think the scenario exists.
1539
- potential_next_node = self.get_parent().get_parent().get_children()[self.get_parent().index + 1].get_children()[0]
1539
+ potential_next_node = \
1540
+ self.get_parent().get_parent().get_children()[self.get_parent().index + 1].get_children()[0]
1540
1541
  if potential_next_node:
1541
1542
  return potential_next_node
1542
1543
  return node
@@ -1757,6 +1758,9 @@ class Document(object):
1757
1758
  self.classes: List[ContentClassification] = []
1758
1759
  """A list of the content classifications associated at the document level"""
1759
1760
 
1761
+ self.tag_instances: List[TagInstance] = []
1762
+ """A list of tag instances that contains a set of tag that has a set of nodes"""
1763
+
1760
1764
  # Start persistence layer
1761
1765
  from kodexa.model import PersistenceManager
1762
1766
 
@@ -1765,6 +1769,36 @@ class Document(object):
1765
1769
  delete_on_close=delete_on_close)
1766
1770
  self._persistence_layer.initialize()
1767
1771
 
1772
+ def add_tag_instance(self, tag_to_apply, node_list: List[ContentNode]):
1773
+ """
1774
+ This will create a group of a tag with indexes
1775
+ :param tag: name of the tag
1776
+ :param node_indices: contains the list of index of a node
1777
+ :return:
1778
+ """
1779
+ # For each node in the list create/update a feature
1780
+ tag = Tag()
1781
+ for node in node_list:
1782
+ node.add_feature('tag', tag_to_apply, Tag)
1783
+ # Tag Object
1784
+ tag_instance = TagInstance(tag, node_list)
1785
+ self.tag_instances.append(tag_instance)
1786
+
1787
+ def update_tag_instance(self, tag_uuid):
1788
+ for tag_instance in self.tag_instances:
1789
+ if tag_instance.tag.uuid == tag_uuid:
1790
+ # Update attributes of a Tag
1791
+ for node in tag_instance.nodes:
1792
+ node.get_tag(tag_instance.tag.value, tag_uuid=tag_instance.tag.uuid)
1793
+
1794
+ def get_tag_instance(self, tag):
1795
+ """
1796
+ Get the tag instance based on the tag itself
1797
+ :param tag: name of the tag
1798
+ :return: a list of tag instance
1799
+ """
1800
+ return [tag_instance for tag_instance in self.tag_instances if tag_instance.tag == tag]
1801
+
1768
1802
  def get_persistence(self):
1769
1803
  return self._persistence_layer
1770
1804
 
@@ -2271,6 +2305,15 @@ class Document(object):
2271
2305
  return self.labels
2272
2306
 
2273
2307
 
2308
+ class TagInstance:
2309
+ def __init__(self, tag: Tag, nodes):
2310
+ self.tag = tag
2311
+ self.nodes = nodes
2312
+
2313
+ def add_node(self, nodes: List[ContentNode]):
2314
+ self.nodes.extend(nodes)
2315
+
2316
+
2274
2317
  class ContentObjectReference:
2275
2318
  """ """
2276
2319
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kodexa
3
- Version: 6.0.191
3
+ Version: 6.0.192a0
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -5,7 +5,7 @@ kodexa/connectors/__init__.py,sha256=WCUEzFGjHcgPAMFIKLaRTXAkGHx3vUCD8APMhOrNNgM
5
5
  kodexa/connectors/connectors.py,sha256=25-TffyGDjxHyp9ITug0qgr1nhqMAekmV5NVvbPGs7o,7722
6
6
  kodexa/model/__init__.py,sha256=DyCgkJU7rOfd4SMvPRLaPdklCNlkqCRRWiVPwjYn2GE,720
7
7
  kodexa/model/base.py,sha256=6IraEK3RomjPgFpPYkxjuLUriF958AusgJO21Dcopeg,753
8
- kodexa/model/model.py,sha256=A9v5CRLe-Y28tj0C-oe8L1Gvu3m6bYfPvQQK89tCFzw,88524
8
+ kodexa/model/model.py,sha256=-UTEHt3hDLGgvVqiJ860m2O907gntTZgOtcwusYHXtY,90090
9
9
  kodexa/model/objects.py,sha256=c58_U0k5wQdha7zcV3oEO_aHlq1Jfh72kzK_6EapZZE,114121
10
10
  kodexa/model/persistence.py,sha256=rRBY_onLcSTFlZZmitU8_FLffP7elDHhcmF8yYT94HE,37655
11
11
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
@@ -34,7 +34,7 @@ kodexa/testing/test_components.py,sha256=i_9M6-bfUBdR1uYAzZZzWiW0M1DGKzE5mkNuHq4
34
34
  kodexa/testing/test_utils.py,sha256=HXM3S5FDzarzS6R7jkOHps6d6Ox2UtNqymoK6VCw8Zg,13596
35
35
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
36
36
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
- kodexa-6.0.191.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
38
- kodexa-6.0.191.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
39
- kodexa-6.0.191.dist-info/METADATA,sha256=pq838LuXkKiXifUhEm-OD-rGXtz8SPsm6Q5ZXE5ctSM,3602
40
- kodexa-6.0.191.dist-info/RECORD,,
37
+ kodexa-6.0.192a0.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
38
+ kodexa-6.0.192a0.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
39
+ kodexa-6.0.192a0.dist-info/METADATA,sha256=dwQ5QImPCW7E4eUbUxBDTVALmn6QgE0-89uKN28X6WQ,3604
40
+ kodexa-6.0.192a0.dist-info/RECORD,,