Package nzilbb.labbcat.server.search
Class Matrix
- java.lang.Object
-
- nzilbb.labbcat.server.search.Matrix
-
- All Implemented Interfaces:
nzilbb.util.CloneableBean
public class Matrix extends Object implements nzilbb.util.CloneableBean
Complete search matrix.
-
-
Constructor Summary
Constructors Constructor Description Matrix()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Matrix
addColumn(Column column)
Convenience builder-pattern method for adding a column.nzilbb.util.CloneableBean
fromJson(javax.json.JsonObject json)
Initializes the bean with the given JSON representation.Matrix
fromJsonString(String jsonString)
Deserialize a search matrix from a JSON-encoded string.Matrix
fromLegacyString(String search)
Defines the matrix using a string formatted in the legacy LaBB-CAT encoding.Vector<Column>
getColumns()
Getter forcolumns
: The columns of the search matrix, each representing patterns matching one word token.String
getDescription()
A curt semi-human-readable summary of the matrix that can be used for probably-unique, more or less descriptive file names, etc.String
getParticipantQuery()
Getter forparticipantQuery
: Query to identify participants whose utterances should be searched.int
getTargetColumn()
Determines which column the (first) LayerMatch whereLayerMatch.target
== true is located in.String
getTargetLayerId()
Returns the layer ID of the (first) LayerMatch whereLayerMatch.target
== true.String
getTranscriptQuery()
Getter fortranscriptQuery
: Query to identify transcripts whose utterances should be searched.Stream<LayerMatch>
layerMatchStream()
A stream of LayerMatchs defined in the matrix.Matrix
setColumns(Vector<Column> newColumns)
Setter forcolumns
: The columns of the search matrix, each representing patterns matching one word token.Matrix
setParticipantQuery(String newParticipantQuery)
Setter forparticipantQuery
: Query to identify participants whose utterances should be searched.Matrix
setTranscriptQuery(String newTranscriptQuery)
Setter fortranscriptQuery
: Query to identify transcripts whose utterances should be searched.String
toString()
Returns the JSON serialization of this search matrix.
-
-
-
Method Detail
-
getParticipantQuery
@ClonedProperty public String getParticipantQuery()
Getter forparticipantQuery
: Query to identify participants whose utterances should be searched.- Returns:
- Query to identify participants whose utterances should be searched.
-
setParticipantQuery
public Matrix setParticipantQuery(String newParticipantQuery)
Setter forparticipantQuery
: Query to identify participants whose utterances should be searched.- Parameters:
newParticipantQuery
- Query to identify participants whose utterances should be searched. An empty string results in null being assigned.
-
getTranscriptQuery
@ClonedProperty public String getTranscriptQuery()
Getter fortranscriptQuery
: Query to identify transcripts whose utterances should be searched.- Returns:
- Query to identify transcripts whose utterances should be searched.
-
setTranscriptQuery
public Matrix setTranscriptQuery(String newTranscriptQuery)
Setter fortranscriptQuery
: Query to identify transcripts whose utterances should be searched.- Parameters:
newTranscriptQuery
- Query to identify transcripts whose utterances should be searched. An empty string results in null being assigned.
-
getColumns
@ClonedProperty public Vector<Column> getColumns()
Getter forcolumns
: The columns of the search matrix, each representing patterns matching one word token.- Returns:
- The columns of the search matrix, each representing patterns matching one word token.
-
setColumns
public Matrix setColumns(Vector<Column> newColumns)
Setter forcolumns
: The columns of the search matrix, each representing patterns matching one word token.- Parameters:
newColumns
- The columns of the search matrix, each representing patterns matching one word token.
-
addColumn
public Matrix addColumn(Column column)
Convenience builder-pattern method for adding a column.- Parameters:
column
-- Returns:
- This matrix.
-
fromJson
public nzilbb.util.CloneableBean fromJson(javax.json.JsonObject json)
Initializes the bean with the given JSON representation.- Specified by:
fromJson
in interfacenzilbb.util.CloneableBean
- Parameters:
json
-- Returns:
- A reference to this object.
-
fromJsonString
public Matrix fromJsonString(String jsonString)
Deserialize a search matrix from a JSON-encoded string.- Parameters:
jsonString
-- Returns:
- This matrix.
-
fromLegacyString
public Matrix fromLegacyString(String search)
Defines the matrix using a string formatted in the legacy LaBB-CAT encoding.A search string can be something like like
pos:N\nphonemes:.*[aeiou]\tpos:V\nphonemes:[aeiou].*
Which searches for
A word with N on the pos layer, and ending with a vowel on the phonemes layer, followed by a word with V on the pos layer and starting with a vowel on the phonemes layer.
The delimiters and formats of the parts are:
\n
- start new layer
\t
- start new search word column
:
- Separator between layer ID and its search expression.
If this is omitted, the whole string is assumed to be an expression to match on the
orthography layer - i.e. the string
expression
is the same asorthography:expression
. layer name
- The layer ID.
expression
- The the regular expressions can be preceded by
NOT
indicating it's a reversed match. Or, for numeric layers, the expression may be of the formmin<max
, which is interpreted asmin≤label<max
- Parameters:
search
-- Returns:
- This object.
-
layerMatchStream
public Stream<LayerMatch> layerMatchStream()
A stream of LayerMatchs defined in the matrix.- Returns:
- A stream of LayerMatchs defined in the matrix.
-
getTargetLayerId
public String getTargetLayerId()
Returns the layer ID of the (first) LayerMatch whereLayerMatch.target
== true.- Returns:
- The layer ID of the (first) LayerMatch where
LayerMatch.target
== true, or null if there is no such LayerMatch.
-
getTargetColumn
public int getTargetColumn()
Determines which column the (first) LayerMatch whereLayerMatch.target
== true is located in.- Returns:
- The index of the column the (first) LayerMatch where
LayerMatch.target
== true is located in, or -1 if there is no such LayerMatch.
-
getDescription
public String getDescription()
A curt semi-human-readable summary of the matrix that can be used for probably-unique, more or less descriptive file names, etc.- Returns:
- A string describing the layer matches.
-
-