pubba 0.4.0__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.
pubba-0.4.0/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ node_modules
2
+ dist
3
+ .DS_Store
4
+ *.log
5
+ coverage
6
+ local/
7
+ __pycache__/
8
+ *.pyc
9
+ packages/python/dist/
10
+ packages/python/build/
11
+ *.egg-info/
pubba-0.4.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tharindu Athapaththu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
pubba-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: pubba
3
+ Version: 0.4.0
4
+ Summary: A small brain for showroom sites: related items with reasons, what-next from a visitor's trail, typo-tolerant matching and a headless guide, from a compiled pubba bundle.
5
+ Project-URL: Homepage, https://github.com/Tharindu127/pubba
6
+ Project-URL: Repository, https://github.com/Tharindu127/pubba
7
+ Project-URL: Issues, https://github.com/Tharindu127/pubba/issues
8
+ Author: Tharindu Athapaththu
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: explainable,fuzzy-search,guide,knowledge-graph,portfolio,recommendations,related-items,showroom
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+
20
+ # pubba for Python
21
+
22
+ The [pubba](https://github.com/Tharindu127/pubba) runtime in Python: load a
23
+ bundle compiled by `pubba compile` and answer related items with reasons, what
24
+ a visitor is likely to want next, typo-tolerant matching, a headless guide and
25
+ privacy-safe measurement events. No dependencies; Python 3.9+.
26
+
27
+ It gives the same answers as every other pubba runtime: it passes the shared
28
+ conformance suite (4,698 cases) exactly.
29
+
30
+ ```bash
31
+ pip install pubba
32
+ ```
33
+
34
+ ```python
35
+ from pubba import load_bundle, create_guide, create_trail
36
+
37
+ pubba = load_bundle(open("pubba.bundle.json").read())
38
+
39
+ pubba.match("flutr").entity.id # "tech:Flutter"
40
+ [s.text for s in pubba.next(["project:kiri-wallet"])]
41
+ # ["Kiri Merchant is built on the same stack as Kiri Wallet (Flutter, Dart).", ...]
42
+
43
+ guide = create_guide(pubba, trail=create_trail())
44
+ reply = guide.ask("anything like kiri walet?")
45
+ reply.kind, reply.text, reply.action # "similar", "Kiri Merchant is built on ...", {"type": "open", ...}
46
+ ```
47
+
48
+ The bundle comes from the content, compiled once with the npm package:
49
+
50
+ ```bash
51
+ npx pubba compile pubba.json --out pubba.bundle.json
52
+ ```
53
+
54
+ ## API
55
+
56
+ | | |
57
+ | --- | --- |
58
+ | `load_bundle(json, events=None)` | A `Pubba` from a bundle (a JSON string, bytes or dict) |
59
+ | `pubba.match(query)` | `MatchResult(intent, entity, match, similar, not_here)`; intent is `entity`, `similar` or `none` |
60
+ | `pubba.search(query, limit=10, types=None)` | Every entity a query could mean, best first |
61
+ | `pubba.next(trail, limit=3, exclude=(), accept=None)` | Predictions: `Suggestion(entity, score, reason, text)` |
62
+ | `pubba.related(id, kinds=None, limit=None)` | Neighbours, strongest first: `Related(entity, weight, link, reason, text)` |
63
+ | `pubba.autocomplete(typed, trail=(), limit=3)` | Type-ahead |
64
+ | `pubba.explain(reason, item)` | A reason as a sentence |
65
+ | `pubba.track.guide_opened() / guided_to(id, via) / reached(goal)` | Measurement moments, checked so no visitor text gets in |
66
+ | `create_guide(pubba, trail=, route=, chips=, nudge=NudgePolicy(), prefer=, accept=, fallback=, line=, templates=, now=)` | The headless navigator: `ask`, `chips`, `visited`, `follow`, `nudge`, `opened`, `reached` |
67
+ | `create_trail(max=24, storage=None, key=...)` | The visitor's trail; `storage` has `get_item` / `set_item` |
68
+ | `create_events(goals=None)`, `summarise(events)` | Events (dicts with the spec's field names), and one visit's funnel |
69
+
70
+ Reasons are dicts (`{"kind": "same-stack", "to": "project:kiri-wallet", "direction": "in", "via": ["Flutter", "Dart"]}`),
71
+ the same shape in every runtime. Behaviour is specified in the repository's
72
+ `spec/SPEC.md`.
73
+
74
+ ## Tests
75
+
76
+ ```bash
77
+ python -m unittest discover -s tests
78
+ ```
79
+
80
+ runs the shared conformance suite from the repository's `conformance/` folder.
81
+
82
+ MIT © Tharindu Athapaththu
pubba-0.4.0/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # pubba for Python
2
+
3
+ The [pubba](https://github.com/Tharindu127/pubba) runtime in Python: load a
4
+ bundle compiled by `pubba compile` and answer related items with reasons, what
5
+ a visitor is likely to want next, typo-tolerant matching, a headless guide and
6
+ privacy-safe measurement events. No dependencies; Python 3.9+.
7
+
8
+ It gives the same answers as every other pubba runtime: it passes the shared
9
+ conformance suite (4,698 cases) exactly.
10
+
11
+ ```bash
12
+ pip install pubba
13
+ ```
14
+
15
+ ```python
16
+ from pubba import load_bundle, create_guide, create_trail
17
+
18
+ pubba = load_bundle(open("pubba.bundle.json").read())
19
+
20
+ pubba.match("flutr").entity.id # "tech:Flutter"
21
+ [s.text for s in pubba.next(["project:kiri-wallet"])]
22
+ # ["Kiri Merchant is built on the same stack as Kiri Wallet (Flutter, Dart).", ...]
23
+
24
+ guide = create_guide(pubba, trail=create_trail())
25
+ reply = guide.ask("anything like kiri walet?")
26
+ reply.kind, reply.text, reply.action # "similar", "Kiri Merchant is built on ...", {"type": "open", ...}
27
+ ```
28
+
29
+ The bundle comes from the content, compiled once with the npm package:
30
+
31
+ ```bash
32
+ npx pubba compile pubba.json --out pubba.bundle.json
33
+ ```
34
+
35
+ ## API
36
+
37
+ | | |
38
+ | --- | --- |
39
+ | `load_bundle(json, events=None)` | A `Pubba` from a bundle (a JSON string, bytes or dict) |
40
+ | `pubba.match(query)` | `MatchResult(intent, entity, match, similar, not_here)`; intent is `entity`, `similar` or `none` |
41
+ | `pubba.search(query, limit=10, types=None)` | Every entity a query could mean, best first |
42
+ | `pubba.next(trail, limit=3, exclude=(), accept=None)` | Predictions: `Suggestion(entity, score, reason, text)` |
43
+ | `pubba.related(id, kinds=None, limit=None)` | Neighbours, strongest first: `Related(entity, weight, link, reason, text)` |
44
+ | `pubba.autocomplete(typed, trail=(), limit=3)` | Type-ahead |
45
+ | `pubba.explain(reason, item)` | A reason as a sentence |
46
+ | `pubba.track.guide_opened() / guided_to(id, via) / reached(goal)` | Measurement moments, checked so no visitor text gets in |
47
+ | `create_guide(pubba, trail=, route=, chips=, nudge=NudgePolicy(), prefer=, accept=, fallback=, line=, templates=, now=)` | The headless navigator: `ask`, `chips`, `visited`, `follow`, `nudge`, `opened`, `reached` |
48
+ | `create_trail(max=24, storage=None, key=...)` | The visitor's trail; `storage` has `get_item` / `set_item` |
49
+ | `create_events(goals=None)`, `summarise(events)` | Events (dicts with the spec's field names), and one visit's funnel |
50
+
51
+ Reasons are dicts (`{"kind": "same-stack", "to": "project:kiri-wallet", "direction": "in", "via": ["Flutter", "Dart"]}`),
52
+ the same shape in every runtime. Behaviour is specified in the repository's
53
+ `spec/SPEC.md`.
54
+
55
+ ## Tests
56
+
57
+ ```bash
58
+ python -m unittest discover -s tests
59
+ ```
60
+
61
+ runs the shared conformance suite from the repository's `conformance/` folder.
62
+
63
+ MIT © Tharindu Athapaththu
@@ -0,0 +1,24 @@
1
+ """pubba: a small brain for showroom sites, in Python.
2
+
3
+ Load a bundle compiled by `pubba compile` and answer: related items with
4
+ reasons, what next from a visitor's trail, typo-tolerant matching, a headless
5
+ guide, and privacy-safe measurement events. Same answers as every other pubba
6
+ runtime: the conformance suite holds them to it.
7
+ """
8
+
9
+ from .core import BUNDLE_FORMAT, Entity, Graph, Link, Match, MatchResult, Pubba, Related, Suggestion, graph_from_bundle, load_bundle, reason_from_link, render_reason
10
+ from .events import GUIDE_VIAS, Events, create_events, summarise
11
+ from .guide import DEFAULT_GUIDE_TEMPLATES, EntityChip, Guide, NudgePolicy, QuestionChip, Reply, create_guide
12
+ from .text import close_to, contains_name, edit_distance, has_phrase, normalize
13
+ from .trail import Trail, create_trail, section_step
14
+
15
+ __version__ = "0.4.0"
16
+
17
+ __all__ = [
18
+ "BUNDLE_FORMAT", "Entity", "Graph", "Link", "Match", "MatchResult", "Pubba", "Related", "Suggestion",
19
+ "graph_from_bundle", "load_bundle", "reason_from_link", "render_reason",
20
+ "GUIDE_VIAS", "Events", "create_events", "summarise",
21
+ "DEFAULT_GUIDE_TEMPLATES", "EntityChip", "Guide", "NudgePolicy", "QuestionChip", "Reply", "create_guide",
22
+ "close_to", "contains_name", "edit_distance", "has_phrase", "normalize",
23
+ "Trail", "create_trail", "section_step", "__version__",
24
+ ]