yanyiwu / jieba-1

D version of Jieba Chinese word segmentation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status GitHub tag Dub downloads

Jieba chinese word segmentation D Deimos Bindings.

Reference:

https://github.com/yanyiwu/cppjieba (upstream) https://github.com/shove70/cppjieba/tree/shove (Fork, Add APIs)

Quick Start:

import std.string : toStringz;
import std.conv : to;
import std.stdio: writeln;

import deimos.jieba.jieba;

string dict_path = "./dict/jieba.dict.utf8";
string hmm_path = "./dict/hmm_model.utf8";
string user_dict_path = "./dict/user.dict.utf8";
string idf_path = "./dict/idf.utf8";
string stop_word_path = "./dict/stop_words.utf8";

jieba_open(dict_path.toStringz, hmm_path.toStringz, user_dict_path.toStringz, idf_path.toStringz, stop_word_path.toStringz);

string s = "A chinese string";
size_t length;
AWord* words = jieba_cut(s.toStringz, true, &length);

for (size_t i = 0; i < length; i++)
{
    writeln(words[i].word.to!string);
}

jieba_free(words, length);
jieba_close();

About

D version of Jieba Chinese word segmentation.

License:MIT License


Languages

Language:C++ 63.2%Language:D 36.8%