Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created April 9, 2016 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuka1984/8394e47c9000fd7906c7f4ec5e6225b3 to your computer and use it in GitHub Desktop.
Save yuka1984/8394e47c9000fd7906c7f4ec5e6225b3 to your computer and use it in GitHub Desktop.
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