yanyiwu / cjieba Goto Github PK
View Code? Open in Web Editor NEWCppJieba的C语言api
License: MIT License
CppJieba的C语言api
License: MIT License
@yanyiwu 你好
首先感谢贡献 cjieba 和 cppjieba.
似乎 cjieba 的 api 已经稳定许久,个人觉得对于很多简单的任务也已经非常方便好用,不知 license 方面是怎么考虑的,我看 cppjieba 是 MIT,但这边没有明确的许可。提这个问题的具体原因是我最近在工作中用 Julia wrap 了一下 cjieba,想着收拾一下提交到 Julia 的 package registry 去,这样 Julia 社区也比较方便使用。
按照 Julia 那边的生态,这涉及到第一步用 BinaryBuilder.jl 把 c 代码编译打包成可以直接安装的 Julia package,然后第二步一般会再写一个纯 Julia 的 package 调用这个打包版本的 c 代码(使用 Julia 的 ccall
宏),提供非 ccall 的 API.
第一步我基本做完了,但在社区管理员提出因为 cjieba 没有显式的许可声明,所以不太好 merge PR。他说的确实也是对的,我不该假设 cjieba 和 cppjieba 使用同样的许可。
所以想问一下你,有否考虑为 cjieba 添加明确的许可声明。
相关 PR 讨论:
JuliaPackaging/Yggdrasil#5585
谢谢,
zxy
请问cjieba在vs2019下怎么配置才能使用呢?我在项目属性的include选项中包含了lib和deps文件夹。但是依然提示无法打开源文件“lib/jieba.h”
请问有预编译好的DLL下载吗?我想在Delphi里面调用。谢谢。
代码如下,主要是调用了x->extractor.Extract,不知这种写法是否妥当。
`
CJiebaWord* ExtractWithoutTags(Jieba handle, const char* sentence, size_t len, const char* tagname, size_t topn) {
cppjieba::Jieba* x = (cppjieba::Jieba*)handle;
vectorcppjieba::KeywordExtractor::Word words;
string wordtag, tagstring;
tagstring = tagname;
tagstring = tagstring!=""? "," + tagstring + ",":"";
x->extractor.Extract(sentence, words, topn5);
CJiebaWord res = (CJiebaWord*)malloc(sizeof(CJiebaWord) * (words.size() + 1));
size_t i, j = 0;
for (i = 0, j = 0; i < words.size(); i++) {
if (j == topn) { break; }
assert(words[i].offsets.size() > 0);
size_t offset = words[i].offsets[0];
assert(offset < len);
if (tagstring != "") {
wordtag = x->LookupTag(words[i].word);
wordtag = "," + wordtag + ",";
if (tagstring.find(wordtag) == string::npos) {
res[j].word = sentence + offset;
res[j].len = words[i].word.size();
j++;
}
}
else {
res[j].word = sentence + offset;
res[j].len = words[i].word.size();
j++;
}
}
res[j].word = NULL;
res[j].len = 0;
return res;
}
`
本以为 把 lib/jieba.cpp 中的 Cut 函数里的,
x->Cut(s, words);
改为:
x->CutForSearch(s, words);
就应该可以了。
但是不行。应该如何改才能使CutForSearch 正确?谢谢
我在 ubuntu 14.04上 需要加 -lm 才能 make。
all: cjieba_demo
cjieba_demo: libcjieba.a
gcc -o cjieba_demo cjieba_demo.c -L./ -lcjieba -lstdc++ -lm
libcjieba.a:
g++ -DLOGGER_LEVEL=LL_WARN -std=c++11 -o c_api.o -c src/c_api.cpp
ar rs libcjieba.a c_api.o
clean:
rm *.a *.o cjieba_demo
否则报:
/usr/bin/ld: .//libcjieba.a(c_api.o): undefined reference to symbol 'log@@GLIBC_2.0'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.