//================================================================

// ===== COM Test Example for Dialing Lemmatizer (www.aot.ru) ==

// ===== Author: Alexey Sokirko, sokirko@yandex.ru, 2004 =======

//================================================================

 

program MorphTest;

 

{$APPTYPE CONSOLE}

 

uses

  SysUtils,

  ActiveX,

//Unit LEMMATIZERLib_TLB.pas is generated by Lemmatizer.dll. In Delphi 6 one should use menu "Project/Import Type Library".

  LEMMATIZERLib_TLB in       '..\..\..\..\Programme\Borland\Delphi6\Imports\LEMMATIZERLib_TLB.pas';

 

procedure TestRusLemmatizer(word : string);

var  RusLemmatizer : ILemmatizer;

     ParadigmCollection : IParadigmCollection;

     Lemma: WideString;

begin

    RusLemmatizer := CoLemmatizerRussian.Create;

    if  (RusLemmatizer = nil) then

    begin

        writeln('cannot load lemmatizer');

        halt(1);

    end;

 

    RusLemmatizer.LoadDictionariesRegistry();

    ParadigmCollection := RusLemmatizer.CreateParadigmCollectionFromForm(word, 1, 1);

    if  (ParadigmCollection.Count > 0) then

    begin

       Lemma := ParadigmCollection.Item[0].Norm;

       writeln('лемма(',word,') = ',Lemma);

    end

    else

        writeln('not found');

 

end;

 

var   hr :  HRESULT;

begin

 

try

    hr := CoInitialize(nil);

    if (hr <> S_OK) then

    begin

        writeln('cannot load Component Object Model(COM) library');

        halt(1);

    end;

    TestRusLemmatizer('маму');

    CoUninitialize();

except

    writeln('an exception occurred!');

end;

 

 

end.