public abstract class PathRewritePlugin extends Object
Dictionary
initialize this plugin with Settings
. It can be
referred as Plugin.settings
.
The following is an example of settings.
{
"class" : "com.worksap.nlp.sudachi.PathRewritePlugin",
"example" : "example setting"
}
Constructor and Description |
---|
PathRewritePlugin() |
Modifier and Type | Method and Description |
---|---|
LatticeNode |
concatenate(List<LatticeNode> path,
int begin,
int end,
Lattice lattice,
String normalizedForm)
Concatenate the sequence of nodes in the path.
|
LatticeNode |
concatenateOov(List<LatticeNode> path,
int begin,
int end,
short posId,
Lattice lattice)
Concatenate the sequence of nodes in the path.
|
Set<CategoryType> |
getCharCategoryTypes(InputText text,
LatticeNode node)
Return the set of the category types of the node.
|
abstract void |
rewrite(InputText text,
List<LatticeNode> path,
Lattice lattice)
Rewrite the path of the lattice.
|
void |
setUp(Grammar grammar)
Set up the plugin.
|
protected Settings settings
public void setUp(Grammar grammar) throws IOException
Tokenizer
calls this method for setting up this plugin.grammar
- the grammar of the system dictionaryIOException
- if reading something is failedpublic abstract void rewrite(InputText text, List<LatticeNode> path, Lattice lattice)
concatenate(java.util.List<com.worksap.nlp.sudachi.LatticeNode>, int, int, com.worksap.nlp.sudachi.Lattice, java.lang.String)
or
concatenateOov(java.util.List<com.worksap.nlp.sudachi.LatticeNode>, int, int, short, com.worksap.nlp.sudachi.Lattice)
.text
- the input textpath
- the best path of the latticelattice
- the latticepublic LatticeNode concatenate(List<LatticeNode> path, int begin, int end, Lattice lattice, String normalizedForm)
begin
and extends to the node at index end - 1
.
The concatenated node has the POS ID of the head of the sequence.
path
- the pathbegin
- the beginning indexend
- the ending indexlattice
- the latticenormalizedForm
- if normalizedForm
is null
, concatenate the
normalizedForms of each wordsIndexOutOfBoundsException
- if begin
or end
are negative, greater than the
length of the sequence, or begin
equals or is greater
than end
public LatticeNode concatenateOov(List<LatticeNode> path, int begin, int end, short posId, Lattice lattice)
begin
and extends to the node at index end - 1
.
The concatenated node is marked as OOV.
path
- the pathbegin
- the beginning indexend
- the ending indexposId
- the POS ID of the concatenated nodelattice
- the latticeIndexOutOfBoundsException
- if begin
or end
are negative, greater than the
length of the sequence, or begin
equals or is greater
than end
public Set<CategoryType> getCharCategoryTypes(InputText text, LatticeNode node)
text
- the input textnode
- the nodeCopyright © 2017–2021 Works Applications Co., Ltd.. All rights reserved.