-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 chore(ft_detect): refactor detect_langs to detect_language
Refactor `detect_langs` function to `detect_language` for better clarity and deprecation warning. Remove redundancy and improve code readability.
- Loading branch information
Showing
7 changed files
with
130 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2024/1/18 上午11:41 | ||
# @Author : sudoskys | ||
# @File : __init__.py.py | ||
# @Software: PyCharm | ||
from fast_langdetect import detect, detect_multilingual, detect_langs | ||
from fast_langdetect import parse_sentence | ||
|
||
print(parse_sentence("你好世界")) | ||
print(parse_sentence("你好世界!Hello, world!Привет, мир!")) | ||
print(detect_multilingual("Hello, world!你好世界!Привет, мир!")) | ||
|
||
from fast_langdetect import detect, detect_multilingual, detect_language | ||
|
||
# 测试繁体,简体,日文,英文,韩文,法文,德文,西班牙文 | ||
|
||
print(detect_multilingual("Hello, world!你好世界!Привет, мир!")) | ||
# [{'lang': 'ja', 'score': 0.32009604573249817}, {'lang': 'uk', 'score': 0.27781224250793457}, {'lang': 'zh', 'score': 0.17542070150375366}, {'lang': 'sr', 'score': 0.08751443773508072}, {'lang': 'bg', 'score': 0.05222449079155922}] | ||
print(detect("hello world")) | ||
print(detect_langs("Привет, мир!")) | ||
|
||
print(detect_language("Привет, мир!")) | ||
print(detect_language("你好世界")) | ||
print(detect_language("こんにちは世界")) | ||
print(detect_language("안녕하세요 세계")) | ||
print(detect_language("Bonjour le monde")) | ||
print(detect_language("Hallo Welt")) | ||
print(detect_language("Hola mundo")) | ||
print(detect_language("這些機構主辦的課程,多以基本電腦使用為主,例如文書處理、中文輸入、互聯網應用等")) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .ft_detect import detect, detect_langs, detect_multilingual # noqa: F401 | ||
from .ft_detect import detect, detect_language, detect_langs, detect_multilingual # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters