ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - goodsign/libtextcat: Cgo binding for libtextcat C library
Cgo binding for libtextcat C library. Contribute to goodsign/libtextcat development by creating an account on GitHub.
Visit Site

GitHub - goodsign/libtextcat: Cgo binding for libtextcat C library

GitHub - goodsign/libtextcat: Cgo binding for libtextcat C library

About

Cgo binding for libtextcat C library. Guaranteed compatibility with version 2.2.

Installation

Installation consists of several simple steps. They may be a bit different on your target system (e.g. require more permissions) so adapt them to the parameters of your system.

Get libtextcat C library code

NOTE: If this link is not working or there are some problems with downloading, there is a stable version 2.2 snapshot saved in Downloads.

Build and install libtextcat C library

From the directory, where you unarchived libtextcat, run:

./configure
make
sudo make install
sudo ldconfig 

Install Go wrapper

go get github.com/goodsign/libtextcat
go test github.com/goodsign/libtextcat (must PASS)

Installation notes

Make sure that you have your local library paths set correctly and that installation was successful. Otherwise, go build or go test may fail.

libtextcat is installed in your local library directory (e.g. /usr/local/lib) and puts its libraries there. This path should be registered in your system (using ldconfig or exporting LD_LIBRARY_PATH, etc.) or the linker would fail.

Usage

cat, err := NewTextCat(ConfigPath) // See 'Usage notes' section

if nil != err {
    // ... Handle error ...
}
defer cat.Close()

matches, err := cat.Classify(text)

if nil != err {
    // ... Handle error ...
}

// Use matches. 
// NOTE: matches[0] is the best match.

Usage notes

libtextcat library needs to load language models to start guessing languages. These models are set using a configuration file and a number of language model (.lm) files.

Configuration file maps .lm files to identifiers used in the library. See example. Path to this file is specified in the NewTextCat call.

.lm files contain language patterns and frequencies for a specified language. See example. Paths to these files are specified in the config file above. They can be absolute or relative (to the caller).

Quickstart

To immediately get started, copy /defaultcfg folder contents to the directory of your target project and use:

cat, err := NewTextCat("defaultcfg/conf.txt")

This will give you a standard set of languages described in the Default configuration section below.

Default configuration

This package contains a default configuration (/defaultcfg) which is created to work in following conditions:

  • Utf-8 only languages
  • Language list is taken from snowball package
  • Language identifiers are the same as in snowball package

This configuration is meant to be used in pair with the snowball package.

More info

For more information on libtextcat refer to the original website, which contains links on theory and other details.

libtextcat Licence

The libtextcat library is released under the BSD Licence

LICENCE file

Licence

The goodsign/libtextcat binding is released under the BSD Licence

LICENCE file

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory