SWU Query
SWU query parsing, composition, and result helpers.
Functions
Sgnw\Core\SwuQuery\_swuquery_parse_prefix
function _swuquery_parse_prefix($text)
The swuquery module contains functions for handling the SWU query language.
Query Language definition:
https://datatracker.ietf.org/doc/id/draft-slevinski-formal-signwriting-10.html#name-query-language
Sgnw\Core\SwuQuery\_swuquery_parse_signbox
function _swuquery_parse_signbox($text)
Parse a signbox query string into a list of query elements.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | A string representing the signbox query. |
Returns
array — A list of symbols, ranges, or OR groups.
Examples
\Sgnw\Core\SwuQuery\_swuquery_parse_signbox('𝤆𝤆');
// [['symbol' => '', 'coord' => [500, 500]]]Sgnw\Core\SwuQuery\swuquery_parse
function swuquery_parse($swu_query_string)
Parse an SWU query string to a structured dictionary.
Parameters
| Parameter | Type | Description |
|---|---|---|
swu_query_string | string | an SWU query string |
Returns
array — Dictionary representing the query structure
Examples
\Sgnw\Core\SwuQuery\swuquery_parse('QARTR𝤆𝤆V5-');
// ['query' => true, 'prefix' => ['required' => true, 'parts' => ['', ['', ''], '']], 'signbox' => [['symbol' => ''], ['range' => ['', ''], 'coord' => [500, 500]]], 'variance' => 5, 'style' => true]Sgnw\Core\SwuQuery\swuquery_compose
function swuquery_compose($swu_query_object)
Function to compose SWU query string from object.
Parameters
| Parameter | Type | Description |
|---|---|---|
swu_query_object | array | Dictionary of query elements |
Returns
string|null — SWU query string
Examples
\Sgnw\Core\SwuQuery\swuquery_compose([
'query' => true,
'prefix' => ['required' => true, 'parts' => ['', ['', ''], '']],
'signbox' => [
['symbol' => ''],
['range' => ['', ''], 'coord' => [500, 500]]
],
'variance' => 5,
'style' => true
]);
// 'QARTR𝤆𝤆V5-'Sgnw\Core\SwuQuery\swu_to_query
function swu_to_query($swu_sign, $flags)
Function to convert an SWU sign to a query string.
For the flags parameter, use one or more of the following:
- A: exact symbol in temporal prefix
- a: general symbol in temporal prefix
- S: exact symbol in spatial signbox
- s: general symbol in spatial signbox
- L: spatial signbox symbol at location
Parameters
| Parameter | Type | Description |
|---|---|---|
swu_sign | string | SWU sign |
flags | string | flags for query string creation |
Returns
string|null — SWU query string
Examples
\Sgnw\Core\SwuQuery\swu_to_query('𝠀𝠃𝤟𝤩𝣵𝤐𝤇𝣤𝤐𝤆𝣮𝣭', 'ASL');
// 'QAT𝣵𝤐𝤇𝣤𝤐𝤆𝣮𝣭'Sgnw\Core\SwuQuery\swuquery_range
function swuquery_range($min_char, $max_char)
Function to transform a range of SWU characters to a regular expression.
Parameters
| Parameter | Type | Description |
|---|---|---|
min_char | string | an SWU character |
max_char | string | an SWU character |
Returns
string — a regular expression that matches a range of SWU characters
Examples
\Sgnw\Core\SwuQuery\swuquery_range('', '');
// '[\\x{40001}-\\x{401E1}]'Sgnw\Core\SwuQuery\_regex_range
function _regex_range($sym_range)
Sgnw\Core\SwuQuery\_regex_symbol
function _regex_symbol($sym)
Sgnw\Core\SwuQuery\swuquery_regex
function swuquery_regex($query)
Function to transform an SWU query string to one or more regular expressions.
Parameters
| Parameter | Type | Description |
|---|---|---|
query | string | an SWU query string |
Returns
array — a list of one or more regular expression strings
Examples
\Sgnw\Core\SwuQuery\swuquery_regex('QAT');Sgnw\Core\SwuQuery\swuquery_results
function swuquery_results($query, $text)
Function that uses a query string to match signs from a string of text.
Parameters
| Parameter | Type | Description |
|---|---|---|
query | string | an SWU query string |
text | string | a string of text containing multiple signs |
Returns
array — an array of SWU signs
Examples
Sgnw\Core\SwuQuery\swuquery_lines
function swuquery_lines($query, $text)
Function that uses an SWU query string to match signs from multiple lines of text.
Parameters
| Parameter | Type | Description |
|---|---|---|
query | string | an SWU query string |
text | string | multiple lines of text, each starting with an SWU sign |
Returns
array — an array of lines of text, each starting with an SWU sign
Examples