unofficial-jisho-api icon indicating copy to clipboard operation
unofficial-jisho-api copied to clipboard

Word Type Search

Open afortiori opened this issue 6 years ago • 5 comments

On jisho.org, it is possible to see the 'type' of word, for example, suru verb, godan verb etc. In the future would it be possible to get that information via the unofficial jisho api? I also now Jisho has a lot of information about inflection, being able to get that information would be super cool too.

afortiori avatar Feb 24 '19 15:02 afortiori

Hi, I'll see if I can add that information when I have some time 👍

mistval avatar Feb 24 '19 23:02 mistval

Thanks! :)

afortiori avatar Feb 24 '19 23:02 afortiori

I added a new scrapeForPhrase function to master that can get you the word type among other things. I need to test it a bit more and write documentation before I push a new version to NPM, but if you want to try it out now you can do npm install https://github.com/mistval/unofficial-jisho-api to install the master branch.

console.log(JSON.stringify(await jisho.scrapeForPhrase('ゆっくり'), null, 2)) returns the following:

{
  "found": true,
  "tags": [
    "Common word",
    "JLPT N5"
  ],
  "meanings": [
    {
      "seeAlsoTerms": [],
      "sentences": [],
      "meaning": "slowly; at ease; restful",
      "supplemental": [
        "Onomatopoeic or mimetic word"
      ],
      "meaningAbstract": "",
      "meaningTags": [
        "adverb",
        "noun",
        "suru verb",
        "adverb taking the 'to' particle"
      ]
    }
  ],
  "query": "ゆっくり",
  "uri": "https://jisho.org/word/%E3%82%86%E3%81%A3%E3%81%8F%E3%82%8A"
}

The word type is in the "meaningTags" property, it's the same as in the entry on Jisho.org.

As for the inflections, those are actually conjugated by JavaScript in the browser (here), so I'd have to do something like use Puppeteer to execute that code, I'll look into that some other time if I get a chance.

mistval avatar Feb 25 '19 06:02 mistval

New version 1.2.0 on NPM has the above mentioned scrapeForPhrase function. Please see the README or jsdocs for more info.

mistval avatar Feb 27 '19 11:02 mistval

Wow, thanks! This is super cool.

afortiori avatar Feb 27 '19 12:02 afortiori