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

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.5.16.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrips-0.5.16-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file pytrips-0.5.16.tar.gz.

File metadata

  • Download URL: pytrips-0.5.16.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for pytrips-0.5.16.tar.gz
Algorithm Hash digest
SHA256 decaa55058ce0bd5eb06fb1e69c1798629ef8b57fb33ef3d65c9ec98dedccb4b
MD5 bffde396369dc9f21ca7e730fefe14af
BLAKE2b-256 68e882d1d8e81f97756a43c423bb8b0f788cd663372e7e86d322f3c0b7ec8bbc

See more details on using hashes here.

File details

Details for the file pytrips-0.5.16-py3-none-any.whl.

File metadata

  • Download URL: pytrips-0.5.16-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for pytrips-0.5.16-py3-none-any.whl
Algorithm Hash digest
SHA256 a9f31a8705bff527d295baf8fb058bd909b20c151e2b1cd1229d0c750f6e4a57
MD5 e512eaf88cc38d26e30426061ce606ae
BLAKE2b-256 f731e8d98dcba3dc13388bbe01154eb8d8d6d0084862316f730a453382797f0b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.22

2 files

0.5.21

2 files

0.5.20

2 files

0.5.19

2 files

0.5.18

2 files

This release

0.5.16 This release

2 files

0.5.15

2 files

0.5.12

2 files

0.5.11

2 files

0.5.10

2 files

0.5.9

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.0

2 files

0.4.0

2 files

0.3.4

1 file

0.3.3

2 files

0.3.2

1 file

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.0.22

2 files

0.0.19

2 files

0.0.16

2 files

0.0.15

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page