Nihongoresources Tools
Searching from the browser search bar
If you are using a broswer with a search-bar built into it, you can add nihongoresources as a search engine for this bar by telling your browser to add the nihongoresources search to it. The procedure differs per browser, but there will be an option to add a search engine pretty close to the actual search bar.
External searching
If you want to poll nihongoresources from your own website, there is a special polling url that you can use, designed especially for external calls by websites that require concise dictionary information.
If you run a site with "ajax" style dynamic content then you can poll the NR database real simple by placing a GET request for the url http://www.nihongoresources.com/index.html?caller=servicename&q=keyword where [caller] is a name that identifies your website and [keyword] is the word you're looking up. This will return an XML document (with DTD) containing all hits for this word as whole word. You can explicitly ask for start, whole word, word end or substring searches by adding the parameter "type" with any of the four values "start", "whole", "end" or "substring". As third parameter the url can be given the location of a stylesheet that the XML should link to for visualisation. By default it links to a stylesheet hosted on the nihonogoresources server, but if your site is styled with css then it is really easy to use your own stylesheet instead by adding a "stylesheet" parameter to the url with as value the URL for your stylesheet.
If you want to test the system, simply copy-paste the following code to a new html file and run it in your browser. It has input fields for the keyword, type and stylesheet location, and will perform an external search call when you click submit on the form.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <form action="http://www.nihongoresources.com/index.php" method="get"> <input type="hidden" name="caller" value="nr_test_form"/> <input type="hidden" name="stylesheet" value="http://www.nihongoresources.com/external.css"/> queryword: <input type="text" name="q"/> as: <select name="type"> <option value="start">word start</option> <option value="end">word end</option> <option value="whole">whole word</option> <option value="substring">substring</option> </select> <input type="submit"/> </form> </body> </html>
One important note is that when you write your own GET request as part of an "ajax" style dynamic request, you have to make sure that when you're doing searches for Japanese keywords these are encoded in UTF-8 unicode, not some other encoding. If you use a different encoding, the system will send back a bit of XML essentially informing you your input was malformed and to please correct that ^_^;
Usage summary
External polling is a "get" request on the URL http://www.nihongoresources.com/index.html
parameters that must/can be passed along are the following:
parameter | priority | type | description |
q | required | string | The keyword to search for. UTF-8 encoded if not ascii input. |
caller | required | string | Identifies your service to the server. |
type | optional | string | Determines the search type. Possible values are "start", "whole", "end" or "substring". |
stylesheet | optional | URL | Specifies the URL of the stylesheet to be used to default-style the XML answer. |
dtd | optional | boolean | Instructs the system not to include the DTD as part of the XML reply. If added, should be set to "false" |
Example reply
The XML that is returned comes with its own DTD embedded, but if you want you can have the DTD stripped, in which case it's good to know what the DTD looks like. For this purpose, an example reply for a call using the word [はじめ] as keyword, which you would get by calling this url is:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="http://www.nihongoresources.com/css/external.css" type="text/css"?> <!DOCTYPE nr_reply [ <!ELEMENT nr_reply (nr_caller, nr_keyword, nr_entry*, nr_rendertime)> <!ELEMENT nr_caller (#PCDATA)> <!ELEMENT nr_keyword (#PCDATA)> <!ELEMENT nr_entry (nr_readings*, nr_kanjis*, nr_poss*, nr_meanings*)> <!ELEMENT nr_readings (nr_reading*)> <!ELEMENT nr_kanjis (nr_kanji*)> <!ELEMENT nr_poss (nr_pos*)> <!ELEMENT nr_meanings (nr_english*)> <!ELEMENT nr_reading (#PCDATA)> <!ELEMENT nr_kanji (#PCDATA)> <!ELEMENT nr_pos (#PCDATA)> <!ELEMENT nr_english (#PCDATA)> <!ELEMENT nr_rendertime (#PCDATA)> ]> <!-- this JMDict data is provided to you in accordance with the license statement found at http://www.csse.monash.edu.au/~jwb/edrdg/licence.html --> <nr_reply> <nr_caller>testcall</nr_caller> <nr_keyword>はじめ</nr_keyword> <nr_entry> <nr_readings> <nr_reading>はじめ</nr_reading> </nr_readings> <nr_kanjis> <nr_kanji>初め</nr_kanji> <nr_kanji>始め</nr_kanji> </nr_kanjis> <nr_poss> <nr_pos>adverbial noun (fukushitekimeishi)</nr_pos> <nr_pos>noun (temporal) (jisoumeishi)</nr_pos> </nr_poss> <nr_meanings> <nr_english>beginning</nr_english> <nr_english>start</nr_english> <nr_english>origin</nr_english> </nr_meanings> </nr_entry> <nr_rendertime>0.0050051212310791</nr_rendertime> </nr_reply>