N-gram Frequency Counter


Tools “N-gram Frequency Counter” for counting the frequency of n number of elements frequency. Symbols and tokens can act as elements, as well as words and even regular expressions. Arbitrary characters is an input for the service. The result of the service is a list of n-grams with their frequencies in the input text.

 

Access to the service via the API

To access the service «N-gram Frequency Counter» via the API, you should send an AJAX-request (type: POST) to the address https://corpus.by/NgramFrequencyCounter/api.php. With an input array data the following parameters are passed:

  • localization — resulting data localization language.
  • text — arbitrary set of characters.
  • gramSelector — the type of «gram» – the type of elements in a sequence to be processsed. Available types: character, word.
  • n — the number of «gram» in one n-gram.
  • caseSensitive — marker for case sensitive characters counting.
  • delimiterSensitive — marker for taking into account dilimiters (spaces, punctuation) while counting.

Example of AJAX-request:

$.ajax({
   type: “POST”,
   url: “https://corpus.by/NgramFrequencyCounter/api.php”,
   data:{
      “localization”: “en”,
      “text”: “Груша цвіла апошні год.
Усе галіны яе, усе вялікія расохі, да апошняга пруціка, былі ўсыпаны буйным бела-ружовым цветам. Яна кіпела, млела і раскашавалася ў пчаліным звоне, цягнула да сонца сталыя лапы і распускала ў яго ззянні маленькія, кволыя пальцы новых парасткаў. І была яна такая магутная і свежая, так утрапёна спрачаліся ў яе ружовым раі пчолы, што, здавалася, не будзе ёй зводу і не будзе ёй канца.”,

      “gramSelector“: “character“,
      “n“: “3”,
      “caseSensitive“: “1”,
      “delimiterSensitive“: “1”
   },
   success: function(msg){ },
   error: function() { }
});

The server returns a JSON-array with the following parameters:

  • text — input set of characters.
  • result — n-grams list with their frequencies.
  • headline — statistical data.

For example, the following reply will be formed on the above listed AJAX-request:

[
   {
      “text”: “Груша цвіла апошні год.
Усе галіны яе, усе вялікія расохі, да апошняга пруціка, былі ўсыпаны буйным бела-ружовым цветам. Яна кіпела, млела і раскашавалася ў пчаліным звоне, цягнула да сонца сталыя лапы і распускала ў яго ззянні маленькія, кволыя пальцы новых парасткаў. І была яна такая магутная і свежая, так утрапёна спрачаліся ў яе ружовым раі пчолы, што, здавалася, не будзе ёй зводу і не будзе ёй канца.”,

      “result”: “5: «ла »
4: «ым »
4: «рас»
4: « ра»
4: « і »
3: «ела»
3: « бу»
3: « ў »
3: «а с»
3: «алі»
3: «я, »
3: «ала»
3: «овы»
3: «на »
2: «зво»
2: «да »
2: « зв»

…”,
      “headline”: “Number of units in the text: <b>408</b><br>Number of unique <b>3-grams</b>: <b>316</b><br>”
   }
]

 

Links to sources

Service page: https://corpus.by/NgramFrequencyCounter/?lang=be

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.