Package org.apache.nlpcraft.model
Class NCMacroProcessor
- java.lang.Object
-
- org.apache.nlpcraft.model.NCMacroProcessor
-
public class NCMacroProcessor extends Object
Standalone synonym macro DSL processor.This processor provides the same macro support as the built-in macro support in data models. It is a general purpose macro-processor and it can be used standalone when testing synonyms, developing NERs, visualizing synonyms in toolchains, etc.
Read full documentation on synonym macro DSL in Data Model section and review examples.
-
-
Constructor Summary
Constructors Constructor Description NCMacroProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addMacro(String name, String macro)
Adds or overrides given macro.Set<String>
expand(String s)
Expands given macro DSL string.boolean
hasMacro(String name)
Tests whether this processor has given macro.boolean
removeMacro(String name)
Removes macro.
-
-
-
Method Detail
-
expand
public Set<String> expand(String s)
Expands given macro DSL string.Read full documentation on synonym macro DSL in Data Model section and review examples.
- Parameters:
s
- Macro DSL string to expand.- Returns:
- Set of macro expansions for a given macro DSL string.
-
addMacro
public boolean addMacro(String name, String macro)
Adds or overrides given macro.- Parameters:
name
- Macro name (typically an upper case string). It must start with '<' and end with '>' symbol.macro
- Value of the macro (any arbitrary string).- Returns:
true
if an existing macro was overridden,false
otherwise.
-
removeMacro
public boolean removeMacro(String name)
Removes macro.- Parameters:
name
- Name of the macro to remove.- Returns:
true
if given macro was indeed found and removed,false
otherwise.
-
hasMacro
public boolean hasMacro(String name)
Tests whether this processor has given macro.- Parameters:
name
- Name of the macro to test.- Returns:
true
if macro was found,false
otherwise.
-
-