Python API
Contents
Installation
Python API is a part of the official RL3 binary package. In order to install it, please consult the Installation Guide page.
Requirements
RL3 Python API requires Python 2 or Python 3
Example usage
import rl3
# create engine
engine = rl3.RL3Engine()
# parse and compile (link) simple annotation pattern
definition = engine.make_simple_annotation_def("text", r"(?i:{dawg continent})", "continent")
engine.parse(definition)
engine.link()
# create factsheet
fs = engine.create_factsheet()
# assert input text
fs.assert_simple_fact("text", "Antarctica is Earth's southernmost continent... Europe is the sixth largest continent in size.")
# run engine - it should now annotate a continent names mentioned in our text
engine.update(fs);
# iterate and print all "continent" annotations
for i in fs.get_facts("continent"):
print (i.get_value())
Output:
Antarctica Europe
General notes
- Objects can not be copied by value (by using
__copy__
or__deepcopy__
functions).
Interface
Core classes
- class rl3.EngineError
- class rl3.SharedText
- class rl3.Fact
- class rl3.Factsheet
- class rl3.FactIterator
- class rl3.FactPathIterator
- class rl3.BaseEngine
- class rl3.RL3Engine
- class rl3.KMLEngine
Info functions
rl3.get_copyright()
Get copyright.
Returns: | copyright |
rl3.get_maintainer()
Get the maintainer's name.
Returns: | the name of a maintainer |