Search for N-gram frequency

C/C++:

int sol_Seek2Grams( HGREN hEngine, int Type, const wchar_t * Word1, const wchar_t * Word2 )

int sol_Seek2Grams8( HGREN hEngine, int Type, const char * Word1Utf8, const char * Word2Utf8 )

C#:

int sol_Seek2Grams( IntPtr hEngine, int Type, string Word1, string Word2 )

Delphi:

function sol_Seek2Grams( hEngine: PInteger; Flags: Integer; Word1: PWideChar; Word2: PWideChar ): Integer;

Parameters:

hEngine - grammatical dictionary instance handle.

Type - 0 for literal, 1 for lemmatized patterns.

Word1, Word2 - N-gram items.

Return value:

The word frequency.

Remarks

The following functions can be used to get the frequency of particular N-gram: sol_Seek1Grams, sol_Seek3Grams, sol_Seek4Grams, sol_Seek5Grams.

Total number of N-grams can be get via sol_CountNGrams.

There are different types of N-grams database storage. Grammatical dictionary reads the database parameters from dictionary configuration file.

Examples

C++ sample code:

#include "solarix_grammar_engine.h"

int freq21 = sol_Seek2Grams8( hEngine, 0, "СОБАКА", "И" );
int freq22 = sol_Seek2Grams8( hEngine, 1, "СОБАКА", "И" );
 

C# sample code:

IntPtr hEngine = GrammarEngine.sol_CreateGrammarEngineW("..\\..\\..\\..\\..\\..\\..\\bin-windows\\dictionary.xml");
  
int freq21 = GrammarEngine.sol_Seek2Grams( hEngine, 0, "СОБАКА", "И" );
int freq22 = GrammarEngine.sol_Seek2Grams( hEngine, 1, "СОБАКА", "И" );

Delphi ample code:

program Project1;
{$APPTYPE CONSOLE}

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

var hEngine: PInteger;
var freq21, freq22: integer;
begin

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

 freq21 := sol_Seek2Grams( hEngine, 0, 'СОБАКА', 'И' );
 freq22 := sol_Seek2Grams( hEngine, 1, 'СОБАКА', 'И' );

 { ... }
 
 rc := sol_DeleteGrammarEngine(hEngine);

end.

Navigation

Purchase the Grammatical Dictionary SDK

Russian version of this page

N-grams database assembler

API layer C++ source code: grammar_engine_api.cpp

Back to API functions list

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