Simple Usage

The procedure:

  1. Create a new empty console project in Visual Studio.
  2. Copy/paste the source code below (Image 1) into the main program file.
  3. Download and add at least next references to the project: "LemmaSharp", "LemmaSharpPrebuilt", "LemmaSharpPrebuiltCompact" and "Lzma#" (download the required files from the links above).
  4. Execute. The output should like similar as the console output shown below on Image 2.
  5. Extend the solution, experiment and have fun.
 using  System;
 using  LemmaSharp;
 
 namespace  LemaNow
 {
     classProgram 
     {
         static void  Main(string [] args)
         {
             string  exampleSentence = "On the other hand, inflectional paradigms, "  +
                 "or lists of inflected forms of typical words (such as sing, sang, "  +
                 "sung, sings, singing, singer, singers, song, songs, songstress, "  +
                 "songstresses in English) need to be analyzed according to criteria "  +
                 "for uncovering the underlying lexical stem." ;
 
             string [] exampleWords = exampleSentence.Split(
                 new  char [] {' ', ',', '.', ')', '('}, StringSplitOptions .RemoveEmptyEntries);
             
             ILemmatizer  lmtz = new  LemmatizerPrebuiltCompact (LemmaSharp.LanguagePrebuilt .English);
 
             Console .ForegroundColor = ConsoleColor .Green;
             Console .WriteLine("Example sentence lemmatized" );
             Console .WriteLine("        WORD ==> LEMMA" );
             foreach  (string  word in  exampleWords)
                 LemmatizeOne(lmtz, word);
             
             Console .ForegroundColor = ConsoleColor .White;
         }
 
         private  static  void  LemmatizeOne(LemmaSharp.ILemmatizer  lmtz, string  word)
         {
             string  wordLower = word.ToLower();
             string  lemma = lmtz.Lemmatize(wordLower);
             Console .ForegroundColor = wordLower == lemma ? ConsoleColor .White : ConsoleColor .Red;
             Console .WriteLine("{0,12} ==> {1}" , word, lemma);
         }
     }
 }

Image 1: Example source code

Example sentence lemmatized
        WORD ==> LEMMA
          On ==> on
         the ==> the
       other ==> other
        hand ==> hand
inflectional ==> inflectional
   paradigms ==> paradigm
          or ==> or
       lists ==> list
          of ==> of
   inflected ==> inflect
       forms ==> form
          of ==> of
     typical ==> typical
       words ==> word
        such ==> such
          as ==> as
        sing ==> sing
        sang ==> sing
        sung ==> sing
       sings ==> sing
     singing ==> sing
      singer ==> singer
     singers ==> singer
        song ==> song
       songs ==> song
  songstress ==> songstress
songstresses ==> songstress
          in ==> in
     English ==> english
        need ==> need
          to ==> to
          be ==> be
    analyzed ==> analyze
   according ==> accord
          to ==> to
    criteria ==> criterion
         for ==> for
  uncovering ==> uncover
         the ==> the
  underlying ==> underlie
     lexical ==> lexical
        stem ==> stem
Press any key to continue . . .

Image 2: Example console output