Search for N-gram frequency

C/C++:

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

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

C#:

int sol_Seek3Grams( IntPtr hEngine, int Type, string Word1, string Word2, string Word3 )

Delphi:

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

Parameters:

hEngine - grammatical dictionary instance handle.

Type - 0 for literal, 1 for lemmatized patterns.

Word1, Word2, Word3 - 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_Seek2Grams, 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 freq31 = sol_Seek3Grams8( hEngine, 0, "СОБАКА", "И", "КОШКА" );
int freq32 = sol_Seek3Grams8( hEngine, 1, "СОБАКА", "И", "КОШКА" ); 
 

C# sample code:

IntPtr hEngine = GrammarEngine.sol_CreateGrammarEngineW("..\\..\\..\\..\\..\\..\\..\\bin-windows\\dictionary.xml");
  
int freq31 = GrammarEngine.sol_Seek3Grams( hEngine, 0, "СОБАКА", "И", "КОШКА" );
int freq32 = GrammarEngine.sol_Seek3Grams( hEngine, 1, "СОБАКА", "И", "КОШКА" ); 

Delphi sample:

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 freq31, freq32: integer;
begin

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

 freq31 := sol_Seek3Grams( hEngine, 0, 'СОБАКА', 'И', 'КОШКА' );
 freq32 := sol_Seek3Grams( 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