Skip to content

Instantly share code, notes, and snippets.

View arcturusannamalai's full-sized avatar

Muthu Annamalai (முத்து அண்ணாமலை) arcturusannamalai

View GitHub Profile
@arcturusannamalai
arcturusannamalai / example.java
Created October 30, 2015 04:19
Example of Open_Tamil library used for Tamil application development in Java
// include the sources for the com/tamil package from
// https://github.com/arcturusannamalai/open-tamil/blob/master/java/OpenTamil/src
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import com.tamil.utf8;
import com.tamil.Numeral;
@arcturusannamalai
arcturusannamalai / binary_tree_traversal.py
Last active January 24, 2017 05:09
இரு கிளை மரம் தரவு உருவம் - (binary tree data structure)
#!/usr/bin/python
from __future__ import print_function
import collections
#BinaryTree = collections.namedtuple('BinaryTree',['left','right','value'])
class BinaryTree:
def __init__(self,left,right,val):
self.left = left
self.right = right
self.value = val
@arcturusannamalai
arcturusannamalai / குவிப்பு.n
Created February 3, 2017 07:56
குவிப்பு - stack data structure
# (C) முத்தையா அண்ணாமலை 2017
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
நிரல்பாகம் குவிப்பு( )
ப = பட்டியல்()
பின்கொடு ப
முடி
நிரல்பாகம் தினி( கு, மதிப்பு )
பின்இணை( கு, மதிப்பு )
@arcturusannamalai
arcturusannamalai / demo_tamil_in_languages.py
Created August 5, 2018 19:51
Tamil word translated into available Google Translate languages
# -*- coding: utf-8 -*-
# (C) 2018 Muthiah Annamalai <ezhillang@gmail.com>
# This code is shared under public domain.
from google.cloud import translate
import tamil
import codecs
import json
import sys
def get_translated_words(wrd,tgtLang,client):
# Demonstrate Tamil Stemmer module from open-tamil library
from tamilstemmer import TamilStemmer
wordlist = [u'மலைகள்',u'பாடுதல்',u'ஓடினான்']
# expected = [u'மலை',u'பாடு', u'ஓடி']
ta_stemmer = TamilStemmer()
for word in wordlist:
ta_stemmer.stemWord(word)
@arcturusannamalai
arcturusannamalai / tamil_keypad_mapping.py
Last active March 1, 2019 08:24
Experiment to see 247 Tamil letters mapped into a 4x3 Telephone keypad.
# Code for blog post: https://ezhillang.blog/2019/03/01/tamil-entry-via-keypad/
# This code is in Public Domain.
from math import factorial as f
from math import log
def comb(n, k):
return (f(n) / f(k)) / f(n - k)
def nck(n,k):
return comb(float(n),float(k))
@arcturusannamalai
arcturusannamalai / detect_encoding.py
Created December 5, 2019 06:23
Simple Font-Based Encoding Detection using Open-Tamil
# This code is in Public Domain.
# It requires installation of Open-Tamil module from Python Package Index.
# Currently Tamil text is saved in Unicode format but it wasn't always like this.
# If you have some of the old encoding formats like TAM, TAB, ISCII etc. you can
# use the encoding converters from Open-Tamil (inspired by ones from Suratha, and late Gopi of HiGopi.com)
# The following code demonstrates the decoding process
# using an intensive search algorithm written by Arulalan, T.
@arcturusannamalai
arcturusannamalai / fix_erased_mei.py
Last active March 25, 2020 07:30
fix_erased_mei - algorithm from Open-Tamil library
# -*- coding: utf-8 -*-
# (C) 2020, முத்து அண்ணாமலை.
# இந்த நிரல் துண்டு MIT உரிமத்தில் வெளியிடப்பட்டது
import tamil
from pprint import pprint
import operator
from solthiruthi.scoring import bigram_scores, unigram_score
chol = tamil.utf8.get_letters("கணனன")
@arcturusannamalai
arcturusannamalai / olini.py
Created April 1, 2020 09:32
Olini - Tamil numeral NLP based calculator
# This Python file uses the following encoding: utf-8
#!/bin/env python3
# (C) 2020, எழில் மொழி அறக்கட்டளை
# இந்த நிரல் ஓப்பன்-தமிழ் நிரல் தொகுப்பில் சேர்ந்ததாகும்.
# உரைவழி தமிழ் எண்களினை கொண்ட கணிதவியல்
# உள்ளீடை கணக்கிடும் ஒரு கருவி.
import operator
import re
import tamil
#!/bin/env python3
from codecs import open
from tamil import utf8
import re
with open('kuttistory.txt','r','utf-8') as fp:
data = fp.readlines()
class Stats:
__fields__ = ('total_words','tamil_words')