lpmn_client_biz is a Python package containing a set of modules with classes and functions that can be used in your code. You can work with the package in any IDE that supports Python, both locally and online. The automatically generated package documentation is available here.
Classes:
Connection
- a class that creates and provides connection to the API server. Providing a config.yml file saved in one of the following locations:
Connection(config_file=‘config.yml’)
or Connection()
Connection(config_file=‘D:\Research\Clarin\config.yml’)
Connection()
Connection()
Connection(‘user’, ‘pass’)
.IOType
- a class that defines the type of input and output data for LPMN tasks, an enumeration type. There are three types of input and output data:
text
file
file_id
- path on the server to input/output dataTask
- a class for operations on LPMN tasks, storing the following methods:
run
- runs a taskrun_sent
- runs tasks that process sentence lists (sentence task type)get_progress
- returns information about the progress of a running taskcancel
- cancels a taskget_output
- returns the path on the server to the completed task; if the task has not been completed, it returns an error message.Functions:
download
- downloads a file / directory with output data from the serverupload
- uploads a file / directory with input data to the serverdelete
- deletes a file / directory from the serverWorking with LPMN Client in a programming environment requires at least basic Python programming skills.
from lpmn_client_biz import Connection, IOType, Task, download, upload
LPMN_BASE = ["any2txt",
"morphodita",
{
"liner2": {
"model": "n82"
}
}]
INPUT_BASE = "Tomasz Bombaliński pojechał do Wrocławia"
_Connection = Connection(config_file='config.yml')
file_id = upload(_Connection, "input_data_file")
task = Task(LPMN_BASE, connection=_Connection)
output_file_id = task.run(file_id, IOType.FILE)
downloaded = download(_Connection, output_file_id, IOType.FILE)
File Structure:
If you run input data in the form of a file, it is recommended to save the following files in one directory:
file.py
- source code fileconfig.yml
- login data file. The location of the file will in this case be treated as the current location.input_data_file
- file with input datafrom lpmn_client_biz import Connection, IOType, Task, download
LPMN_BASE = ["any2txt",
"morphodita",
{
"liner2": {
"model": "n82"
}
}]
INPUT_BASE = "Tomasz Bombaliński pojechał do Wrocławia"
_Connection = Connection(config_file='config.yml')
task = Task(LPMN_BASE, connection=_Connection)
output_file_id = task.run(INPUT_BASE, IOType.TEXT)
downloaded = download(_Connection, output_file_id, IOType.FILE)
To define a text processing pipeline using language tools in Python you need to define an LPMN query in the form of a list of ordered values. The list should be assigned to the LPMN_BASE
variable and saved in square brackets according to the pattern:
LPMN_BASE = [
"tool1",
"tool2",
"tool3"
]
It means that the text is processed first by tool1, then by tool2, and finally by tool3.
Some tools allow for detailed definition of processing parameters. To define a tool along with parameters you should use a dictionary according to the pattern:
{
"tool": {
"parameter": "value"
}
}
If you use multiple tools, the processing tools order should be as follows:
LPMN_BASE = ["tool1",
"tool2",
{
"tool3": {
"parameter": "value"
}
}]
for example:
LPMN_BASE = ["any2txt",
"morphodita",
{
"liner2": {
"model": "n82"
}
}]
(C) CLARIN-PL