Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
C#でEdge.jsを使ってrakutenMAを実行
using System;
using EdgeJs;
using Newtonsoft.Json;
namespace RakutenMA
{
internal class Program
{
private static void Main(string[] args)
{
var func = Edge.Func(@"
var RakutenMA = require('../rakutenma/rakutenma.js');
var fs = require('fs');
var model = JSON.parse(fs.readFileSync('rakutenma/model_ja.json'));
rma = new RakutenMA(model, 1024, 0.007812); // Specify hyperparameter for SCW (for demonstration purpose)
rma.featset = RakutenMA.default_featset_ja;
rma.hash_func = RakutenMA.create_hash_func(15);
return function(data, cb) {
cb(null, rma.tokenize(data));
};
");
var result = func("彼は新しい仕事できっと成功するだろう。").Result;
Console.Write(JsonConvert.SerializeObject(result, Formatting.Indented));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment