Search for N-gram frequency

C/C++:

int sol_Seek5Grams( HGREN hEngine, int Type, const wchar_t * Word1, const wchar_t * Word2, const wchar_t * Word3, const wchar_t * Word4, const wchar_t * Word5 )

int sol_Seek5Grams8( HGREN hEngine, int Type, const char * Word1Utf8, const char * Word2Utf8, const char * Word3Utf8, const char * Word4Utf8, const char * Word5Utf8 )

C#:

int sol_Seek5Grams( IntPtr hEngine, int Type, string Word1, string Word2, string Word3, string Word4, string Word5 )

Delphi:

function sol_Seek5Grams( hEngine: PInteger; Flags: Integer; Word1: PWideChar; Word2: PWideChar; Word3: PWideChar; Word4: PWideChar; Word5: PWideChar ): Integer;

Parameters:

hEngine - grammatical dictionary instance handle.

Type - 0 for literal, 1 for lemmatized patterns.

Word1, Word2, Word3, Word4, Word5 - 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_Seek3Grams, sol_Seek4Grams.

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 freq51 = sol_Seek5Grams8( hEngine, 0, "СОБАКА", "И", "КОШКА", "НАШЛИ", "БОЛЬШОЕ" );
int freq52 = sol_Seek5Grams8( hEngine, 1, "СОБАКА", "И", "КОШКА", "НАШЛИ", "БОЛЬШОЕ" );

C# sample code:

IntPtr hEngine = GrammarEngine.sol_CreateGrammarEngineW("..\\..\\..\\..\\..\\..\\..\\bin-windows\\dictionary.xml");
  
int freq51 = GrammarEngine.sol_Seek5Grams( hEngine, 0, "СОБАКА", "И", "КОШКА", "НАШЛИ", "БОЛЬШОЕ" );
int freq52 = GrammarEngine.sol_Seek5Grams( 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 freq51, freq52: integer;
begin

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

 freq51 := sol_Seek5Grams( hEngine, 0, 'СОБАКА', 'И', 'КОШКА', 'НАШЛИ', 'БОЛЬШОЕ' );
 freq52 := sol_Seek5Grams( 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