summaryrefslogtreecommitdiff
path: root/src/mongo/db/fts/stemmer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/fts/stemmer.cpp')
-rw-r--r--src/mongo/db/fts/stemmer.cpp51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/mongo/db/fts/stemmer.cpp b/src/mongo/db/fts/stemmer.cpp
index dd260f92305..6ce0fdfb538 100644
--- a/src/mongo/db/fts/stemmer.cpp
+++ b/src/mongo/db/fts/stemmer.cpp
@@ -36,39 +36,36 @@
namespace mongo {
- namespace fts {
+namespace fts {
- using std::string;
+using std::string;
- Stemmer::Stemmer( const FTSLanguage& language ) {
- _stemmer = NULL;
- if ( language.str() != "none" )
- _stemmer = sb_stemmer_new(language.str().c_str(), "UTF_8");
- }
-
- Stemmer::~Stemmer() {
- if ( _stemmer ) {
- sb_stemmer_delete(_stemmer);
- _stemmer = NULL;
- }
- }
-
- string Stemmer::stem( const StringData& word ) const {
- if ( !_stemmer )
- return word.toString();
+Stemmer::Stemmer(const FTSLanguage& language) {
+ _stemmer = NULL;
+ if (language.str() != "none")
+ _stemmer = sb_stemmer_new(language.str().c_str(), "UTF_8");
+}
- const sb_symbol* sb_sym = sb_stemmer_stem( _stemmer,
- (const sb_symbol*)word.rawData(),
- word.size() );
+Stemmer::~Stemmer() {
+ if (_stemmer) {
+ sb_stemmer_delete(_stemmer);
+ _stemmer = NULL;
+ }
+}
- if ( sb_sym == NULL ) {
- // out of memory
- abort();
- }
+string Stemmer::stem(const StringData& word) const {
+ if (!_stemmer)
+ return word.toString();
- return string( (const char*)(sb_sym), sb_stemmer_length( _stemmer ) );
- }
+ const sb_symbol* sb_sym =
+ sb_stemmer_stem(_stemmer, (const sb_symbol*)word.rawData(), word.size());
+ if (sb_sym == NULL) {
+ // out of memory
+ abort();
}
+ return string((const char*)(sb_sym), sb_stemmer_length(_stemmer));
+}
+}
}