Skip to content

Commit adc22fb

Browse files
add wrapper for word manager
1 parent 19cad8a commit adc22fb

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

nvdaHelper/cppjieba/cppjieba.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ int segmentOffsets(const char* text, int** charOffsets, int* outLen) {
7171
return 0;
7272
}
7373

74+
bool insertUserWord(const string& word, int freq, const string& tag = cppjieba::UNKNOWN_TAG) {
75+
return JiebaSingleton::getInstance().InsertUserWord(word, freq, tag);
76+
}
77+
78+
bool find(const string& word) {
79+
return JiebaSingleton::getInstance().Find(word);
80+
}
81+
82+
bool deleteUserWord(const string& word, const string& tag = cppjieba::UNKNOWN_TAG) {
83+
return JiebaSingleton::getInstance().DeleteUserWord(word, tag);
84+
}
85+
7486
void freeOffsets(int* ptr) {
7587
if (ptr) free(ptr);
7688
}

nvdaHelper/cppjieba/cppjieba.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ LIBRARY cppjieba
22
EXPORTS
33
initJieba
44
segmentOffsets
5+
insertUserWord
6+
find
7+
deleteUserWord
58
freeOffsets

nvdaHelper/cppjieba/cppjieba.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ JIEBA_API int initJieba();
5656
/// @return 0 on success, -1 on failure.
5757
JIEBA_API int segmentOffsets(const char* text, int** charOffsets, int* outLen);
5858

59+
/// Wrapper for word management
60+
JIEBA_API bool insertUserWord(const string& word, int freq, const string& tag);
61+
JIEBA_API bool find(const string& word);
62+
JIEBA_API bool deleteUserWord(const string& word, const string& tag);
63+
5964
/// @brief Free memory allocated by segmentOffsets.
6065
JIEBA_API void freeOffsets(int* ptr);
6166

nvdaHelper/cppjieba/sconscript

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ sourceFiles = [
3535
"cppjieba.def",
3636
]
3737

38+
env.AppendUnique(
39+
CCFLAGS=['/wd4819'],
40+
CXXFLAGS=['/wd4819'],
41+
)
42+
3843
cppjiebaLib = env.SharedLibrary(target="cppjieba", source=sourceFiles)
3944

4045
if not os.path.exists(outDir.Dir("dicts").get_abspath()) or not os.listdir(outDir.Dir("dicts").get_abspath()): # insure dicts installation happens only once and avoid a scons' warning

0 commit comments

Comments
 (0)