Format of a jsRealB lexicon

The information in the lexicons of jsRealB was originally converted from an internal Lisp inspired format developed at RALI many years ago. The JSON lexicons were originally created using a Python script and then manually patched and updated over the years with a few fields as new information became available.

The declension or conjugation information is associated with tables, defined in the files rule-en.js and rule-fr.js, that cover most English and French use cases.

We now give the json-rnc schema used to validate the entries of the English lexicon. The schema for the French lexicon differs slightly in some field names and values, but its overall shape is similar.

A lexicon is a single JSON object whose keys are the lemma and the value is itself another object of type lexInfo with information about allowed parts of speech for this lemma; at least one part of speech object must be defined. The object associated with each part of speech list allowed values for different fields giving declension or conjugation information.

Schema (data/lexicon-en.jsonrnc)

start = {*:lexInfo}

lexInfo={N?:  {tab:/n(I|\d{1,3}a?)/, g?:gender, hAn?:one, cnt:/yes|no|both/,ldv?:boolean },
         A?:  {tab:/[a](I|\d{1,2})/, hAn?:one, ldv?:boolean},
         Pro?:{tab:/pn\d{1,2}(-\d[sp]?[mfn]?)?|d[35]/,ldv?:boolean},
         V?:  {tab:/v\d{1,3}/,ldv?:boolean}, 
         D?:  {tab:/d\d{1,2}/, n?:num, value?:number,ldv?:boolean},  
         Adv?:{tab:/b\d/,ldv?:boolean}, 
         P?:  {tab:/ppe?/,ldv?:boolean},
         C?:  {tab:/cs|cc/,ldv?:boolean},
         Q?:  {tab:/av/},
         Pc?: {tab:[/pc[145678]/], compl?:string},
         ldv?:boolean, 
         value?:number
    }@(minProperties=1)

one       = number@(minimum=1, maximum=1)
oneTwoThree  = number@(minimum=1, maximum=3)
gender = /m|f|x/
num = /s|p/

Query lexicons using jq

To query information from these lexicons, the easiest way is through the IDE or the evaluation demo.

But it is also possible to use jq to query these json lexicons. Here are a few examples of queries:

jq 'to_entries[]|select(.key=="love")' lexicon-en.json

jq -c 'to_entries[]|select(.key|test("^love.*"))' lexicon-en.json

jq -r 'to_entries[]|select((.key|test("er$")) and (.value|has("N")) and (.value|has("V")) and (.value|has("A")))|.key' lexicon-en.json

Validation

Using the jsonrnc validator

.../ValidateJsonRnc.py --slurp lexicon-en.jsonrnc lexicon-en.json
.../ValidateJsonRnc.py --slurp lexicon-fr.jsonrnc lexicon-fr.json

This also creates a standard JSON Schema which can be used in other contexts.

Use the JSON validator in Visual Studio Code

This is useful for adding new lexicon entries . Add the following to the settings.json configuration file. This uses the JSON Schema created by the previous validation process.

"json.schemas": [
        {"fileMatch": ["/Users/lapalme/Documents/GitHub/jsRealB/data/lexicon-en.json"],
         "url": "./data/lexicon-en.jsonrnc.json"},
         {"fileMatch": ["/Users/lapalme/Documents/GitHub/jsRealB/data/lexicon-fr.json"],
         "url": "./data/lexicon-fr.jsonrnc.json"}
   ]

Contact: Guy Lapalme RALI, Université de Montréal, 2024.