Sha256: 4870d8050b70a098f4d5139304f7fff01bbba8a348ba21561cdd41d708806389

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

#include <stdio.h>
#include "./next_phoneme_length.h"
void find_phonemes(int *string, int string_length, int *count, int *lengths) {
  int i = 0;
  int length;
  while (i < string_length) {
    length = next_phoneme_length(string, i, string_length);
    if (length) {
      lengths[(*count)++] = length;
      i += length;
    } else {
      i++;
    }
  }
}

void print_phoneme(int *string, int offset, int length, int padding) {
  int p;
  int max = padding;
  if (length > max) {
    max = length;
  }

  for (p = 0; p < length; p++) {
    putchar(string[offset + p]);
  }
  // The printable characters take up to four bytes. If a phoneme takes 1-4 we
  // assume the padding is the same. If it takes 5-8 we subtract one from the
  // padding because it'll have printed another character.
  for (p = (length / 4)+1; p < max; p++) {
    printf(" ");
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phonetics-1.9.0 ext/c_levenshtein/phonemes.c
phonetics-1.8.0 ext/c_levenshtein/phonemes.c