Lexicon API - adding new phrase entry


int sol_AddPhrase( HGREN hEngine, const wchar_t * Phrase, int LanguageID, int ClassID, int Flags )

int sol_AddPhrase8( HGREN hEngine, const char * PhraseUtf8, int LanguageID, int ClassID, int Flags )


int sol_AddPhrase( IntPtr hEngine, string Phrase, int LanguageID, int ClassID, int Flags )


function sol_AddPhrase( hEngine: PInteger; Phrase: PWideChar; LanguageID: integer; ClassID: integer; Flags: integer ): integer;


hEngine - grammatical dictionary instance handle.

Phrase - phrase text.

LanguageID - language ID or -1.

ClassID - part of speech ID or -1.

Flags - must always be 0 in current version.

Return value:

-1 - there is no matching phrase entry.

value>=0 - the primary key (id) of created phrase entry.


The functions sol_AddPhrase and sol_AdddPhrase8 differ in phrase text format. sol_AddPhrase accepts wide string, whereas sol_AddPhrase8 requires the text in utf-8.

Phrase ID can be used to get the extended information about entry (see sol_GetPhraseText, sol_GetPhraseLanguage, sol_GetPhraseClass) or to delete it using sol_DeletePhrase.

Dictionary instance is a result of sol_CreateGrammarEngine or sol_LoadDictionary call.

ORM Library includes the PhraseEntry class, the representation of phrase entry.



#include "solarix_grammar_engine.h"


HGREN hEngine = sol_CreateGrammarEngineW(L"..\\..\\bin-windows\\dictionary.xml");


int phrase_id = sol_AddPhrase( hEngine, L"dirt road", ENGLISH_LANGUAGE, ENG_NOUN, 0 );

// ...


IntPtr gren = SolarixGrammarEngineNET.GrammarEngine.sol_CreateGrammarEngineW("..\\..\\bin-windows\\dictionary.xml");

// ...

int phrase_id = SolarixGrammarEngineNET.GrammarEngine.sol_AddPhrase( hEngine, "dirt road", -1, -1, 0 );


uses SysUtils, Windows,
    _sg_api in '..\..\..\..\..\include\lem\solarix\_sg_api.pas',
    GrammarEngineApi in '..\..\..\..\..\include\lem\solarix\GrammarEngineApi.pas';

var hEngine: PInteger;
var id_phrase1, id_phrase2, id_phrase3: integer;
var phrase_text: WideString;

 hEngine := sol_CreateGrammarEngineA( '..\..\..\..\..\bin-windows\dictionary.xml' );

 id_phrase1 := sol_FindPhrase( hEngine, WideString('грамматический словарь русского языка'), 0 );
 id_phrase2 := sol_AddPhrase( hEngine, WideString('проверяем добавление фразы'), -1, -1, 0 );
 id_phrase3 := sol_FindPhrase( hEngine, WideString('проверяем добавление фразы'), 0 );

 phrase_text := sol_GetPhraseTextPAS( hEngine, id_phrase3 );
 sol_DeletePhrase( hEngine, id_phrase3 );



Related topics

Purchase the Grammatical Dictionary SDK

Phrase class - phrase entry representation in ORM library

Russian version of this page

Back to the list of API calls

API layer C++ source code: grammar_engine_api.cpp

  © Козиев Илья 2019
changed 04-Apr-11