Package nzilbb.labbcat
Class PatternBuilder
java.lang.Object
nzilbb.labbcat.PatternBuilder
Helper class for building layered search patterns for
LabbcatView.search(JsonObject,String[],String[],boolean,Integer,Integer,Integer)
.
e.g.
// words starting with 'ps...' JSONObject pattern = new PatternBuilder().addMatchLayer("orthography", "ps.*").build(); // the word 'the' followed immediately or with one intervening word by // a hapax legomenon (word with a frequency of 1) that doesn't start with a vowel JSONObject pattern2 = new PatternBuilder() .addColumn() .addMatchLayer("orthography", "the") .addColumn() .addNotMatchLayer("phonemes", "[cCEFHiIPqQuUV0123456789~#\\$@].*") .addMaxLayer("frequency", 2) .build();
- Author:
- Robert Fromont robert@fromont.net.nz
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a column to the search matrix.addColumn
(int adj) Adds a column to the search matrix.addMatchLayer
(String layerId, String regularExpression) Adds a layer for matching a regular expression.addMaxLayer
(String layerId, double max) Adds a layer for matching a maximum value.addMaxLayer
(String layerId, int max) Adds a layer for matching a maximum value.addMinLayer
(String layerId, double min) Adds a layer for matching a minimum value.addMinLayer
(String layerId, int min) Adds a layer for matching a minimum value.addNotMatchLayer
(String layerId, String regularExpression) Adds a layer for not matching a regular expression.addRangeLayer
(String layerId, double min, double max) Adds a layer for matching a minimum to maximum range.addRangeLayer
(String layerId, int min, int max) Adds a layer for matching a minimum to maximum range.javax.json.JsonObject
build()
Construct a valid pattern object for passing toLabbcatView.search(JsonObject,String[],String[],boolean,Integer,Integer,Integer)
.toString()
A String representation of the JSON pattern object.
-
Constructor Details
-
PatternBuilder
public PatternBuilder()Default constructor.
-
-
Method Details
-
addColumn
Adds a column to the search matrix.- Returns:
- A reference to this builder.
-
addColumn
Adds a column to the search matrix.- Parameters:
adj
- Maximum distance, in tokens, from previous column.- Returns:
- A reference to this builder.
-
addMatchLayer
Adds a layer for matching a regular expression.- Parameters:
layerId
- The ID of the layer.regularExpression
- The regular expression to match.- Returns:
- A reference to this object.
-
addNotMatchLayer
Adds a layer for not matching a regular expression.- Parameters:
layerId
- The ID of the layer.regularExpression
- The regular expression to match.- Returns:
- A reference to this object.
-
addMinLayer
Adds a layer for matching a minimum value.- Parameters:
layerId
- The ID of the layer.min
- The minimum value.- Returns:
- A reference to this object.
-
addMinLayer
Adds a layer for matching a minimum value.- Parameters:
layerId
- The ID of the layer.min
- The minimum value.- Returns:
- A reference to this object.
-
addMaxLayer
Adds a layer for matching a maximum value.- Parameters:
layerId
- The ID of the layer.max
- The maximum value.- Returns:
- A reference to this object.
-
addMaxLayer
Adds a layer for matching a maximum value.- Parameters:
layerId
- The ID of the layer.max
- The maximum value.- Returns:
- A reference to this object.
-
addRangeLayer
Adds a layer for matching a minimum to maximum range.- Parameters:
layerId
- The ID of the layer.min
- The minimum value.max
- The maximum value.- Returns:
- A reference to this object.
-
addRangeLayer
Adds a layer for matching a minimum to maximum range.- Parameters:
layerId
- The ID of the layer.min
- The minimum value.max
- The maximum value.- Returns:
- A reference to this object.
-
build
public javax.json.JsonObject build()Construct a valid pattern object for passing toLabbcatView.search(JsonObject,String[],String[],boolean,Integer,Integer,Integer)
.- Returns:
- A valid pattern object.
-
toString
A String representation of the JSON pattern object.
-