Tags:
create new tag
view all tags

Stemmer Example Code

/*****************************************************************************/
/*                                                                           */
/*  Filename:     stemExample.cpp                                             */
/*  Author(s):    Jim Skon                                                   */
/*  Last Update:  1/21/2017                                                  */
/*                                                                           */
/*  This is a program that shows how to use the English word stemmer.        */
/*                                                                           */
/*                                                                           */
/*****************************************************************************/

#include <iostream>
#include <string>
#include <stdlib.h>
#include <utility>
#include <algorithm>
// Include stemming stuff                                                                                                                                 
#include "english_stem.h"

using namespace std;

main () {

  string word;

  stemming::english_stem<char, std::char_traits<char> > StemEnglish;

  while (1) {
    cout << "Enter word the word to find the stem of: ";
    cin >> word;
    /* Convert word to upper case*/
    transform(word.begin(), word.end(), word.begin(), ::toupper);
    string saveWord = word;
    /* Reduce to Stem */
    StemEnglish(word);
    cout << "The stemmed version of \"" << saveWord <<"\" is \"" << word << "\"" << endl;
  }
}
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2017-02-01 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback