WordNET Dictionary APIs and Data Structures
Perhaps the specification could incorporate a full WordNET database
let word = new WordNetArray(["apple"])
word /* = {
"word": "apple",
"part-of-speech": "n,noun",
"synonym": ["macintosh", "granny smith", "red delicious", ...],
"phrase": "I ate an apple",
// Context-sensitive key-value pairs ... //
"sentence": `${ pronoun } ${ verb } ${ preposition } apple`,
"template": ( params ) => { ... },
"pronoun": [ { "singular personal":"i" }, { "singular direct":"you" }, { "plural direct":"we" }, { "plural indirect":"us" }, { "singular indirect":"me" }, ...],
"verb": [ { "present":"eat" }, { "past food reductive":"ate" }, { "present informal":"share" }, { "present formal":"split" }, ...],
"preposition": [ {"singular nonvowel":"a" },{ "singular vowel":"an" } ],
"metonym": [ { "fruit":"apple" }, { "fruit":"banana" }, { "fruit":"orange" }, { "fruit":"mango" }, ...],
}
*/
// Example #1
let subject = word["word"] /* "apple" */
let directObj = word["metonym"][1].fruit /* "banana" */
// Example #2
let pronoun = word["pronoun"][2]["plural direct"].toUpper() /* "We" */
let verb = word["verb"][2].present /* "share" */
let preposition = word["preposition"][1]["singular vowel"] /* "an" */
let mySentence = word.sentence /* "We share an apple" */
// Example #3
let mySentence2 = word.template( { "verb present pronoun plural direct informal":verb, "preposition singular vowel":preposition } ) /* "We share an apple" */
// Example #4
let myVeryShortStory = [
new WordNetArray(["studio"]).template( { "obj pronoun proper":"john", "verb present possessive":"works", "obj direct locale spatial":"big time L.A. movie studio" } ),
new WordNetArray(["call"]).template( { "obj direct locale temporal":"At 2:53 PM", "obj pronoun singular masculine generic present":"gets" "obj modifier":"phone" } ) +
new WordNetArray(["document"]).template( { "verb present singular masculine possessive generic":"offers", "obj synonym":"contract" } ),
new WordNetArray(["documents"]).template( { "verb present disjunctive compound obligating pronoun singular masculine generic":"print" } ) +
new WordNetArray(["document"]).template( { "verb present intransitive-of":"sign", "obj synonym":"contract" } ),
new WordNetArray(["building"]).template( { "verb present sense 1 masculine possessive":"leaves" } ),
new WordNetArray(["document"]).template( { "verb present":"prints", "obj noun modifier":"final page" } ),
new WordNetArray(["building"]).template( { "obj noun tangible":"page", "prep":"out", "obj direct locale":"window", "obj":"wooshes", "obj noun tangible":"desk fan" } ),
new WordNetArray(["object"]).template( { "obj pronoun proper":"john", "verb intransitive":"lunges", "verb intransitive singular masculine generic indirect formal":"falls" } ),
new WordNetArray(["window"]).template( { "verb singular masculine generic":"falls" } ) +
new WordNetArray(["car"]).template( { "verb covering":"collapsing", "obj pronoun proper individual indirect possessive":"executive" } ) +
new WordNetArray(["documents"]).template( { "verb pronoun improper singular masculine objective":"offer" "obj direct concrete colloquial modifier":"fresh set of" } ),
].join('\n')
myVeryShortStory /* =
`John works for a big time L.A. movie studio
At 2:53 PM he gets a phone call from an executive whom offers him a new contract,
but he has to print the documents and sign the contract before the executive leaves the building at 3 PM
As John prints the final page of the document a desk fan whooshes the page out the window
and as John lunges for it he falls out the window, collapsing onto the executive's car
whom is there to offer him a fresh set of documents`
*/