Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ jobs:

- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Update apt-get
Expand Down
4 changes: 2 additions & 2 deletions build-and-run
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ simple.example() {
run "cd output/bin/"
run "cat ${ProjectRoot}/example.sql ${ProjectRoot}/example-jieba.sql | ./sqlite3"
run "./simple_cpp_example"
run "cd ${ProjectRoot}"
run "python3 examples/python3/db_connector.py './output/bin/libsimple'"
# run "cd ${ProjectRoot}"
# run "python3 examples/python3/db_connector.py './output/bin/libsimple'"
}

main() {
Expand Down
4 changes: 2 additions & 2 deletions build-and-run-no-jieba
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ simple.example() {
run "cd output-no-jieba/bin/"
run "./sqlite3 < ${ProjectRoot}/example.sql"
run "./simple_cpp_example"
run "cd ${ProjectRoot}"
run "python3 examples/python3/db_connector.py"
# run "cd ${ProjectRoot}"
# run "python3 examples/python3/db_connector.py"
}

main() {
Expand Down
9 changes: 9 additions & 0 deletions src/simple_tokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ std::string SimpleTokenizer::tokenize_jieba_query(const char *text, int textLen,
std::vector<cppjieba::Word> words;
jieba.Cut(text, words);
for (auto word : words) {
// if all char is the same category, then use that category
// otherwise use OTHER
// fix https://github.com/wangfenjin/simple/issues/176
TokenCategory category = from_char(text[word.offset]);
for (auto c : word.word) {
if (from_char(c) != category) {
category = TokenCategory::OTHER;
break;
}
}
append_result(result, word.word, category, word.offset, flags);
}
return result;
Expand Down
4 changes: 4 additions & 0 deletions test/tokenizer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
query.push_back(R"VAGON(( z+h+o+u* OR zhou* ) AND "杰" AND "伦")VAGON");
arr.push_back("杰伦 zhou 123");
query.push_back(R"VAGON("杰" AND "伦" AND ( z+h+o+u* OR zhou* ) AND "123"*)VAGON");
arr.push_back("c#");
query.push_back(R"VAGON(c* AND "#")VAGON");
for (int i = 0; i < arr.size(); i++) {

Check warning on line 23 in test/tokenizer_test.cc

View workflow job for this annotation

GitHub Actions / Linux (ubuntu-22.04)

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Check warning on line 23 in test/tokenizer_test.cc

View workflow job for this annotation

GitHub Actions / Linux (ubuntu-24.04-arm)

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
std::string s = arr[i];
std::cout << s << " as doc:\n";
t->tokenize(nullptr, FTS5_TOKENIZE_DOCUMENT, s.c_str(), s.length(), printFn);
Expand All @@ -42,7 +44,7 @@
query.push_back(R"VAGON(zhou* AND "杰" AND "伦")VAGON");
arr.push_back("杰伦123");
query.push_back(R"VAGON("杰" AND "伦" AND "123"*)VAGON");
for (int i = 0; i < arr.size(); i++) {

Check warning on line 47 in test/tokenizer_test.cc

View workflow job for this annotation

GitHub Actions / Linux (ubuntu-22.04)

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
std::string s = arr[i];
std::cout << s << " as doc:\n";
t->tokenize(nullptr, FTS5_TOKENIZE_DOCUMENT, s.c_str(), s.length(), printFn);
Expand All @@ -66,7 +68,9 @@
query.push_back(R"VAGON(( z+h+o+u* OR zhou* ) AND "杰伦")VAGON");
arr.push_back("杰伦 zhou 123");
query.push_back(R"VAGON("杰伦" AND ( z+h+o+u* OR zhou* ) AND "123"*)VAGON");
arr.push_back("c#");
query.push_back(R"VAGON("c#")VAGON");
for (int i = 0; i < arr.size(); i++) {

Check warning on line 73 in test/tokenizer_test.cc

View workflow job for this annotation

GitHub Actions / Linux (ubuntu-22.04)

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
std::string s = arr[i];
std::cout << s << " as doc:\n";
t->tokenize(nullptr, FTS5_TOKENIZE_DOCUMENT, s.c_str(), s.length(), printFn);
Expand All @@ -90,7 +94,7 @@
query.push_back(R"VAGON(zhou* AND "杰伦")VAGON");
arr.push_back("杰伦123");
query.push_back(R"VAGON("杰伦" AND "123"*)VAGON");
for (int i = 0; i < arr.size(); i++) {

Check warning on line 97 in test/tokenizer_test.cc

View workflow job for this annotation

GitHub Actions / Linux (ubuntu-22.04)

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
std::string s = arr[i];
std::cout << s << " as doc:\n";
t->tokenize(nullptr, FTS5_TOKENIZE_DOCUMENT, s.c_str(), s.length(), printFn);
Expand Down
Loading