Skip to content

LimaAnalyzer: the runtime rules and pipelines API of the Python bindings - #252

Open
kleag wants to merge 1 commit into
masterfrom
sync-lima-analyzer
Open

kleag wants to merge 1 commit into
masterfrom
sync-lima-analyzer

Conversation

@kleag

@kleag kleag commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Syncs LIMA's LimaAnalyzer (lima_linguisticprocessing/src/linguisticProcessing/client/lima.{h,cpp}) with the copy in aymara/lima-python. That copy gained a runtime API with the PhraseMatcher (aymara 0.10.0) and with compile_rules (aymara/lima-python#53, merged). LIMA's copy had none of it.

New LimaAnalyzer methods

  • addResource(media, json), addProcessUnit(media, json), addPipeline(pipeline, media, unit): declare at runtime a resource, a process unit, and a pipeline made of a ProcessUnitPipeline unit.
  • addEntityType(group, type): declares a named entity type (and its group).
  • setRecognizerRules(media, recognizer, rulesFile): replaces the rules of an AutomatonRecognizer resource with the compiled ModEx rules of a text file.
  • compileRules(media, rulesFile, binFile): compiles ModEx rules into a .bin, as compile-rules does. It writes a temporary file and renames it, so a failed compilation leaves binFile untouched.
  • loadRecognizerRules(media, recognizer, binFile): loads a .bin into a recognizer, after checking that it was compiled for that media.

The private implementations are copied verbatim from lima-python. LIMA's LimaAnalyzer keeps its public error / errorMessage fields: a new LimaAnalyzerPrivate::report passes the errors there. The header documents that analyzeText refuses to run while error is set, so a caller resets it to go on after a failed call (e.g. rules that don't compile). lima-lp-analyzer already linked lima-lp-automaton and lima-lp-automatoncompiler, so there's no CMake change.

Tests (LimaAnalyzerTest0)

  • test_compile_rules (no model):
    • compiles rules for a group declared with addEntityType;
    • a failed compilation keeps the .bin and leaves no temporary file;
    • loadRecognizerRules and setRecognizerRules on a resource added with addResource;
    • the errors: text rules given as a .bin, an unknown recognizer, a resource that already exists.
  • test_rules_entities (eng-UD_English-MERGE model, skipped without it): compiled rules applied by a pipeline built at runtime (micro-categories, recognizer, ApplyRecognizer unit, ProcessUnitPipeline, addPipeline). The entity is in the output of that pipeline and not in the one of deepud.

Locally (Ninja build, execEnv environment, with the models): ctest -R LimaAnalyzer gives 23/23 passed, the two new tests included (not skipped).

🤖 Generated with Claude Code

Synced with aymara/lima-python's lima.cpp (PhraseMatcher in 0.10.0,
compile_rules in aymara/lima-python#53): addResource, addProcessUnit,
addPipeline, addEntityType, setRecognizerRules, compileRules and
loadRecognizerRules. LimaAnalyzer keeps its public error and errorMessage
fields: the private part reports its errors there.

LimaAnalyzerTest0: test_compile_rules (no model) and test_rules_entities
(compiled rules applied by a pipeline added at runtime).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 54 complexity · 0 duplication

Metric Results
Complexity 54
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant