1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

enebularでkuromoji その2

Last updated at Posted at 2022-09-30

概要

enebularでkuromojiやってみた。
練習問題やってみた。

練習問題

apiを作って、plunkerで表示せよ。

方針

  • herokuに設置する。
  • endpointは、kuromojiでget
  • 結果のjsonをそのまま返す。

フロー

image.png

[{"id":"372f37d3.63e518","type":"debug","z":"51ad95ea.8b77ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":100,"wires":[]},{"id":"a9eb53ee.6a444","type":"http in","z":"51ad95ea.8b77ec","name":"","url":"/kuromoji","method":"get","upload":false,"swaggerDoc":"","x":110,"y":260,"wires":[["8cc58da7.521bb"]]},{"id":"8cc58da7.521bb","type":"function","z":"51ad95ea.8b77ec","name":"token","func":"\nmsg.payload = msg.req.query.token;\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":260,"wires":[["f98cd94b.b10998"]]},{"id":"f1ca732c.ca026","type":"http response","z":"51ad95ea.8b77ec","name":"","statusCode":"","headers":{},"x":600,"y":260,"wires":[]},{"id":"f98cd94b.b10998","type":"Kuromoji Tokenizer","z":"51ad95ea.8b77ec","name":"","x":330,"y":100,"wires":[["372f37d3.63e518","f1ca732c.ca026"]]}]

サンプルコード


var endpoint = "https://ohiapp0.herokuapp.com/kuromoji?token=";
var src = document.getElementById('src');

function send(msg) {
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && xhr.status == 200)
		{
			//alert(xhr.responseText);
    	document.body.appendChild(document.createTextNode(xhr.responseText));	
		}
		else
		{
			//alert(xhr.readyState);
			//alert(xhr.status);
			//alert(xhr.responseText);
		}
	};
  var uri = endpoint + msg;
	xhr.open("GET", uri, true);
	xhr.send();
	//alert("ok");
}

function run() {
  send(src.value);
  src.value = '';  
};




成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?