Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stratosblue/languageidentification
.NET Port of Language Identification Library for langid-java. 移植自langid-java的语言识别库。
https://github.com/stratosblue/languageidentification
langid langid-csharp langid-dotnet language-detection language-identification
Last synced: about 13 hours ago
JSON representation
.NET Port of Language Identification Library for langid-java. 移植自langid-java的语言识别库。
- Host: GitHub
- URL: https://github.com/stratosblue/languageidentification
- Owner: stratosblue
- License: mit
- Created: 2021-09-26T11:27:45.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T02:57:57.000Z (11 months ago)
- Last Synced: 2024-11-05T15:13:18.786Z (about 2 months ago)
- Topics: langid, langid-csharp, langid-dotnet, language-detection, language-identification
- Language: C#
- Homepage:
- Size: 2.47 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# LanguageIdentification
## Intro
.NET Port of Language Identification Library for [langid-java](https://github.com/carrotsearch/langid-java)。
移植自[langid-java](https://github.com/carrotsearch/langid-java)的语言识别库,技术细节参见[langid-java](https://github.com/carrotsearch/langid-java)、[langid.py](https://github.com/saffsd/langid.py)。
- 支持`.netstandard2.0`+;
## 如何使用
### 安装Nuget包
```PowerShell
Install-Package LanguageIdentification
```### 快速使用
----
1. 通过手动创建实例使用
```C#
var langIdClassifier = new LanguageIdentificationClassifier();
langIdClassifier.Append("Hello");
using var result = langIdClassifier.Classify();
Console.WriteLine(result);
```- 实例`不是线程安全`的;
- 实例复用进行新的检测前,需要调用`Reset()`方法;----
2. 通过静态方法使用
```C#
using var result = LanguageIdentificationClassifier.Classify("Hello");
Console.WriteLine(result);
```- 静态方法是`线程安全`的,内部使用了默认的`LanguageIdentificationClassifier`池 - `LanguageIdentificationClassifierPool.Default` 进行处理;
### 特殊用法
----
1. 只加载部分语言支持
```C#
var classifier = new LanguageIdentificationClassifier("zh", "en");
langIdClassifier.Append("Hello");
using var result = langIdClassifier.Classify();
Console.WriteLine(result);
```
- 速度会更快;
- 返回的语言只会是已加载语言的其中一个;----
2. 使用自己的模型数据
```C#
var model = new LanguageIdentificationModel(langClasses, nb_ptc, nb_pc, dsa, dsaOutput);
var classifier = new LanguageIdentificationClassifier(model);
```- 具体各个参数是什么意义。。不清楚。。自行研究源项目。。。
----