sayou-wrapper 0.1.2__tar.gz → 0.1.3__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: sayou-wrapper
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Wrapper components for the Sayou Data Platform
5
5
  Project-URL: Homepage, https://www.sayouzone.com/
6
6
  Project-URL: Documentation, https://sayouzone.github.io/sayou-fabric/
@@ -7,7 +7,7 @@ build-backend = "hatchling.build"
7
7
  # -----------------
8
8
  [project]
9
9
  name = "sayou-wrapper"
10
- version = "0.1.2"
10
+ version = "0.1.3"
11
11
  authors = [
12
12
  { name = "Sayouzone", email = "contact@sayouzone.com" },
13
13
  ]
@@ -1,6 +1,7 @@
1
1
  from typing import Any, List, Union
2
2
 
3
3
  from ..core.schemas import SayouNode, WrapperOutput
4
+ from ..core.vocabulary import SayouAttribute, SayouClass, SayouPredicate
4
5
  from ..interfaces.base_adapter import BaseAdapter
5
6
 
6
7
 
@@ -38,23 +39,23 @@ class DocumentChunkAdapter(BaseAdapter):
38
39
  is_header = meta.get("is_header", False)
39
40
 
40
41
  if is_header:
41
- node_class = "sayou:Topic"
42
+ node_class = SayouClass.TOPIC
42
43
  elif sem_type == "table":
43
- node_class = "sayou:Table"
44
+ node_class = SayouClass.TABLE
44
45
  elif sem_type == "code_block":
45
- node_class = "sayou:Code"
46
+ node_class = SayouClass.CODE
46
47
  elif sem_type == "list_item":
47
- node_class = "sayou:ListItem"
48
+ node_class = SayouClass.LIST_ITEM
48
49
  else:
49
- node_class = "sayou:TextFragment"
50
+ node_class = SayouClass.TEXT
50
51
 
51
- # 3. Attributes Mapping
52
+ # [Refactored] Attributes using Constants
52
53
  attributes = {
53
- "schema:text": content,
54
- "sayou:semanticType": sem_type,
55
- "sayou:pageIndex": meta.get("page_num"),
56
- "sayou:partIndex": meta.get("part_index"),
57
- "sayou:source": meta.get("source"),
54
+ SayouAttribute.TEXT: content,
55
+ SayouAttribute.SEMANTIC_TYPE: sem_type,
56
+ SayouAttribute.PAGE_INDEX: meta.get("page_num"),
57
+ SayouAttribute.PART_INDEX: meta.get("part_index"),
58
+ SayouAttribute.SOURCE: meta.get("source"),
58
59
  }
59
60
 
60
61
  # 4. Relationships Mapping
@@ -62,7 +63,7 @@ class DocumentChunkAdapter(BaseAdapter):
62
63
  parent_id = meta.get("parent_id")
63
64
  if parent_id:
64
65
  std_parent_id = f"sayou:doc:{parent_id}"
65
- relationships["sayou:hasParent"] = [std_parent_id]
66
+ relationships[SayouPredicate.HAS_PARENT] = [std_parent_id]
66
67
 
67
68
  # 5. Create Node
68
69
  node = SayouNode(
@@ -0,0 +1,26 @@
1
+ class SayouClass:
2
+ """Ontology Class Definitions"""
3
+
4
+ TOPIC = "sayou:Topic"
5
+ TABLE = "sayou:Table"
6
+ CODE = "sayou:Code"
7
+ TEXT = "sayou:TextFragment"
8
+ LIST_ITEM = "sayou:ListItem"
9
+
10
+
11
+ class SayouPredicate:
12
+ """Relationship Definitions"""
13
+
14
+ HAS_PARENT = "sayou:hasParent"
15
+ NEXT = "sayou:next"
16
+ MENTIONS = "sayou:mentions"
17
+
18
+
19
+ class SayouAttribute:
20
+ """Property Keys"""
21
+
22
+ TEXT = "schema:text"
23
+ SEMANTIC_TYPE = "sayou:semanticType"
24
+ PAGE_INDEX = "sayou:pageIndex"
25
+ PART_INDEX = "sayou:partIndex"
26
+ SOURCE = "sayou:source"
File without changes
File without changes