How to use the franc function in franc

To help you get started, we’ve selected a few franc 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 rsimmons / voracious / src / util / languages.js View on Github external
export function detectIso6393(text) {
  // franc returns ISO 639-3 codes, including 'und' for undetermined
  return franc(text);
}
github hubtype / botonic / packages / botonic-nlu / src / preprocessing.js View on Github external
export function detectLang(input, langs) {
  let res = franc(input, { whitelist: langs.map(l => langs.where('1', l)[3]) })
  if (res === 'und') {
    return langs[0]
  }
  return langs.where('3', res)[1]
}
github busyorg / busy / src / widgets / Flag.js View on Github external
export default ({ title, body, className }) => {
  const language = franc(`${title} ${striptags(remarkable.render(body))}`);
  const textLength = (`${title} ${striptags(remarkable.render(body))}`).length;
  if (!(language !== 'eng' && language !== 'sco' && textLength > 255)) {
    return null;
  }
  return (
    <span>
      
        <img src="{`/img/flag/${getCountryCode(language)}.svg`}" alt="{language}">
      
    </span>
  );
};
github huridocs / uwazi / app / shared / languages.js View on Github external
  detect: (text, purpose = 'elastic') => get(franc(text), purpose)
};
github huridocs / uwazi / app / api / search / languages.js View on Github external
detect: (text) => {
    return languages[franc(text)] || 'other';
  }
};

franc

Detect the language of text

MIT
Latest version published 4 months ago

Package Health Score

64 / 100
Full package analysis

Popular franc functions