| commit | 121c66e064b17477b0792e7d10aa1dfb6c2f7e04 | [log] [tgz] |
|---|---|---|
| author | Akron <nils@diewald-online.de> | Mon Jun 02 16:34:05 2025 +0200 |
| committer | Akron <nils@diewald-online.de> | Mon Jun 02 16:34:05 2025 +0200 |
| tree | d5b5122ae2cad3a324db984ecf4089c74d30645e | |
| parent | 876fc2db95b46b3587f73191b3aabf3ec5fff482 [diff] |
Support escaping inm grammar rules Change-Id: I87e01605be27f165cfb4eaee69315c312e51f326
A KorAP service using the KoralPipe mechanism to rewrite terms in queries and responses between different annotations.
KoralPipe-TermMapper is a tool for transforming linguistic annotations between different annotation schemes. It allows you to define mapping rules in YAML configuration files and apply these mappings to JSON-encoded linguistic annotations.
go get github.com/KorAP/KoralPipe-TermMapper
termmapper -c config.yaml -p 8080 -l info
Command line options:
--config or -c: YAML configuration file containing mapping directives (required)--port or -p: Port to listen on (default: 8080)--log-level or -l: Log level (debug, info, warn, error) (default: info)--help or -h: Show help messageMapping rules are defined in YAML files with the following structure:
- id: mapping-list-id foundryA: source-foundry layerA: source-layer foundryB: target-foundry layerB: target-layer mappings: - "[pattern1] <> [replacement1]" - "[pattern2] <> [replacement2]"
Each mapping rule consists of two patterns separated by <>. The patterns can be:
[key] or [foundry/layer=key] or [foundry/layer=key:value][term1 & term2] or [term1 | term2] or [term1 | (term2 & term3)]Transform a JSON object using the specified mapping list.
Parameters:
:map: ID of the mapping list to usedir (query): Direction of transformation (atob or btoa, default: atob)foundryA (query): Override default foundryA from mapping listfoundryB (query): Override default foundryB from mapping listlayerA (query): Override default layerA from mapping listlayerB (query): Override default layerB from mapping listRequest body: JSON object to transform
Example request:
POST /opennlp-mapper/query?dir=atob&foundryB=custom HTTP/1.1 Content-Type: application/json { "@type": "koral:token", "wrap": { "@type": "koral:term", "foundry": "opennlp", "key": "PIDAT", "layer": "p", "match": "match:eq" } }
Example response:
{ "@type": "koral:token", "wrap": { "@type": "koral:termGroup", "operands": [ { "@type": "koral:term", "foundry": "custom", "key": "PIDAT", "layer": "p", "match": "match:eq" }, { "@type": "koral:term", "foundry": "custom", "key": "AdjType", "layer": "p", "match": "match:eq", "value": "Pdt" } ], "relation": "relation:and" } }
Copyright (C) 2025, IDS Mannheim
Author: Nils Diewald
TermMapper is free software published under the BSD-2 License.
Disclaimer: This software was developed (as an experiment) with major assistance by AI (mainly Claude 3.5-sonnet and Claude 4-sonnet).