Gets a list of IDs of graphs (i.e. transcript names) that match a particular pattern.

getMatchingGraphIds(
  labbcat.url,
  expression,
  page.length = NULL,
  page.number = NULL,
  order = NULL
)

Arguments

labbcat.url

URL to the LaBB-CAT instance

expression

An expression that determines which graphs match

page.length

The maximum number of IDs to return, or null to return all

page.number

The zero-based page number to return, or null to return the first page

order

An expression that determines the order the graphs are listed in - if specified, this must include the keyword 'ASC' for ascending or 'DESC' for descending order.

Value

A list of graph IDs (i.e. transcript names)

Details

The results can be exhaustive, by omitting pageLength and page.number, or they can be a subset (a 'page') of results, by given pageLength and page.number values.

The order of the list can be specified. If ommitted, the graphs are listed in ID order.

The expression language is currently not well defined, but is based on JavaScript syntax.

  • The labels function can be used to represent a list of all the annotation labels on a given layer. For example, each transcript can have multiple participants, so the participant labels (names) are represented by: labels('participant')

  • Use the includes function on a list to test whether the list contains a given element. e.g. to match transcripts that include the participant 'Joe' use: labels('participant').includes('Joe')

  • Use the first function to identify the first (or the only) annotation on a given layer. e.g. the annotation representing the transcript's corpus is: first('corpus')

  • Single annotations have various attributes, including 'id', 'label', 'ordinal', etc. e.g. the name of the transcript's corpus is: first('corpus').label

  • Regular expressions can be matched by using expressions like '/regex/.test(str)', e.g. to test if the ID starts with 'BR' use: /^BR.+/.test(id) or to test if the transcript's corpus includes a B use: /.*B.*/.test(first('corpus').label)

Expressions such as those in the examples can be used.

Examples

if (FALSE) {
## Get all transcripts whose names start with "BR"
transcripts <- getMatchingGraphIds(labbcat.url, "/^BR.+/.test(id)")

## Get the first twenty transcripts in the "QB" corpus
transcripts <- getMatchingGraphIds(
        labbcat.url, "first('corpus').label = 'QB'", 20, 0)

## Get the second transcript that has "QB247_Jacqui" as a speaker
transcripts <- getMatchingGraphIds(
        labbcat.url, "labels('participant').includes('QB247_Jacqui')", 1, 1)

## Get all transcripts in the QB corpus whose names start with "BR"
## in word-count order 
transcripts <- getMatchingGraphIds(
        labbcat.url, "first('corpus').label = 'QB' && /^BR.+/.test(id)", 
        order="first('transcript_word_count').label ASC")
}