Skip to main content

PyTrips PyPI version

Build Status

PyTrips provides a python interface to interacting with the TRIPS ontology and parser.

Installation

pip install pytrips
pip install pytrips[tools] # optional
python -c "import nltk; nltk.download('wordnet')"

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]}

Metadata

Release files for pytrips 0.5.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytrips 0.5.5
File Size Uploaded
pytrips-0.5.5.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytrips 0.5.5
File Interpreter ABI Platform
pytrips-0.5.5-py3-none-any.whl Python 3 none any Details

Total release size: 37.2 kB

Release files / pytrips-0.5.5.tar.gz

Download URL pytrips-0.5.5.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5645067ddc14aaad684e790e67d73b7487e87a4b9d9314fbe2e5a54c8b0e57bf
BLAKE2b-256 checksum
How to use checksums
48ef9304dc8a5b955756a2a592e539c9a73be43219f1d6f1c278f519e2147ccc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

Release files / pytrips-0.5.5-py3-none-any.whl

Download URL pytrips-0.5.5-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e351151c0ebc8a9f8f628dbef51fc7b77f19337d6aab0c1b04aab9527a68f73c
BLAKE2b-256 checksum
How to use checksums
1e98311893d04b95b528338b0e068181af4a5498e4d5a736bb3c8a2f40ace1b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

Release history Release notifications | RSS feed

0.5.22

2 release files

0.5.21

2 release files

0.5.20

2 release files

0.5.16

2 release files

0.5.15

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.7

2 release files

0.5.6

2 release files

This release

0.5.5 This release

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.4

1 release file

0.3.3

2 release files

0.3.2

1 release file

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.9

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page