MyNixOS website logo
Description

Detect the Language of Text.

With no external dependencies and support for 335 languages; all languages spoken by more than one million speakers. 'Franc' is a port of the 'JavaScript' project of the same name, see <https://github.com/wooorm/franc>.

franc

Detect the Language of Text

Project Status: Active - The project has reached a stable, usablestate and is being activelydeveloped. R buildstatus CRAN RStudio mirrordownloads CoverageStatus

Franc has no external dependencies and supports 310 languages; all languages spoken by more than one million speakers. Franc is a port of the JavaScript project of the same name, see https://github.com/wooorm/franc.

Installation

install.packages("franc")

Usage

library(franc)

Simply supply the text, and franc detects its language:

franc("Alle menslike wesens word vry")
#> [1] "afr"
franc("এটি একটি ভাষা একক IBM স্ক্রিপ্ট")
#> [1] "ben"
franc("Alle mennesker er født frie og")
#> [1] "nno"
head(franc_all("O Brasil caiu 26 posições"))
#>   language     score
#> 1      por 1.0000000
#> 2      src 0.8800937
#> 3      glg 0.8702576
#> 4      snn 0.8637002
#> 5      bos 0.8168618
#> 6      hrv 0.8103044

und is the undefined language, this is returned if the input is too short (shorter than 10 characters by default).

franc("the")
#> [1] "und"
franc("the", min_length = 3)
#> [1] "sco"

You can provide a whitelist or a blacklist:

franc_all("O Brasil caiu 26 posições",
    whitelist = c("por", "src", "glg", "spa"))
#>   language     score
#> 1      por 1.0000000
#> 2      src 0.8800937
#> 3      glg 0.8702576
#> 4      spa 0.7995316
head(franc_all("O Brasil caiu 26 posições",
    blacklist = c("src", "glg", "lav")))
#>   language     score
#> 1      por 1.0000000
#> 2      snn 0.8637002
#> 3      bos 0.8168618
#> 4      hrv 0.8103044
#> 5      cat 0.8065574
#> 6      spa 0.7995316

Supported languages

The R version of franc supports 310 languages. By default only the languages with more than 1 million speakers are used, this is 175 languages. The min_speakers argument can relax this, and allows using more languages:

head(franc_all("O Brasil caiu 26 posições"))
#>   language     score
#> 1      por 1.0000000
#> 2      src 0.8800937
#> 3      glg 0.8702576
#> 4      snn 0.8637002
#> 5      bos 0.8168618
#> 6      hrv 0.8103044
head(franc_all("O Brasil caiu 26 posições", min_speakers = 0))
#>   language     score
#> 1      lad 1.0000000
#> 2      por 0.9442724
#> 3      pov 0.8788147
#> 4      ast 0.8677576
#> 5      roh 0.8363556
#> 6      src 0.8310482

License

MIT © Mango Solutions, Titus Wormer, Maciej Ceglowski, Jacob R. Rideout, Kent S. Johnson, Gábor Csárdi.

Metadata

Version

1.1.4

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows