How to use n-gram - 2 common examples

To help you get started, we’ve selected a few n-gram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github words / dice-coefficient / index.js View on Github external
function diceCoefficient(value, alternative) {
  var val = String(value).toLowerCase()
  var alt = String(alternative).toLowerCase()
  var left = val.length === 1 ? [val] : bigrams(val)
  var right = alt.length === 1 ? [alt] : bigrams(alt)
  var leftLength = left.length
  var rightLength = right.length
  var index = -1
  var intersections = 0
  var leftPair
  var rightPair
  var offset

  while (++index < leftLength) {
    leftPair = left[index]
    offset = -1

    while (++offset < rightLength) {
      rightPair = right[offset]

      if (leftPair === rightPair) {
github words / dice-coefficient / index.js View on Github external
function diceCoefficient(value, alternative) {
  var val = String(value).toLowerCase()
  var alt = String(alternative).toLowerCase()
  var left = val.length === 1 ? [val] : bigrams(val)
  var right = alt.length === 1 ? [alt] : bigrams(alt)
  var leftLength = left.length
  var rightLength = right.length
  var index = -1
  var intersections = 0
  var leftPair
  var rightPair
  var offset

  while (++index < leftLength) {
    leftPair = left[index]
    offset = -1

    while (++offset < rightLength) {
      rightPair = right[offset]

n-gram

Get n-grams from text

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis

Popular n-gram functions