forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
615 additions
and
22,047 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
all: cws pos par ner multi_cws | ||
|
||
cws: cws.cpp | ||
g++ -o cws cws.cpp -I./ \ | ||
-I../include/ \ | ||
-I../thirdparty/boost/include \ | ||
-L../lib/ -lsegmentor -lboost_regex | ||
|
||
pos: pos.cpp | ||
g++ -o pos pos.cpp -I./ \ | ||
-I../include/ \ | ||
-L../lib/ -lpostagger | ||
|
||
ner: ner.cpp | ||
g++ -o ner ner.cpp -I./ \ | ||
-I../src/ner/ \ | ||
-L../lib/ -lner | ||
|
||
par: par.cpp | ||
g++ -o par par.cpp -I./ \ | ||
-I../src/parser/ \ | ||
-L../lib -lparser | ||
|
||
multi_cws: multi_cws.cpp | ||
g++ -o multi_cws multi_cws.cpp \ | ||
thirdparty/tinythreadpp/tinythread.cpp \ | ||
-I./ \ | ||
-I../include/ \ | ||
-I../thirdparty/boost/include/ \ | ||
-I./thirdparty/tinythreadpp/ \ | ||
-L../lib/ -lsegmentor -lboost_regex -lpthread | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm cws | ||
rm pos | ||
rm ner | ||
rm par | ||
rm multi_cws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include "segment_dll.h" | ||
|
||
int main(int argc, char * argv[]) { | ||
if (argc < 2) { | ||
std::cerr << "cws [model path] [lexicon_file]" << std::endl; | ||
return 1; | ||
} | ||
|
||
void * engine = 0; | ||
if (argc == 2) { | ||
engine = segmentor_create_segmentor(argv[1]); | ||
} else if (argc == 3) { | ||
engine = segmentor_create_segmentor(argv[1], argv[2]); | ||
} | ||
|
||
if (!engine) { | ||
return -1; | ||
} | ||
std::vector<std::string> words; | ||
|
||
const char * suite[2] = { | ||
"What's wrong with you? 别灰心! http://t.cn/zQz0Rn", | ||
"台北真的是天子骄子吗?",}; | ||
|
||
for (int i = 0; i < 2; ++ i) { | ||
words.clear(); | ||
int len = segmentor_segment(engine, suite[i], words); | ||
for (int i = 0; i < len; ++ i) { | ||
std::cout << words[i]; | ||
if (i+1 == len) std::cout <<std::endl; | ||
else std::cout<< "|"; | ||
} | ||
} | ||
|
||
segmentor_release_segmentor(engine); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include "ner_dll.h" | ||
|
||
int main(int argc, char * argv[]) { | ||
if (argc < 2) { | ||
std::cerr << "usage: ./ner [model_path]" << std::endl; | ||
return -1; | ||
} | ||
|
||
void * engine = ner_create_recognizer(argv[1]); | ||
if (!engine) { | ||
std::cerr << "failed to load model" << std::endl; | ||
return -1; | ||
} | ||
|
||
std::vector<std::string> words; | ||
std::vector<std::string> postags; | ||
|
||
words.push_back("中国"); postags.push_back("ns"); | ||
words.push_back("国际"); postags.push_back("n"); | ||
words.push_back("广播"); postags.push_back("n"); | ||
words.push_back("电台"); postags.push_back("n"); | ||
words.push_back("创办"); postags.push_back("v"); | ||
words.push_back("于"); postags.push_back("p"); | ||
words.push_back("1941年"); postags.push_back("m"); | ||
words.push_back("12月"); postags.push_back("m"); | ||
words.push_back("3日"); postags.push_back("m"); | ||
words.push_back("。"); postags.push_back("wp"); | ||
|
||
std::vector<std::string> tags; | ||
|
||
ner_recognize(engine, words, postags, tags); | ||
|
||
for (int i = 0; i < tags.size(); ++ i) { | ||
std::cout << words[i] << "\t" << postags[i] << "\t" << tags[i] << std::endl; | ||
} | ||
|
||
ner_release_recognizer(engine); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include "parser_dll.h" | ||
|
||
int main(int argc, char * argv[]) { | ||
if (argc < 2) { | ||
return -1; | ||
} | ||
|
||
void * engine = parser_create_parser(argv[1]); | ||
if (!engine) { | ||
return -1; | ||
} | ||
|
||
std::vector<std::string> words; | ||
std::vector<std::string> postags; | ||
|
||
words.push_back("一把手"); postags.push_back("n"); | ||
words.push_back("亲自"); postags.push_back("d"); | ||
words.push_back("过问"); postags.push_back("v"); | ||
words.push_back("。"); postags.push_back("wp"); | ||
|
||
std::vector<int> heads; | ||
std::vector<std::string> deprels; | ||
|
||
parser_parse(engine, words, postags, heads, deprels); | ||
|
||
for (int i = 0; i < heads.size(); ++ i) { | ||
std::cout << words[i] << "\t" << postags[i] << "\t" | ||
<< heads[i] << "\t" << deprels[i] << std::endl; | ||
} | ||
|
||
parser_release_parser(engine); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include "postag_dll.h" | ||
|
||
int main(int argc, char * argv[]) { | ||
if (argc < 1) { | ||
return -1; | ||
} | ||
|
||
void * engine = postagger_create_postagger(argv[1]); | ||
if (!engine) { | ||
return -1; | ||
} | ||
|
||
std::vector<std::string> words; | ||
|
||
words.push_back("我"); | ||
words.push_back("是"); | ||
words.push_back("中国人"); | ||
|
||
std::vector<std::string> tags; | ||
|
||
postagger_postag(engine, words, tags); | ||
|
||
for (int i = 0; i < tags.size(); ++ i) { | ||
std::cout << words[i] << "/" << tags[i]; | ||
if (i == tags.size() - 1) std::cout << std::endl; | ||
else std::cout << " "; | ||
|
||
} | ||
|
||
postagger_release_postagger(engine); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.