language-detector

2.1.3

Detect language from a text string in Swift!
Al00X/LanguageDetector

What's New

v2.1.3

2023-12-31T16:06:10Z

Update readme

Language Detector

Version License

Detect languages of any given text with high accuracy!

This library can take a given text and detect its language using the database previously generated in the training phase.


Installation

To use this package, you need to set it up as a package dependency in Package.swift:

let package = Package(
  name: "MyPackage",
  dependencies: [
    .package(url: "https://github.com/Al00X/LanguageDetector.git", from: "2.0.0")
  ],
  targets: [
    .target(
      name: "MyTarget",
      dependencies: [
        .product(name: "LanguageDetector", package: "language-detector")
      ]
    )
  ]
)

Usage

You and either instantiate the class or use it statically.

Instance Use

let detector = LanguageDetector(languages: ["en", "it", "fr", "ar"])

// add more languages

detector.addLanguages(languages: ["es", "de"])

// detect

let result = detector.evaluate(text: "Hi there!") // [(String, Int)]

return result.first.0 // en

Static Use

let result = LanguageDetector.detect(text: "I'm on static", languages: ["en", "fr", "es"]) // String

return result // en

Supported languages

The library currently supports 110 languages. You can see the list of the languages here.



This package is inspired by php-language-detection


Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Sat Nov 16 2024 22:38:06 GMT-1000 (Hawaii-Aleutian Standard Time)