File size: 1,279 Bytes
5e1adfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
---
language:
- tr
- en
license: mit
library_name: sklearn
pipeline_tag: text-classification
tags:
- turkish
- english
- language-detection
- charling
---

# 🧠 CharLing - Turkish/English Language Detection Model

## Model Description

CharLing is a lightweight and fast language detection model trained on 882,555 parallel Turkish-English sentence pairs. It uses character frequency analysis with n-grams (2-4) combined with a Logistic Regression classifier, achieving 99.61% accuracy on the test set. The model is designed to quickly distinguish between Turkish and English text with minimal computational resources, making it ideal for preprocessing pipelines, multilingual applications, and edge devices.

## 🎯 Quick Start

```python
import pickle

# Download and load the model
with open('charling.pkl', 'rb') as f:
    model_data = pickle.load(f)

vectorizer = model_data['vectorizer']
classifier = model_data['classifier']

def detect_language(text):
    vector = vectorizer.transform([text])
    prediction = classifier.predict(vector)[0]
    return "🇹🇷 Turkish" if prediction == 0 else "🇬🇧 English"

# Test it
print(detect_language("Bugün hava çok güzel."))  # 🇹🇷 Turkish
print(detect_language("The weather is nice today."))  # 🇬🇧 English