PyTrips 
PyTrips provides a python interface to interacting with the TRIPS ontology and parser.
Installation
pip install pytrips
Basic Usage
Load the ontology and retrieve a type by name:
from pytrips.ontology import load
ont = load()
catch = ont["catch"] # lookup an ontology type
And then inspect said type:
print(catch)
print(catch.parent)
print(catch.children)
print(catch.arguments)
which should result in:
# ont::catch
# ont::co-motion
# []
# [<TripsRestriction :neutral >, <TripsRestriction :source >, <TripsRestriction :result >, <TripsRestriction :extent >, <TripsRestriction :affected >, <TripsRestriction :agent >]
Check if types subsume each other:
catch < ont["event-of-action"]
# Make sure at least one type is explicitly a TripsType. The other can be a string.
"food" > ont["bread"]
Or get the lowest common subsumer of two types:
ont["bread"] ^ ont["geo-object"]
For simplicity, lookup words and ontology types in the same way:
ont["person"] # default is to look up an ontology type
ont["ont::person"] # explicitly get the ontology type named "ont::person"
ont["w::person"] # or lookup the list of ontology types that the word "person" can map to
WordNet lookups are similar:
ont["wn::cat%1:06:00::"]
>> [ont::device]
ont["q::cat"] # returns all lexical and wordnet mappings for the word cat in a dictionary
>> {'lex': [ont::nonhuman-animal, ont::medical-diagnostic],
'wn': [ont::pharmacologic-substance,
ont::female-person,
ont::communication-party,
ont::male-person,
ont::medication,
ont::mammal,
ont::device,
ont::land-vehicle,
ont::vomit]}
Or we can specify a part of speech to limit the search:
ont[("q::move", 'v')]
>> {'lex': [ont::cause-move, ont::move, ont::provoke, ont::activity-ongoing],
'wn': [ont::cause-effect,
ont::change,
ont::believe,
ont::activity-event,
ont::commerce-sell,
ont::move,
ont::progress,
ont::live,
ont::suggest]}
Release files for pytrips 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytrips-0.0.10.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytrips-0.0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.0 kB
Release files / pytrips-0.0.10.tar.gz
| Download URL | pytrips-0.0.10.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f18972596ca4a63a5878211a5a8c74b50c5697842cce26a8b3c9e01afc87eaf
|
|
BLAKE2b-256 checksum How to use checksums |
e64ac2772091203e5ac350389edf6b3291ddbb6fcdd28f639e3a9902ee30e9f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3
|
Release files / pytrips-0.0.10-py3-none-any.whl
| Download URL | pytrips-0.0.10-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9864dc7f8fa7ad28c3c8afd4cf18c830fa622409156cd80043a1bcd69a77dcda
|
|
BLAKE2b-256 checksum How to use checksums |
5d3613ae32a4fedf94fa6fddd42c31e6cd3bdb7034032b0292393c8d3ba2dda4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3
|