Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

297
Visualizações
Reference error: RiLexicon is not defined

I am trying to write a code on p5.js and cannot figure out why the code below is throwing the error:

Uncaught ReferenceError: RiLexicon is not defined

mySketch, line 18:Cannot read properties of undefined (reading 'isNoun')

I turned on the RiTa.js library but it doesn't work. Hope someone can give an insight.

let poem = "STOPPING BY WOODS ON A SNOWY EVENING WHOSE woods these are I think I know. His house is in the village though; He will not see me stopping here To watch his woods fill up with snow. My little horse must think it queer To stop without a farmhouse near Between the woods and frozen lake The darkest evening of the year. He gives his harness bells a shake To ask if there is some mistake. The only other sound's the sweep Of easy wind and downy flake. The woods are lovely, dark and deep. But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep."

let words;
let newPoem = "";
var lexicon = new RiLexicon();
function setup() {
    createCanvas(windowWidth, windowHeight);
    background(100);
    
    // tokenize the poem string to words
    words = RiTa.tokenize(poem);
    // replace all nouns and adjectives in the text with random nouns and adjectives. 
    // loop through all the words
    for (i=0; i<words.length; i++){
        let currentWord = words[i];
        // when the word is a noun
        if (lexicon.isNoun(currentWord)){
            // generate a new noun and use that as current word
            currentWord = lexicon.randomWord("nn");
        }
        // when the word is an adj
        else if (lexicon.isAdjective(currentWord)){
            // generate a new adj and use that as current word
            currentWord = lexicon.randomWord("jj");
        }
        // add the word to the new poem
        newPoem += currentWord + " ";
    }
    print(newPoem);
}
function draw() {
    textSize(16);
    // display the new poem
    text(newPoem, width/20, height/4, 500, 800);
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I'm pretty sure RiLexicon is deprecated in RiTa 2, as I've just read that in an update to an old tutorial I've been doing. I can't give you a definitive answer as I've only been using RiTa for about 2 hours - I found your question when googling for info on its alternatives! RiTa.randomWord might do it ps just found this https://rednoise.org/rita1/reference/RiLexicon.php It has been deprecated

about 4 years ago · Juan Pablo Isaza Relatório

0

RiLexicon is deprecated in v2.x, but all the functions still exist -- they are just accessed in the form of RiTa.functionName():

  • RiTa.isNoun()
  • RiTa.isAdjective()
  • RiTa.randomWord()
  • RiTa.tokenize()

The reference for version 2.x is here: https://rednoise.org/rita/#reference

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda