kuroshiro icon indicating copy to clipboard operation
kuroshiro copied to clipboard

KuromojiAnalyzer is not a constructor

Open ChesterAiGo opened this issue 1 year ago • 0 comments

I know everyone's getting Kuroshiro is not a constructor and resolves the problem with adding a default

But i don't see anyone getting this weird error as mine:

KuromojiAnalyzer is not a constructor
TypeError: KuromojiAnalyzer is not a constructor

My code is:

const Kuroshiro = require("kuroshiro").default;
const KuromojiAnalyzer = require("kuroshiro-analyzer-kuromoji");


function someComponent({ text }) {

  const kuroshiro = new Kuroshiro();
  const analyzer = new KuromojiAnalyzer();

  // Convert the Japanese text to Romaji
  let captionedText;
  kuroshiro.init(analyzer)
    .then(function(){
      captionedText = kuroshiro.convert(text, { to: "romaji" });
    })
    .then(function(captionedText){
        console.log(captionedText);
    })
    

and it fails with the error above Any hint or help would be immensely appreciated! :)

ChesterAiGo avatar Jul 15 '23 09:07 ChesterAiGo