-
Notifications
You must be signed in to change notification settings - Fork 5
classification training guide
This page ports the Java wiki page Zemberek-NLP-ile-Metin-Sınıflandırma.md to ZemberekDotNet.
It explains how to train and evaluate a Turkish news-title classifier using the .NET examples and apps in this repository.
Use the same dataset referenced by the original Java wiki:
news-title-category-setnews-title-category-set.tokenizednews-title-category-set.lemmas
Source link (Java wiki reference):
Expected line format:
__label__magazin Jackie Chan'a yapmadıklarını bırakmadılar!
__label__spor Fenerbahçe Akhisar'da çok rahat kazandı
The class NewsTitleCategoryFinder in ZemberekDotNet.Examples.Classification runs an end-to-end workflow:
- reads raw labeled lines
- prints category distribution
- creates train/test split (
testSize = 1000) - trains model(s) with
TrainClassifier - evaluates with
EvaluateClassifier - compares raw vs tokenized vs lemma-based inputs
Main file:
ZemberekDotNet.Examples.Classification/NewsTitleCategoryFinder.cs
Set your local dataset path in that file before running.
Run:
dotnet run --project ZemberekDotNet.Examples.Classification/ZemberekDotNet.Examples.Classification.csprojThe example is configured with startup object:
ZemberekDotNet.Examples.Classification.NewsTitleCategoryFinder
The Java wiki highlights that preprocessing significantly improves classification quality. The same applies here.
Recommended progression:
- Raw text
- Tokenized + lowercase text
- Lemma-based text
- Optional model compression (quantization)
In this repo, the example already evaluates raw, tokenized, and lemma/split variants.
NewsTitleCategoryFinder currently uses:
--learningRate 0.1--epochCount 70--dimension 100--wordNGrams 2
These are passed through ZemberekDotNet.Apps.FastText.TrainClassifier.
For reproducible comparisons, keep train/test split and parameters fixed while changing one preprocessing factor at a time.
Evaluation is done with:
ZemberekDotNet.Apps.FastText.EvaluateClassifier
The example writes prediction outputs and prints top-1 metrics (k=1) for the generated test split.
For runtime classification, see:
ZemberekDotNet.Examples.Classification/SimpleClassification.cs
Core flow:
- Load model with
FastTextClassifier.Load(...) - Preprocess input exactly like training data
- Call
Predict(processed, k)
Important: preprocessing mismatch between training and inference will hurt accuracy.
The training call in NewsTitleCategoryFinder includes commented options for quantization:
--applyQuantization--cutOff 25000
Enable them when you need much smaller model files and can tolerate a small quality drop.
- Java CLI examples using
zemberek-full.jarmap to .NET app classes underZemberekDotNet.Apps.FastText. - Java example classes map to
.NETexample projects underZemberekDotNet.Examples.Classification. - Keep dataset format (
__label__...) unchanged.
Getting Started
Module Reference
- Morphology Notes
- Additions and Release Notes
- Morphemes Reference
- Classification Training Guide
- Normalization Guide
- Proper Nouns and Named Entities
- Text Dictionary Rules
API Parity & Migration
Reference
Roadmap