Skip to content
Navigation Menu
Toggle navigation
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
New
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
Accelerator
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search or jump to...
Search code, repositories, users, issues, pull requests...
Search syntax tips
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Sign in
Sign up
Appearance settings
Resetting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
Nim-NLP
/
fastText
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
8
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
fastText
/
tests
/
testnews.nim
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
31 lines (25 loc) · 1.47 KB
master
Breadcrumbs
fastText
/
tests
/
testnews.nim
Copy path
Top
File metadata and controls
Code
Blame
31 lines (25 loc) · 1.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import
os
import
unittest
import
fasttext
const
testDir
=
currentSourcePath
().parentDir
/
"
testdata
"
suite
"
FastText News Classification Tests
"
:
var
ft:
FastText
setup:
ft
=
newFastText
()
ft.
loadModel
(testDir
/
"
sogou_news.ftz
"
)
test
"
model parameters are correct
"
:
check
ft.args.lrUpdateRate
==
100
check
ft.args.dim
==
10
check
ft.args.minn
==
0
check
ft.args.maxn
==
0
check
ft.args.bucket
==
10000000
test
"
classify sports news (pinyin input)
"
:
let
ss
=
"
be3i ji1ng shi2 jia1n 5 yue4 16 ri4 , 2018 nia2n NBA xua3n xiu4 le4 to4u cho1u qia1n da4 hui4 za4i zhi1 jia1 ge1 ji4n xi2ng 。 zui4 zho1ng , fe1i ni2 ke4 si1 ta4i ya2ng xi4ng yu4n cho1u da4o zhua4ng yua2n qia1n , e2r ba3ng ya3n he2 ta4n hua1 qia1n ze2 fe1n bie2 gui1 shu3 sa4 ke4 la1 me2n tuo1 guo2 wa2ng he2 ya4 te4 la2n da4 la3o yi1ng
"
let
output
=
ft.
predict
(ss)
check
output.len
>
0
check
output[
0
].second
==
"
__label__1
"
#
sports label
test
"
classify technology news (pinyin input)
"
:
let
s2
=
"
me3i guo2 ha2ng tia1n ju2 ji4n ri4 za4i qi2 gua1n wa3ng bo2 ke4 sha4ng go1ng bu4 le sha1ng ye4 za4i re2n fe1i chua2n de shi4 ya4n xi4ng fe1i xi2ng shi2 jia1n bia3o , qi2 zho1ng di4 yi1 ci4 shi4 fe1i jia1ng bu4 za4i re2n , yo2u me3i guo2 ta4i ko1ng ta4n suo3 ji4 shu4 go1ng si1 de lo2ng fe1i chua2n yu2 mi2ng nia2n nia2n chu1 zhi2 xi2ng 。
"
let
output2
=
ft.
predict
(s2)
check
output2.len
>
0
check
output2[
0
].second
==
"
__label__5
"
#
technology label
You can’t perform that action at this time.