Home

nzilbb.labbcat.js

nzilbb.labbcat module for communicating with LaBB-CAT web application servers.

What is LaBB-CAT?

LaBB-CAT is a web-based linguistic annotation store that stores audio or video recordings, text transcripts, and other annotations.

Annotations of various types can be automatically generated or manually added.

LaBB-CAT servers are usually password-protected linguistic corpora, and can be accessed manually via a web browser, or programmatically using a client library like this one.

What is this library?

The library copies from nzilbb.ag.IGraphStoreQuery and related Java interfaces, for standardized API calls.

nzilbb.labbcat is available as an npm package here.

nzilbb.labbcat.js can also be used as a browser-importable script.

This API is has the following object model:

LabbcatView
implements read-only functions for a LaBB-CAT graph store, corresponding to view permissions in LaBB-CAT.
LabbcatEdit
inherits all LabbcatView functions, and also implements some graph store editing functions, corresponding to edit permissions in LaBB-CAT.
LabbcatAdmin
inherits all LabbcatEdit functions, and also implements some administration functions, corresponding to admin permissions in LaBB-CAT.
Author:
  • Robert Fromont robert.fromont@canterbury.ac.nz
License:
  • magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL v3.0
Source:

Example

const corpus = new labbcat.LabbcatView("https://sometld.com", "your username", "your password");

// optionally, we can set the language that messages are returned in 
labbcat.language = "es";

// get the first participant in the corpus
corpus.getParticipantIds((ids, errors, messages)=>{
    const participantId = ids[0];
    
    // all their instances of "the" followed by a word starting with a vowel
    const pattern = [
        {"orthography" : "i"},
        {"phonemes" : "[cCEFHiIPqQuUV0123456789~#\\$@].*"}];
    
    // start searching
    corpus.search(pattern, [ participantId ], false, (response, errors, messages)=>{
        const taskId = response.threadId
                
        // wait for the search to finish
        corpus.waitForTask(taskId, 30, (task, errors, messages)=>{
            
            // get the matches
            corpus.getMatches(taskId, (result, errors, messages)=>{
                const matches = result.matches;
                console.log("There were " + matches.length + " matches for " + participantId);
                
                // get TextGrids of the utterances
                corpus.getFragments(
                    matches, [ "orthography", "phonemes" ], "text/praat-textgrid",
                    (textgrids, errors, messages)=>{
                        
                        for (let textgrid of textgrids) {
                            console.log(textgrid);
                        }
                        
                        // get the utterance recordings
                        corpus.getSoundFragments(matches, (wavs, errors, messages)=>{
                            
                            for (let wav of wavs) {
                                console.log(wav);
                            }
                        });
                    });
            });
        });
    });
});