kodexa 6.1.15059972675__py3-none-any.whl → 6.1.15059982168__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 +43 -1
- {kodexa-6.1.15059972675.dist-info → kodexa-6.1.15059982168.dist-info}/METADATA +1 -1
- {kodexa-6.1.15059972675.dist-info → kodexa-6.1.15059982168.dist-info}/RECORD +5 -5
- {kodexa-6.1.15059972675.dist-info → kodexa-6.1.15059982168.dist-info}/LICENSE +0 -0
- {kodexa-6.1.15059972675.dist-info → kodexa-6.1.15059982168.dist-info}/WHEEL +0 -0
kodexa/model/model.py
CHANGED
@@ -82,7 +82,7 @@ class Tag(Dict):
|
|
82
82
|
"""A string representing the value that was labelled in the node"""
|
83
83
|
self.data: Optional[Any] = data
|
84
84
|
"""Any data object (JSON serializable) that you wish to associate with the label"""
|
85
|
-
self.uuid: Optional[str] = uuid
|
85
|
+
self.uuid: Optional[str] = uuid or str(uuid.uuid4())
|
86
86
|
"""The UUID for this tag instance, this allows tags that are on different content nodes to be related through the same UUID"""
|
87
87
|
self.confidence: Optional[float] = confidence
|
88
88
|
"""The confidence of the tag in a range of 0-1"""
|
@@ -1893,6 +1893,9 @@ class Document(object):
|
|
1893
1893
|
self.classes: List[ContentClassification] = []
|
1894
1894
|
"""A list of the content classifications associated at the document level"""
|
1895
1895
|
|
1896
|
+
self.tag_instances: List[TagInstance] = []
|
1897
|
+
"""A list of tag instances that contains a set of tag that has a set of nodes"""
|
1898
|
+
|
1896
1899
|
# Start persistence layer
|
1897
1900
|
from kodexa.model import PersistenceManager
|
1898
1901
|
|
@@ -1901,6 +1904,36 @@ class Document(object):
|
|
1901
1904
|
delete_on_close=delete_on_close)
|
1902
1905
|
self._persistence_layer.initialize()
|
1903
1906
|
|
1907
|
+
def add_tag_instance(self, tag_to_apply, node_list: List[ContentNode]):
|
1908
|
+
"""
|
1909
|
+
This will create a group of a tag with indexes
|
1910
|
+
:param tag: name of the tag
|
1911
|
+
:param node_indices: contains the list of index of a node
|
1912
|
+
:return:
|
1913
|
+
"""
|
1914
|
+
# For each node in the list create/update a feature
|
1915
|
+
tag = Tag()
|
1916
|
+
for node in node_list:
|
1917
|
+
node.add_feature('tag', tag_to_apply, Tag)
|
1918
|
+
# Tag Object
|
1919
|
+
tag_instance = TagInstance(tag, node_list)
|
1920
|
+
self.tag_instances.append(tag_instance)
|
1921
|
+
|
1922
|
+
def update_tag_instance(self, tag_uuid):
|
1923
|
+
for tag_instance in self.tag_instances:
|
1924
|
+
if tag_instance.tag.uuid == tag_uuid:
|
1925
|
+
# Update attributes of a Tag
|
1926
|
+
for node in tag_instance.nodes:
|
1927
|
+
node.get_tag(tag_instance.tag.value, tag_uuid=tag_instance.tag.uuid)
|
1928
|
+
|
1929
|
+
def get_tag_instance(self, tag):
|
1930
|
+
"""
|
1931
|
+
Get the tag instance based on the tag itself
|
1932
|
+
:param tag: name of the tag
|
1933
|
+
:return: a list of tag instance
|
1934
|
+
"""
|
1935
|
+
return [tag_instance for tag_instance in self.tag_instances if tag_instance.tag == tag]
|
1936
|
+
|
1904
1937
|
def get_persistence(self):
|
1905
1938
|
return self._persistence_layer
|
1906
1939
|
|
@@ -2444,6 +2477,15 @@ class Document(object):
|
|
2444
2477
|
return self._persistence_layer.get_all_tagged_nodes()
|
2445
2478
|
|
2446
2479
|
|
2480
|
+
class TagInstance:
|
2481
|
+
def __init__(self, tag: Tag, nodes):
|
2482
|
+
self.tag = tag
|
2483
|
+
self.nodes = nodes
|
2484
|
+
|
2485
|
+
def add_node(self, nodes: List[ContentNode]):
|
2486
|
+
self.nodes.extend(nodes)
|
2487
|
+
|
2488
|
+
|
2447
2489
|
class ContentObjectReference:
|
2448
2490
|
""" """
|
2449
2491
|
|
@@ -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=
|
8
|
+
kodexa/model/model.py,sha256=_fV5srWiX_iBQfdtlI7YjyGLJDTBuktysuF8VlO8Sv0,96183
|
9
9
|
kodexa/model/objects.py,sha256=bTj_COUUgvoergrNjFuYOK4fsMnZxZg7Ff4KN7KS3kg,116484
|
10
10
|
kodexa/model/persistence.py,sha256=ZWESzXS-jkGbp-NlPuQzQFxmZeRup7uNJjrUkGaYIOk,38334
|
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.1.
|
38
|
-
kodexa-6.1.
|
39
|
-
kodexa-6.1.
|
40
|
-
kodexa-6.1.
|
37
|
+
kodexa-6.1.15059982168.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
38
|
+
kodexa-6.1.15059982168.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
39
|
+
kodexa-6.1.15059982168.dist-info/METADATA,sha256=NY253QPacIXWUxRGyA1o1khVwhg4zEJBHrhy6-qqpuk,4158
|
40
|
+
kodexa-6.1.15059982168.dist-info/RECORD,,
|
File without changes
|
File without changes
|