xxxxxxxxxx
38
// A2Z F24
// Daniel Shiffman
// https://github.com/Programming-from-A-to-Z/A2Z-F24
function setup() {
noCanvas();
// Make a text input field
input = select('#sentence');
// Make a submit button
let button1 = select('#pluralize');
button1.mousePressed(pluralize);
let button2 = select('#negate');
button2.mousePressed(negate);
let button3 = select('#tense');
button3.mousePressed(futureTense);
function pluralize() {
let doc = nlp(input.value())
doc.nouns().toPlural();
createP(doc.out('text'));
}
function negate() {
let doc = nlp(input.value())
doc.verbs().toNegative();
createP(doc.out('text'));
}
function futureTense() {
let doc = nlp(input.value())
doc.verbs().toFutureTense();
createP(doc.out('text'));
}
}