DEV Community

Mario
Mario

Posted on

I made app that can convert sentences to Japanese honorific form (Keigo)

I am not a Japanese native, sometimes I don't know how to say correctly in Keigo form (Japanese honorific form, usually for business).

For example, I wanted to say "I don't understand what this means", or in casual Japanese "これはどういう意味か分からない (Kore wa douiu imi ka wakaranai".

The app will return "これはどういう意味でしょうか?教えて頂けますか? (Kore wa doiu imi deshouka? oshiete itadakemasuka?)".
Or in English "what this means? Can you explain to me?"

https://keigobot.com

keigobot.com

I used OpenAI's latest model ("gpt-3.5-turbo") to convert the sentences.
For the front end I used NextJS and TailwindCSS.

The API call part looks like this.

  const config = new Configuration({
    apiKey: process.env.OPENAI_API_KEY
  })

  const openai = new OpenAIApi(config)

  const prompt = 

`I want you to act as an Japanese teacher. I will speak to you in any language, and you will change it to Keigo form.
Make it natural and keep the meaning same. I want you to only reply the correction, the improvements and nothing else, do not write explanations. 
My sentence is {${userInput}}` 

  const response = await openai.createChatCompletion({
    model: "gpt-3.5-turbo",
    messages: [{role: "user", content: prompt}],
  })

  res.status(200).json({ result: response.data.choices[0].message })

Enter fullscreen mode Exit fullscreen mode

You can type any language for the input, and it will return the honorific sentence.
Of course because it is generated by AI, It's not always right. But I can say it is good most of the times.

I shared this on Reddit after release, so the traffic was pretty high. Currently, I am expecting about 100 visitors per day.

traffic

There are still many other things that can be improved.
It would be nice if this website can help people who are using Japanese.

References

OpenAPI Guide (Paid)
https://platform.openai.com/docs/api-reference/completions?lang=node.js

Host/Deploy (Free)
https://vercel.com/

Top comments (0)