whatcategory 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README.md +164 -2
- package/THIRD_PARTY_NOTICES.md +112 -0
- package/data/brands/001.js +2 -0
- package/data/brands/AC.js +2 -0
- package/data/brands/AD.js +2 -0
- package/data/brands/AE.js +2 -0
- package/data/brands/AF.js +2 -0
- package/data/brands/AG.js +2 -0
- package/data/brands/AI.js +2 -0
- package/data/brands/AL.js +2 -0
- package/data/brands/AM.js +2 -0
- package/data/brands/AO.js +2 -0
- package/data/brands/AQ.js +2 -0
- package/data/brands/AR.js +2 -0
- package/data/brands/AS.js +2 -0
- package/data/brands/AT.js +2 -0
- package/data/brands/AU.js +2 -0
- package/data/brands/AW.js +2 -0
- package/data/brands/AX.js +2 -0
- package/data/brands/AZ.js +2 -0
- package/data/brands/BA.js +2 -0
- package/data/brands/BB.js +2 -0
- package/data/brands/BD.js +2 -0
- package/data/brands/BE.js +2 -0
- package/data/brands/BF.js +2 -0
- package/data/brands/BG.js +2 -0
- package/data/brands/BH.js +2 -0
- package/data/brands/BI.js +2 -0
- package/data/brands/BJ.js +2 -0
- package/data/brands/BL.js +2 -0
- package/data/brands/BM.js +2 -0
- package/data/brands/BN.js +2 -0
- package/data/brands/BO.js +2 -0
- package/data/brands/BQ.js +2 -0
- package/data/brands/BR.js +2 -0
- package/data/brands/BS.js +2 -0
- package/data/brands/BT.js +2 -0
- package/data/brands/BV.js +2 -0
- package/data/brands/BW.js +2 -0
- package/data/brands/BY.js +2 -0
- package/data/brands/BZ.js +2 -0
- package/data/brands/CA.js +2 -0
- package/data/brands/CC.js +2 -0
- package/data/brands/CD.js +2 -0
- package/data/brands/CF.js +2 -0
- package/data/brands/CG.js +2 -0
- package/data/brands/CH.js +2 -0
- package/data/brands/CI.js +2 -0
- package/data/brands/CK.js +2 -0
- package/data/brands/CL.js +2 -0
- package/data/brands/CM.js +2 -0
- package/data/brands/CN.js +2 -0
- package/data/brands/CO.js +2 -0
- package/data/brands/CP.js +2 -0
- package/data/brands/CQ.js +2 -0
- package/data/brands/CR.js +2 -0
- package/data/brands/CU.js +2 -0
- package/data/brands/CV.js +2 -0
- package/data/brands/CW.js +2 -0
- package/data/brands/CX.js +2 -0
- package/data/brands/CY.js +2 -0
- package/data/brands/CZ.js +2 -0
- package/data/brands/DE.js +2 -0
- package/data/brands/DG.js +2 -0
- package/data/brands/DJ.js +2 -0
- package/data/brands/DK.js +2 -0
- package/data/brands/DM.js +2 -0
- package/data/brands/DO.js +2 -0
- package/data/brands/DZ.js +2 -0
- package/data/brands/EA.js +2 -0
- package/data/brands/EC.js +2 -0
- package/data/brands/EE.js +2 -0
- package/data/brands/EG.js +2 -0
- package/data/brands/EH.js +2 -0
- package/data/brands/ER.js +2 -0
- package/data/brands/ES.js +2 -0
- package/data/brands/ET.js +2 -0
- package/data/brands/FI.js +2 -0
- package/data/brands/FJ.js +2 -0
- package/data/brands/FK.js +2 -0
- package/data/brands/FM.js +2 -0
- package/data/brands/FO.js +2 -0
- package/data/brands/FR.js +2 -0
- package/data/brands/GA.js +2 -0
- package/data/brands/GB.js +2 -0
- package/data/brands/GD.js +2 -0
- package/data/brands/GE.js +2 -0
- package/data/brands/GF.js +2 -0
- package/data/brands/GG.js +2 -0
- package/data/brands/GH.js +2 -0
- package/data/brands/GI.js +2 -0
- package/data/brands/GL.js +2 -0
- package/data/brands/GM.js +2 -0
- package/data/brands/GN.js +2 -0
- package/data/brands/GP.js +2 -0
- package/data/brands/GQ.js +2 -0
- package/data/brands/GR.js +2 -0
- package/data/brands/GS.js +2 -0
- package/data/brands/GT.js +2 -0
- package/data/brands/GU.js +2 -0
- package/data/brands/GW.js +2 -0
- package/data/brands/GY.js +2 -0
- package/data/brands/HK.js +2 -0
- package/data/brands/HM.js +2 -0
- package/data/brands/HN.js +2 -0
- package/data/brands/HR.js +2 -0
- package/data/brands/HT.js +2 -0
- package/data/brands/HU.js +2 -0
- package/data/brands/IC.js +2 -0
- package/data/brands/ID.js +2 -0
- package/data/brands/IE.js +2 -0
- package/data/brands/IL.js +2 -0
- package/data/brands/IM.js +2 -0
- package/data/brands/IN.js +2 -0
- package/data/brands/IO.js +2 -0
- package/data/brands/IQ.js +2 -0
- package/data/brands/IR.js +2 -0
- package/data/brands/IS.js +2 -0
- package/data/brands/IT.js +2 -0
- package/data/brands/JE.js +2 -0
- package/data/brands/JM.js +2 -0
- package/data/brands/JO.js +2 -0
- package/data/brands/JP.js +2 -0
- package/data/brands/KE.js +2 -0
- package/data/brands/KG.js +2 -0
- package/data/brands/KH.js +2 -0
- package/data/brands/KI.js +2 -0
- package/data/brands/KM.js +2 -0
- package/data/brands/KN.js +2 -0
- package/data/brands/KP.js +2 -0
- package/data/brands/KR.js +2 -0
- package/data/brands/KW.js +2 -0
- package/data/brands/KY.js +2 -0
- package/data/brands/KZ.js +2 -0
- package/data/brands/LA.js +2 -0
- package/data/brands/LB.js +2 -0
- package/data/brands/LC.js +2 -0
- package/data/brands/LI.js +2 -0
- package/data/brands/LK.js +2 -0
- package/data/brands/LR.js +2 -0
- package/data/brands/LS.js +2 -0
- package/data/brands/LT.js +2 -0
- package/data/brands/LU.js +2 -0
- package/data/brands/LV.js +2 -0
- package/data/brands/LY.js +2 -0
- package/data/brands/MA.js +2 -0
- package/data/brands/MC.js +2 -0
- package/data/brands/MD.js +2 -0
- package/data/brands/ME.js +2 -0
- package/data/brands/MF.js +2 -0
- package/data/brands/MG.js +2 -0
- package/data/brands/MH.js +2 -0
- package/data/brands/MK.js +2 -0
- package/data/brands/ML.js +2 -0
- package/data/brands/MM.js +2 -0
- package/data/brands/MN.js +2 -0
- package/data/brands/MO.js +2 -0
- package/data/brands/MP.js +2 -0
- package/data/brands/MQ.js +2 -0
- package/data/brands/MR.js +2 -0
- package/data/brands/MS.js +2 -0
- package/data/brands/MT.js +2 -0
- package/data/brands/MU.js +2 -0
- package/data/brands/MV.js +2 -0
- package/data/brands/MW.js +2 -0
- package/data/brands/MX.js +2 -0
- package/data/brands/MY.js +2 -0
- package/data/brands/MZ.js +2 -0
- package/data/brands/NA.js +2 -0
- package/data/brands/NC.js +2 -0
- package/data/brands/NE.js +2 -0
- package/data/brands/NF.js +2 -0
- package/data/brands/NG.js +2 -0
- package/data/brands/NI.js +2 -0
- package/data/brands/NL.js +2 -0
- package/data/brands/NO.js +2 -0
- package/data/brands/NP.js +2 -0
- package/data/brands/NR.js +2 -0
- package/data/brands/NU.js +2 -0
- package/data/brands/NZ.js +2 -0
- package/data/brands/OM.js +2 -0
- package/data/brands/PA.js +2 -0
- package/data/brands/PE.js +2 -0
- package/data/brands/PF.js +2 -0
- package/data/brands/PG.js +2 -0
- package/data/brands/PH.js +2 -0
- package/data/brands/PK.js +2 -0
- package/data/brands/PL.js +2 -0
- package/data/brands/PM.js +2 -0
- package/data/brands/PN.js +2 -0
- package/data/brands/PR.js +2 -0
- package/data/brands/PS.js +2 -0
- package/data/brands/PT.js +2 -0
- package/data/brands/PW.js +2 -0
- package/data/brands/PY.js +2 -0
- package/data/brands/QA.js +2 -0
- package/data/brands/RE.js +2 -0
- package/data/brands/RO.js +2 -0
- package/data/brands/RS.js +2 -0
- package/data/brands/RU.js +2 -0
- package/data/brands/RW.js +2 -0
- package/data/brands/SA.js +2 -0
- package/data/brands/SB.js +2 -0
- package/data/brands/SC.js +2 -0
- package/data/brands/SD.js +2 -0
- package/data/brands/SE.js +2 -0
- package/data/brands/SG.js +2 -0
- package/data/brands/SH.js +2 -0
- package/data/brands/SI.js +2 -0
- package/data/brands/SJ.js +2 -0
- package/data/brands/SK.js +2 -0
- package/data/brands/SL.js +2 -0
- package/data/brands/SM.js +2 -0
- package/data/brands/SN.js +2 -0
- package/data/brands/SO.js +2 -0
- package/data/brands/SR.js +2 -0
- package/data/brands/SS.js +2 -0
- package/data/brands/ST.js +2 -0
- package/data/brands/SV.js +2 -0
- package/data/brands/SX.js +2 -0
- package/data/brands/SY.js +2 -0
- package/data/brands/SZ.js +2 -0
- package/data/brands/TA.js +2 -0
- package/data/brands/TC.js +2 -0
- package/data/brands/TD.js +2 -0
- package/data/brands/TF.js +2 -0
- package/data/brands/TG.js +2 -0
- package/data/brands/TH.js +2 -0
- package/data/brands/TJ.js +2 -0
- package/data/brands/TK.js +2 -0
- package/data/brands/TL.js +2 -0
- package/data/brands/TM.js +2 -0
- package/data/brands/TN.js +2 -0
- package/data/brands/TO.js +2 -0
- package/data/brands/TR.js +2 -0
- package/data/brands/TT.js +2 -0
- package/data/brands/TV.js +2 -0
- package/data/brands/TW.js +2 -0
- package/data/brands/TZ.js +2 -0
- package/data/brands/UA.js +2 -0
- package/data/brands/UG.js +2 -0
- package/data/brands/UM.js +2 -0
- package/data/brands/US.js +2 -0
- package/data/brands/UY.js +2 -0
- package/data/brands/UZ.js +2 -0
- package/data/brands/VA.js +2 -0
- package/data/brands/VC.js +2 -0
- package/data/brands/VE.js +2 -0
- package/data/brands/VG.js +2 -0
- package/data/brands/VI.js +2 -0
- package/data/brands/VN.js +2 -0
- package/data/brands/VU.js +2 -0
- package/data/brands/WF.js +2 -0
- package/data/brands/WS.js +2 -0
- package/data/brands/XK.js +2 -0
- package/data/brands/YE.js +2 -0
- package/data/brands/YT.js +2 -0
- package/data/brands/ZA.js +2 -0
- package/data/brands/ZM.js +2 -0
- package/data/brands/ZW.js +2 -0
- package/data/index.d.ts +5 -0
- package/data/index.js +424 -0
- package/data/words/af.js +2 -0
- package/data/words/ak.js +2 -0
- package/data/words/am.js +2 -0
- package/data/words/ar-SA.js +2 -0
- package/data/words/ar.js +2 -0
- package/data/words/as.js +2 -0
- package/data/words/ast.js +2 -0
- package/data/words/az.js +2 -0
- package/data/words/ba.js +2 -0
- package/data/words/be.js +2 -0
- package/data/words/bg.js +2 -0
- package/data/words/blo.js +2 -0
- package/data/words/bn.js +2 -0
- package/data/words/br.js +2 -0
- package/data/words/bs.js +2 -0
- package/data/words/ca-ES-valencia.js +2 -0
- package/data/words/ca.js +2 -0
- package/data/words/ccp.js +2 -0
- package/data/words/ceb.js +2 -0
- package/data/words/chr.js +2 -0
- package/data/words/ckb.js +2 -0
- package/data/words/cop.js +2 -0
- package/data/words/cs.js +2 -0
- package/data/words/cv.js +2 -0
- package/data/words/cy.js +2 -0
- package/data/words/da.js +2 -0
- package/data/words/de-CH.js +2 -0
- package/data/words/de.js +2 -0
- package/data/words/dsb.js +2 -0
- package/data/words/el.js +2 -0
- package/data/words/en-001.js +2 -0
- package/data/words/en-AU.js +2 -0
- package/data/words/en-CA.js +2 -0
- package/data/words/en-GB.js +2 -0
- package/data/words/en-IN.js +2 -0
- package/data/words/en.js +2 -0
- package/data/words/es-419.js +2 -0
- package/data/words/es-MX.js +2 -0
- package/data/words/es-US.js +2 -0
- package/data/words/es.js +2 -0
- package/data/words/et.js +2 -0
- package/data/words/eu.js +2 -0
- package/data/words/fa.js +2 -0
- package/data/words/ff-Adlm.js +2 -0
- package/data/words/ff.js +2 -0
- package/data/words/fi.js +2 -0
- package/data/words/fil.js +2 -0
- package/data/words/fo.js +2 -0
- package/data/words/fr-CA.js +2 -0
- package/data/words/fr.js +2 -0
- package/data/words/ga.js +2 -0
- package/data/words/gd.js +2 -0
- package/data/words/gl.js +2 -0
- package/data/words/gu.js +2 -0
- package/data/words/ha-NE.js +2 -0
- package/data/words/ha.js +2 -0
- package/data/words/he.js +2 -0
- package/data/words/hi-Latn.js +2 -0
- package/data/words/hi.js +2 -0
- package/data/words/hr.js +2 -0
- package/data/words/hsb.js +2 -0
- package/data/words/hu.js +2 -0
- package/data/words/hy.js +2 -0
- package/data/words/ia.js +2 -0
- package/data/words/id.js +2 -0
- package/data/words/ig.js +2 -0
- package/data/words/is.js +2 -0
- package/data/words/it.js +2 -0
- package/data/words/ja.js +2 -0
- package/data/words/jv.js +2 -0
- package/data/words/ka.js +2 -0
- package/data/words/kab.js +2 -0
- package/data/words/kk-Arab.js +2 -0
- package/data/words/kk.js +2 -0
- package/data/words/kl.js +2 -0
- package/data/words/km.js +2 -0
- package/data/words/kn.js +2 -0
- package/data/words/ko.js +2 -0
- package/data/words/kok.js +2 -0
- package/data/words/ku.js +2 -0
- package/data/words/ky.js +2 -0
- package/data/words/lb.js +2 -0
- package/data/words/lij.js +2 -0
- package/data/words/lo.js +2 -0
- package/data/words/lt.js +2 -0
- package/data/words/lv.js +2 -0
- package/data/words/mi.js +2 -0
- package/data/words/mk.js +2 -0
- package/data/words/ml.js +2 -0
- package/data/words/mn.js +2 -0
- package/data/words/mni.js +2 -0
- package/data/words/mr.js +2 -0
- package/data/words/ms.js +2 -0
- package/data/words/mt.js +2 -0
- package/data/words/my.js +2 -0
- package/data/words/ne.js +2 -0
- package/data/words/nl.js +2 -0
- package/data/words/nn.js +2 -0
- package/data/words/no.js +2 -0
- package/data/words/nso.js +2 -0
- package/data/words/oc.js +2 -0
- package/data/words/om.js +2 -0
- package/data/words/or.js +2 -0
- package/data/words/pa-Arab.js +2 -0
- package/data/words/pa.js +2 -0
- package/data/words/pcm.js +2 -0
- package/data/words/pl.js +2 -0
- package/data/words/ps.js +2 -0
- package/data/words/pt-PT.js +2 -0
- package/data/words/pt.js +2 -0
- package/data/words/qu.js +2 -0
- package/data/words/quc.js +2 -0
- package/data/words/rm.js +2 -0
- package/data/words/ro.js +2 -0
- package/data/words/ru.js +2 -0
- package/data/words/rw.js +2 -0
- package/data/words/sat.js +2 -0
- package/data/words/sc.js +2 -0
- package/data/words/sd.js +2 -0
- package/data/words/shn.js +2 -0
- package/data/words/si.js +2 -0
- package/data/words/sk.js +2 -0
- package/data/words/sl.js +2 -0
- package/data/words/so.js +2 -0
- package/data/words/sq.js +2 -0
- package/data/words/sr-Cyrl-BA.js +2 -0
- package/data/words/sr-Cyrl.js +2 -0
- package/data/words/sr-Latn-BA.js +2 -0
- package/data/words/sr-Latn.js +2 -0
- package/data/words/sr.js +2 -0
- package/data/words/su.js +2 -0
- package/data/words/sv-FI.js +2 -0
- package/data/words/sv.js +2 -0
- package/data/words/sw-KE.js +2 -0
- package/data/words/sw.js +2 -0
- package/data/words/syr.js +2 -0
- package/data/words/ta.js +2 -0
- package/data/words/te.js +2 -0
- package/data/words/tg.js +2 -0
- package/data/words/th.js +2 -0
- package/data/words/ti.js +2 -0
- package/data/words/tk.js +2 -0
- package/data/words/tn.js +2 -0
- package/data/words/to.js +2 -0
- package/data/words/tr.js +2 -0
- package/data/words/ug.js +2 -0
- package/data/words/uk.js +2 -0
- package/data/words/ur.js +2 -0
- package/data/words/uz.js +2 -0
- package/data/words/vec.js +2 -0
- package/data/words/vi.js +2 -0
- package/data/words/wo.js +2 -0
- package/data/words/xh.js +2 -0
- package/data/words/yo-BJ.js +2 -0
- package/data/words/yo.js +2 -0
- package/data/words/yue-Hans.js +2 -0
- package/data/words/yue.js +2 -0
- package/data/words/zh-Hant-HK.js +2 -0
- package/data/words/zh-Hant.js +2 -0
- package/data/words/zh.js +2 -0
- package/data/words/zu.js +2 -0
- package/dist/data.d.ts +22 -0
- package/dist/data.js +2 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +272 -0
- package/dist/load.d.ts +15 -0
- package/dist/load.js +22 -0
- package/dist/text.d.ts +17 -0
- package/dist/text.js +52 -0
- package/dist/words.d.ts +36 -0
- package/dist/words.js +112 -0
- package/package.json +71 -4
- package/types/brands.d.ts +3 -0
- package/types/words.d.ts +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are listed here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.1]
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Published from GitHub Actions with npm provenance, so `npm audit signatures` can check where the package was built.
|
|
14
|
+
|
|
15
|
+
## [0.1.0]
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `createClassifier`: suggests one of the app's categories for a short title in any language, with a
|
|
20
|
+
confidence and the reasons, or `null` when unsure.
|
|
21
|
+
- History learning: exact repeats win, most recent first; similar past titles count when the data is unsure.
|
|
22
|
+
- `createEmojiFinder`: emoji for free text, without categories.
|
|
23
|
+
- `loadData`: lazy per-locale and per-country data chunks, with locale fallback.
|
|
24
|
+
- Data for 161 locales and 257 regions from Unicode CLDR 49, the iD tagging schema and the
|
|
25
|
+
OpenStreetMap name-suggestion-index.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Varun Biju
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,165 @@
|
|
|
1
|
-
#
|
|
1
|
+
# whatcategory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Suggest which of **your app's categories** fits a short title, in any language:
|
|
4
|
+
"Bus to Goa", "Abendessen", "Stromrechnung", "タクシー代", "Biedronka zakupy".
|
|
5
|
+
|
|
6
|
+
- **Offline.** No LLM, no network call, no API key. The title never leaves the device.
|
|
7
|
+
- **Your categories.** There are no built-in categories. Describe each one with an emoji, words in any language, or both.
|
|
8
|
+
- **Learns from history.** Pass past choices and repeats are recognised, including local shops and slang that no open data knows.
|
|
9
|
+
- **Small and lazy.** Load only the locales and countries you need. ESM, TypeScript types, zero runtime dependencies, browsers and Node 18+.
|
|
10
|
+
- **Explains itself.** Every suggestion says why.
|
|
11
|
+
|
|
12
|
+
It works for expense splitters, budgets, to-do lists, notes, inventories, bookmarks: anything that files short text into a few buckets.
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import { createClassifier, loadData, learn } from 'whatcategory'
|
|
16
|
+
|
|
17
|
+
const classifier = createClassifier({
|
|
18
|
+
categories: [
|
|
19
|
+
{ id: 'food', emoji: '🍽️', words: ['Eating out'] },
|
|
20
|
+
{ id: 'groceries', emoji: '🛒', words: ['Groceries'] },
|
|
21
|
+
{ id: 'transport', emoji: '🚕', words: ['Transport'] },
|
|
22
|
+
{ id: 'bills', words: ['Bills', 'Rechnungen'] },
|
|
23
|
+
],
|
|
24
|
+
// The user's languages in order of preference, and their country for brand names.
|
|
25
|
+
data: await loadData({ locales: ['de', 'en'], regions: ['DE'] }),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
classifier.suggest('Abendessen')
|
|
29
|
+
// → { id: 'food', confidence: 0.53, why: [{ layer: 'words', text: 'abendessen', match: '🍴', link: 'gabel', … }] }
|
|
30
|
+
classifier.suggest('Lidl') // → groceries: brand → shop/supermarket, which shares "grocery"
|
|
31
|
+
classifier.suggest('Stromrechnung') // → bills: "rechnung" inside the compound → 🧾
|
|
32
|
+
classifier.suggest('Sonstiges') // → null: not sure, so no suggestion
|
|
33
|
+
|
|
34
|
+
// History is plain JSON. Store it however you like.
|
|
35
|
+
let history = learn([], 'Bäckerei Müller', 'food')
|
|
36
|
+
classifier.suggest('Bäckerei Müller', history) // → { id: 'food', confidence: 1, why: [{ layer: 'history', … }] }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install whatcategory
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Describing categories
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
interface Category {
|
|
49
|
+
id: string // yours, returned as-is
|
|
50
|
+
emoji?: string // the strongest signal: '🍺'
|
|
51
|
+
words?: string[] // in any language, the category's name works: ['Drinks', 'Getränke']
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Give both when you can. An emoji is the strongest link, because emoji are annotated in every language. A name links
|
|
56
|
+
place types and brands: "Groceries" is what lets Lidl reach a 🛒 category. Words work in any loaded locale.
|
|
57
|
+
A category with only a vague name such as "Misc" or "Other" will rarely be suggested, and that's intended.
|
|
58
|
+
|
|
59
|
+
## Data
|
|
60
|
+
|
|
61
|
+
| Import | Contents | Size (gzip) |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `whatcategory/words/<locale>` | Emoji names and keywords ([Unicode CLDR](https://cldr.unicode.org)) and place-type names and search terms ([iD tagging schema](https://github.com/openstreetmap/id-tagging-schema)), for 161 locales | ~90 KB each |
|
|
64
|
+
| `whatcategory/brands/<COUNTRY>` | Brand, operator and transit-network names from the [OSM name-suggestion-index](https://nsi.guide), with what kind of place each is. `001` is worldwide | 5–105 KB each |
|
|
65
|
+
|
|
66
|
+
`loadData({ locales, regions })` picks chunks for you. It falls back from `de-AT` to `de`, skips unknown locales and always adds the worldwide brands. Each chunk is a separate module behind a literal `import()`, so Vite, webpack, esbuild and Node load only what you ask for. You can also import chunks directly and pass them as `data`.
|
|
67
|
+
|
|
68
|
+
Load the user's language first. Adding `en` helps when categories are described in English, and English is the best-covered locale.
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
### `createClassifier({ categories, data, threshold? })`
|
|
73
|
+
|
|
74
|
+
Returns `{ suggest(title, history?), rank(title, history?) }`.
|
|
75
|
+
|
|
76
|
+
- `suggest` returns the best `Suggestion`, or `null` when confidence is below `threshold` (default `0.08`).
|
|
77
|
+
- `rank` returns every category with any evidence, best first.
|
|
78
|
+
- `Suggestion` is `{ id, confidence, why }`. `confidence` is the lead over the runner-up, from 0 to 1. `why` lists the evidence: `layer` (`history`, `brand`, `words` or `category`), the `text` that matched, the emoji or place type it matched (`match`), and how that links to the category (`link`: `anchor` or the shared word).
|
|
79
|
+
|
|
80
|
+
Setup takes about 100 ms for two locales and a country, and each suggestion about 1 ms. Create one classifier and reuse it.
|
|
81
|
+
|
|
82
|
+
### History
|
|
83
|
+
|
|
84
|
+
`history` is an array of `{ title, categoryId, at? }` that you store. `learn(history, title, categoryId)` returns a new array.
|
|
85
|
+
|
|
86
|
+
- An exact repeat of a title wins, case- and accent-insensitively. The most recent wins, by `at` or else by array order.
|
|
87
|
+
- A past title that shares words ("Kamath Stores veggies" after "Kamath Stores") is used only when it is stronger evidence than the open data.
|
|
88
|
+
- Entries for category ids you no longer pass are ignored.
|
|
89
|
+
|
|
90
|
+
### `createEmojiFinder(data)`
|
|
91
|
+
|
|
92
|
+
`find(title, limit = 5)` returns `[{ emoji, score }]` with no categories needed: `find('Gitarre')` gives 🎸. It uses only the words chunks.
|
|
93
|
+
|
|
94
|
+
### Also exported
|
|
95
|
+
|
|
96
|
+
`loadData`, `resolveLocale`, `availableLocales`, `availableRegions`, `learn`, `tokens`, `fold`, and the types.
|
|
97
|
+
|
|
98
|
+
## How it works
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
title ─► history: exact repeat? ─────────────────────────────► past choice
|
|
102
|
+
│
|
|
103
|
+
├─► split into words (Intl.Segmenter for ja/zh/th), lowercase, strip Latin/Greek/Cyrillic accents
|
|
104
|
+
├─► brand names (longest first) "biedronka" ─► shop/supermarket
|
|
105
|
+
├─► other words ─► concepts "zakupy" ─► 🛍 🛒 … (exact, inflected, or inside a compound)
|
|
106
|
+
│ concept = an emoji or an OSM place type, described by its words in every locale
|
|
107
|
+
├─► concepts ─► your categories anchor (the category's emoji, or a concept its words name) = 1,
|
|
108
|
+
│ otherwise the most specific word they share
|
|
109
|
+
└─► confidence = lead over the runner-up; below threshold ─► null
|
|
110
|
+
(if a similar past title is stronger evidence, it wins)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
There are no hand-written word lists. Everything general comes from the data:
|
|
114
|
+
|
|
115
|
+
- **Specificity.** A word that describes hundreds of concepts ("face", "store") counts for little.
|
|
116
|
+
- **Phrase fragments.** A word that is never a name or keyword on its own anywhere in its locale ("and", "la", "का") counts for little.
|
|
117
|
+
- **Locale preference.** When a word exists in several loaded locales, the first locale wins (French "courses" is not English "courses").
|
|
118
|
+
- **Brands.** Weight comes from how many NSI items of each place type carry the name, and sub-brands count ("Tesco Extra" counts for "Tesco").
|
|
119
|
+
|
|
120
|
+
## Accuracy
|
|
121
|
+
|
|
122
|
+
Measured on 541 hand-labelled titles in 19 languages (en, de, fr, es, it, pt, nl, pl, sv, ru, uk, el, tr, ar, hi, ja, zh, ko, th), including titles that should get no suggestion. Per-language numbers and every failure are in [eval/RESULTS.md](eval/RESULTS.md).
|
|
123
|
+
|
|
124
|
+
| Category set | Precision | Recall | No-suggestion correct | Best guess right (top-1) |
|
|
125
|
+
|---|---|---|---|---|
|
|
126
|
+
| Expenses: emoji + English name | 92% | 60% | 98% | 76% |
|
|
127
|
+
| Expenses: emoji only | 88% | 56% | 95% | 72% |
|
|
128
|
+
| To-do list | 85% | 36% | 83% | 58% |
|
|
129
|
+
| Home inventory: English words only | 81% | 36% | 60% | 66% |
|
|
130
|
+
|
|
131
|
+
**What this means:** when it suggests something, it is usually right. It stays silent on a third to a half of titles, and history fills those in for each user. Replaying one user's 26 expenses in order, history raised correct suggestions from 7 to 16.
|
|
132
|
+
|
|
133
|
+
The labels were written by the author, not by native speakers of all 19 languages. Corrections are welcome.
|
|
134
|
+
|
|
135
|
+
## Limitations
|
|
136
|
+
|
|
137
|
+
- **Concepts without an emoji or place type** are mostly missed: rent, subscriptions, insurance, salary.
|
|
138
|
+
- **App and online brands** (Uber, Airbnb, Netflix, Swiggy) are not in OpenStreetMap data. History learns them after one use.
|
|
139
|
+
- **Ambiguous brands** (Shell, Tesco, Amazon) spread across what they sell, so confidence is low.
|
|
140
|
+
- **Typos** are not corrected ("Resturant").
|
|
141
|
+
- **Loose inflection matching** can link unrelated words that share a start ("Flug" and "Flügel").
|
|
142
|
+
- **Closely related categories** such as Groceries and Shopping, or Transport and Fuel, share vocabulary and get confused. Distinct emoji help.
|
|
143
|
+
- Scoring constants were tuned on the evaluation set above. Expect somewhat lower numbers on other titles.
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
```sh
|
|
148
|
+
npm ci
|
|
149
|
+
npm run build:data # generates data/ from the pinned upstream packages (~1 min)
|
|
150
|
+
npm test
|
|
151
|
+
npm run eval # rewrites eval/RESULTS.md; commit it with any change that moves the numbers
|
|
152
|
+
node eval/explain.ts "Stromrechnung" --lang de --region DE # see why a title scores the way it does
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The data build needs Node 22.18+ (it runs TypeScript directly). The published library runs on Node 18+ and modern browsers.
|
|
156
|
+
Upstream data is pinned in `package-lock.json` and in `upstream/emoji-test.txt`, and rebuilds are byte-for-byte deterministic. A weekly workflow refreshes the data and opens a pull request showing how the results changed.
|
|
157
|
+
|
|
158
|
+
## Contributing
|
|
159
|
+
|
|
160
|
+
Wrong suggestions, new evaluation cases (especially from native speakers) and fixes are welcome. See
|
|
161
|
+
[CONTRIBUTING.md](CONTRIBUTING.md): the main rule is no hand-written word lists.
|
|
162
|
+
|
|
163
|
+
## Licence
|
|
164
|
+
|
|
165
|
+
Code: MIT. Bundled data: Unicode License v3 (CLDR, emoji-test), ISC (iD tagging schema) and BSD-3-Clause (name-suggestion-index). See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The code of whatcategory is MIT-licensed (see LICENSE). The generated data in `data/` is derived from the
|
|
4
|
+
sources below and is distributed under their licences.
|
|
5
|
+
|
|
6
|
+
## Unicode CLDR annotations (cldr-annotations-full 49.0.0, cldr-core 49.0.0)
|
|
7
|
+
|
|
8
|
+
Emoji names and keywords in data/words, and locale data used to build them.
|
|
9
|
+
|
|
10
|
+
COPYRIGHT AND PERMISSION NOTICE
|
|
11
|
+
|
|
12
|
+
Copyright © 2001–2026 Unicode, Inc.
|
|
13
|
+
|
|
14
|
+
Unicode Technical Standard #35, Unicode Locale Data Markup Language
|
|
15
|
+
(LDML) made available in this repository is protected by copyright, and
|
|
16
|
+
permission must be obtained from Unicode, Inc. prior to any
|
|
17
|
+
reproduction, modification, or other use not permitted by the Unicode
|
|
18
|
+
Terms of Use <https://www.unicode.org/copyright.html>. Specifically, you
|
|
19
|
+
may make copies of this publication and may annotate and translate it
|
|
20
|
+
solely for personal or internal business purposes and not for public
|
|
21
|
+
distribution, provided that any such permitted copies and modifications
|
|
22
|
+
fully reproduce all copyright and other legal notices contained in the
|
|
23
|
+
original. You may not make copies of or modifications to this
|
|
24
|
+
publication for public distribution, or incorporate it in whole or in
|
|
25
|
+
part into any product or publication without the express written
|
|
26
|
+
permission of Unicode. Notwithstanding the foregoing, you may within
|
|
27
|
+
this repository provide comments and propose changes to this standard
|
|
28
|
+
and may make copies/forks solely for such purposes provided that you
|
|
29
|
+
reproduce this copyright notice and these terms of use in any such
|
|
30
|
+
copy/fork.
|
|
31
|
+
|
|
32
|
+
All other content in this repo is released under UNICODE LICENSE V3
|
|
33
|
+
|
|
34
|
+
NOTICE TO USER: Carefully read the following legal agreement. BY
|
|
35
|
+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
|
|
36
|
+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
|
37
|
+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
|
|
38
|
+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
|
|
39
|
+
|
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
41
|
+
copy of data files and any associated documentation (the "Data Files") or
|
|
42
|
+
software and any associated documentation (the "Software") to deal in the
|
|
43
|
+
Data Files or Software without restriction, including without limitation
|
|
44
|
+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
|
|
45
|
+
copies of the Data Files or Software, and to permit persons to whom the
|
|
46
|
+
Data Files or Software are furnished to do so, provided that either (a)
|
|
47
|
+
this copyright and permission notice appear with all copies of the Data
|
|
48
|
+
Files or Software, or (b) this copyright and permission notice appear in
|
|
49
|
+
associated Documentation.
|
|
50
|
+
|
|
51
|
+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
|
52
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
54
|
+
THIRD PARTY RIGHTS.
|
|
55
|
+
|
|
56
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
|
|
57
|
+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
|
|
58
|
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
59
|
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
60
|
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
|
|
61
|
+
FILES OR SOFTWARE.
|
|
62
|
+
|
|
63
|
+
Except as contained in this notice, the name of a copyright holder shall
|
|
64
|
+
not be used in advertising or otherwise to promote the sale, use or other
|
|
65
|
+
dealings in these Data Files or Software without prior written
|
|
66
|
+
authorization of the copyright holder.
|
|
67
|
+
|
|
68
|
+
SPDX-License-Identifier: Unicode-3.0
|
|
69
|
+
|
|
70
|
+
## Unicode emoji-test.txt (18.0)
|
|
71
|
+
|
|
72
|
+
The list of emoji and their subgroups. Same licence as CLDR above.
|
|
73
|
+
|
|
74
|
+
© Unicode, Inc. Unicode License v3, see above.
|
|
75
|
+
|
|
76
|
+
## iD tagging schema (@openstreetmap/id-tagging-schema 7.3.0)
|
|
77
|
+
|
|
78
|
+
Place type names and search terms in data/words.
|
|
79
|
+
|
|
80
|
+
ISC License
|
|
81
|
+
|
|
82
|
+
Copyright (c) iD Contributors
|
|
83
|
+
|
|
84
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
85
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
86
|
+
copyright notice and this permission notice appear in all copies.
|
|
87
|
+
|
|
88
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
89
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
90
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
91
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
92
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
93
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
94
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
95
|
+
|
|
96
|
+
## name-suggestion-index (9.0.20261121)
|
|
97
|
+
|
|
98
|
+
Brand, operator and network names in data/brands.
|
|
99
|
+
|
|
100
|
+
BSD 3-Clause
|
|
101
|
+
|
|
102
|
+
Copyright 2026, name-suggestion-index contributors
|
|
103
|
+
|
|
104
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
105
|
+
|
|
106
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
107
|
+
|
|
108
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
109
|
+
|
|
110
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
111
|
+
|
|
112
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|