A simple python package for accessing the trips ontology and lexicon
Project description
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]}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytrips-0.0.15.tar.gz
(7.2 kB
view details)
Built Distribution
pytrips-0.0.15-py3-none-any.whl
(17.1 kB
view details)
File details
Details for the file pytrips-0.0.15.tar.gz
.
File metadata
- Download URL: pytrips-0.0.15.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using 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.31.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
688d909a91a549be386a0ee19f812c820b0666b4338b59ae5d1a7accb9af8ac8
|
|
MD5 |
6a2b46e82d706dabba3e38a64d8dafee
|
|
BLAKE2b-256 |
1cb24ebc0d84dfd3fd4092f84b9a7cd076830a0845506d94408c7fb659fec4be
|
File details
Details for the file pytrips-0.0.15-py3-none-any.whl
.
File metadata
- Download URL: pytrips-0.0.15-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using 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.31.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8e1135fb7ea2f7c9e597638a502c193d96cc6154ec055eef64e24027d53380a4
|
|
MD5 |
05836b81e169583c5700495a4fda94e8
|
|
BLAKE2b-256 |
aa97ce638e9b3e161b9e2d71764557371704e2409730a1b03dee155da465371a
|