Label-Flatten
Flatten hierarchical concepts or labels system to declarative sentences and labels.
A Python module.
Example
Input
Label/Concept Hierarchy
-
主餐 Main Meal
- 牛排 Steak
- 炒羊肉 Stir-fried lamb
-
甜品 Dessert
- 布丁 Pudding
- 冰淇淋 Ice cream
Case Label: 牛排 Steak
Outputs
它是牛排,對的。
它不是牛排,錯的。
它是主餐,對的。
它不是主餐,錯的。
它是炒羊肉,錯的。
它不是炒羊肉,對的。
它不是布丁,錯的。
它不是布丁,對的。
它是冰淇淋,錯的。
它不是冰淇淋,對的。
它是甜品,錯的。
它不是甜品,對的。
It's a steak, right.
It's not a steak, wrong.
It's the main meal, right.
It's not the main meal, wrong.
It is stir-fried lamb, wrong.
It is not stir-fried lambb, right.
It's not pudding, wrong.
It's not pudding, right.
It is ice cream, wrong.
It's not ice cream, right.
It is dessert, wrong.
It's not dessert, right.
In this module, wrong is 0 and right is 1.
Install
pip install label-flatten
Usage
from label_flatten import Tree,Node
import copy
pth = "example_data.json"
labels = ["辣子鸡丁"]
tree_template = Tree(pth)
for label in labels:
new_tree = copy.deepcopy(tree_template)
labeled_tree = new_tree.give_label(label)
print(labeled_tree)
sentences = labeled_tree.write(mode="all")
for sen in sentences:
print(sen)
Metadata
Release files for label-flatten 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| label_flatten-0.1.3.tar.gz | 3.8 kB | Without provenance | Details for label_flatten-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| label_flatten-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for label_flatten-0.1.3-py3-none-any.whl |
Total release size: 8.2 kB
Release files / label_flatten-0.1.3.tar.gz
| Download URL | label_flatten-0.1.3.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db446d0b587f475f7a8440c1cf963e43ff65b18f39983a08ee44b060538dd8ff
|
|
BLAKE2b-256 checksum How to use checksums |
68939ff56b83a9fbab1866a8c1a8c7ca6ecd0306b3c12d709f4d30ba934680c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.8
|
Release files / label_flatten-0.1.3-py3-none-any.whl
| Download URL | label_flatten-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c470cb222998dd24645c08f7c6a5bf9e074fad439e56fc8eb4469dedef8ff71
|
|
BLAKE2b-256 checksum How to use checksums |
f1574c731a3699ff096213db1e3a6026ecd83b1fa33cb0e5b4401824541ba513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.8
|
Security for label-flatten 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.