Skip to content

Instantly share code, notes, and snippets.

View malithjkmt's full-sized avatar
😆
Don't eat, code and sleep

Malith malithjkmt

😆
Don't eat, code and sleep
View GitHub Profile
@malithjkmt
malithjkmt / AutoComboBox.java
Last active August 29, 2015 14:27 — forked from resarahadian/ComboListener.java
ComboBox AutoComplete Java Swing
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
public class AutoComboBox extends JComboBox<Object> {
// default item list
String keyWord[] = {"item1", "item2", "item3"};
@malithjkmt
malithjkmt / corpusShuffler.py
Last active August 4, 2017 00:41
Shuffle a parallel corpus without loosing the alignment.
# To run: python corpusShuffler -src sourceCourpus.txt -tdt targetCorpus.txt
import argparse
import random
parser = argparse.ArgumentParser(description='## CORPUS SHUFLER ##')
parser.add_argument(
'-src', help='sorce language corpus to shuffle', required=True)
parser.add_argument(
'-tgt', help='target language corpus to shuffle', required=True)
@malithjkmt
malithjkmt / corpusRepeater.py
Created August 4, 2017 00:40
Repeat a parallel corpus without loosing alignment. Used in bootstrapping.
import sys, math
MAX_LENGTH = 200
if(len(sys.argv)<3):
sys.exit('input 2 files!')
f1 = open(sys.argv[1],'r').readlines()
f2 = open(sys.argv[2], 'r').readlines()
f_a = [[] for y in range(MAX_LENGTH)]
@malithjkmt
malithjkmt / Counter.py
Created August 13, 2017 04:58
Total & unique word counter
import sys
uniqu_words = {}
total_word_count = 0
inFile = open(sys.argv[1],'r')
for line in inFile:
tokens = line.split()
for word in tokens: