struggle-annotator 0.2.5__tar.gz → 0.3.2__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,29 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: struggle-annotator
3
- Version: 0.2.5
3
+ Version: 0.3.2
4
4
  Summary: Streamlit custom component for interactive NER-style text annotation
5
- License: MIT License
6
-
7
- Copyright (c) 2026 Patrick
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy
10
- of this software and associated documentation files (the "Software"), to deal
11
- in the Software without restriction, including without limitation the rights
12
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- copies of the Software, and to permit persons to whom the Software is
14
- furnished to do so, subject to the following conditions:
15
-
16
- The above copyright notice and this permission notice shall be included in all
17
- copies or substantial portions of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
- SOFTWARE.
26
-
5
+ License-Expression: MIT
27
6
  Requires-Python: >=3.10
28
7
  Description-Content-Type: text/markdown
29
8
  License-File: LICENSE
@@ -4,11 +4,12 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "struggle-annotator"
7
- version = "0.2.5"
7
+ version = "0.3.2"
8
8
  description = "Streamlit custom component for interactive NER-style text annotation"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
- license = { file = "LICENSE" }
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
12
13
  dependencies = ["streamlit>=1.28"]
13
14
 
14
15
  [project.optional-dependencies]
@@ -18,7 +18,14 @@ else:
18
18
  _component_func = components.declare_component("txt_annotator", path=_build_dir)
19
19
 
20
20
 
21
- def txt_annotator(text: str, label_dict: dict, key: str | None = None) -> dict:
21
+ def txt_annotator(
22
+ text: str,
23
+ label_dict: dict,
24
+ spacing: float = 1.9,
25
+ label_position: str = "top",
26
+ auto_expand: bool = True,
27
+ key: str | None = None,
28
+ ) -> dict:
22
29
  """Interactive NER-style text annotation component.
23
30
 
24
31
  Parameters
@@ -29,6 +36,13 @@ def txt_annotator(text: str, label_dict: dict, key: str | None = None) -> dict:
29
36
  Entity definitions. Keys are label names; values must contain ``color``
30
37
  (any valid CSS color) and optionally ``annotation`` (list of
31
38
  ``{"start": int, "end": int, "value": str}`` dicts).
39
+ spacing:
40
+ Initial line-height of the text area (1.2 – 5.0). Default ``1.9``.
41
+ label_position:
42
+ Where to render the entity buttons — ``"top"``, ``"left"``, or ``"right"``.
43
+ Default ``"top"``.
44
+ auto_expand:
45
+ When ``True`` (default), selections are expanded to full word boundaries.
32
46
  key:
33
47
  Standard Streamlit component key — required when rendering multiple
34
48
  annotators on the same page.
@@ -39,6 +53,9 @@ def txt_annotator(text: str, label_dict: dict, key: str | None = None) -> dict:
39
53
  Updated ``label_dict`` with each entity's ``annotation`` list reflecting
40
54
  the current UI state. Annotations within each entity are sorted by ``start``.
41
55
  """
56
+ if label_position not in ("top", "left", "right"):
57
+ raise ValueError(f"label_position must be 'top', 'left', or 'right', got {label_position!r}")
58
+
42
59
  normalised = {
43
60
  label: {
44
61
  "color": cfg["color"],
@@ -46,5 +63,13 @@ def txt_annotator(text: str, label_dict: dict, key: str | None = None) -> dict:
46
63
  }
47
64
  for label, cfg in label_dict.items()
48
65
  }
49
- result = _component_func(text=text, label_dict=normalised, key=key, default=normalised)
66
+ result = _component_func(
67
+ text=text,
68
+ label_dict=normalised,
69
+ spacing=float(spacing),
70
+ label_position=label_position,
71
+ auto_expand=bool(auto_expand),
72
+ key=key,
73
+ default=normalised,
74
+ )
50
75
  return result if result is not None else normalised