Contextual19 Python Interpreter
This module provides you 2 classes to work with Ctx19.
ctx19.Contextual19Parser
This is just regular parser that takes rules in object representation.
Initialization
To initialize this class, just call it and take there rules in object representation:
from ctx19 import Contextual19Parser
data = [
{
"if": ...,
"then": ...
},
...
]
parser = Contextual19Parser(data)
Data you passed will be stored in parser.data.
methods
-
apply(sentence: list) -> list
This method apply rules, stored inself.datato the sentence you passed.
sentenceis the list of dictionaries which represents tokens with their properties. It can look like this:[ { "tense": "past", "gender": "neutral", "some_other_stuff": "other_value" }, { "tense": "future", "voice": "active", "another_property": "another_value" } ]
If some property will be missing while rule applying then it will be skipped.
-
save(filepath: str) -> void
This method will simply save the rules stored inself.datainto file you passed asfilepath. -
applyToSentence(rule: dict, sentence: list) -> listThis method will apply the given rule to every token in the sentence if possible.
Private methods
There's also some methods that should not be used in your code, but they are widely used in Contextual19Parser.apply method and they can be useful in some cases.
applyRule(rule: dict, token: dict) -> dict
Apply assignments from some rule to the given token. This won't check if the given rule is really appliable to the token in this context. Resulting token will be returned.ruleIsAppliable(rule: dict, sentence: list, token: int) -> bool
Check if the givenruleis appliable to thetokenth token in thesentence. It'll check the context.applyIfPossible(rule: dict, sentence: list, token: int) -> list
It will apply some rule to the token if it's appliable in this context. Resulting sentence will be returned.applyRulesTo(rules: list, sentence: list, token: int) -> list
Apply each rule in the given list to thetoken-th token in thesentenceif they're appliable.
ctx19.Contextual19FileParser
This is the children of ctx19.Contextual19Parser with the changed initialization method.
Initialization
To initialize this parser just pass path to file with rules as the filepath parameter:
from ctx19 import Contextual19FileParser
parser = Contextual19FileParser("path/to/file.ctx19")
Since this is the Contextual19Parser children, it'll inherit all the parent methods, but one new private was added.
Private methods
parseFile(void) -> void
This will parse Contextual19 syntax from the file saved inself.file. You can change the file and call this method again.
Reading other object notation formats
From 1.2 version JSON and YAML parsers was moved in order to make ctx19 independent from other packages, but you can still do it yourself. Here's the example:
import json
from ctx19 import Contextual19Parser
ctx = Contextual19Parser(json.load("path/to/file.json"))
Metadata
Release files for ctx19 1.2
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 | |
|---|---|---|---|---|
| ctx19-1.2.tar.gz | 5.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ctx19-1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / ctx19-1.2.tar.gz
| Download URL | ctx19-1.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32aef05fba22531ef2c0303e81216b8da641dd75b26da15ee7a320f8c68e0e04
|
|
BLAKE2b-256 checksum How to use checksums |
939420a175c095756a2683bac182c1a2498c210053b94e0f3aca1fd73a919aaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.6.4
|
Release files / ctx19-1.2-py3-none-any.whl
| Download URL | ctx19-1.2-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f5c5dcdef325dfb97828d027b7742fa12103b8788f7b844fd4d961bb11d8c33
|
|
BLAKE2b-256 checksum How to use checksums |
20d5dafd4228104fc5c759ef6c8ed28ea764c15f69e19b131c5a25f11123ebf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.6.4
|
Security for ctx19 1.2
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.