Lexicon API - retrieving the phrase entry contents

C/C++:

wchar_t * sol_GetPhraseText( HGREN hEngine, int PhraseID )

char * sol_GetPhraseText8( HGREN hEngine, int PhraseID )

C#:

IntPtr sol_GetPhraseText( IntPtr hEngine, int PhraseID )

string sol_GetPhraseTextFX( IntPtr hEngine, int PhraseID )

Delphi:

function sol_GetPhraseText( hEngine: PInteger; PhraseID: integer ): PWideChar;

function sol_GetPhraseTextPAS( hEngine: PInteger; PhraseID: integer ): WideString;

Parameters:

hEngine - grammatical dictionary instance handle.

PhraseID - phrase entry ID.

Return value:

-1 - there is no matching phrase entry.

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

Remarks

sol_GetPhraseText and sol_GetPhraseText8 return the pointers to c-style strings. The callee must release the pointers via sol_Free. Delphi and .NET wrappers provide two special functions sol_GetPhraseTextPAS and sol_GetPhraseTextFX which return the platform native strings, that is WideString and System.String respectively.

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.

Examples

C++:

#include "solarix_grammar_engine.h"

...

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

int phrase_id = sol_FindPhrase( hEngine, L"dirt road", 0 );
char * text_utf8 = sol_GetPhraseText( hEngine, phrase_id );
// ...
sol_Free(hEngine,text_utf8);  

C#:

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

// ...

int phrase_id = SolarixGrammarEngineNET.GrammarEngine.sol_FindPhrase( hEngine, "dirt road", 0 );
string text = SolarixGrammarEngineNET.GrammarEngine.sol_GetPhraseTextFX( hEngine, phrase_id );

Пример на Delphi:

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

var hEngine: PInteger;
var id_phrase: integer;
var phrase_text: WideString;
begin

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

 id_phrase1 := sol_FindPhrase( hEngine, WideString('проверяем добавление фразы'), 0 );
 phrase_text := sol_GetPhraseTextPAS( hEngine, id_phrase3 );

 sol_DeleteGrammarEngine(hEngine);

end.

Related topics

Purchase the Grammatical Dictionary SDK

Phrase class - phrase entry representation in ORM library

Russian version of this page

API layer C++ source code: grammar_engine_api.cpp

Back to the list of API calls

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