# -*- coding: utf-8 -*-
'''
Filtering pairs, created for filtering pairs form PWN. Currently supports only filtering of head units

TODO:
- adding of filtering of whole lists
- adding command line options parser

Created on May 26, 2010

@author: Bartosz Broda
'''
import codecs

def filter_pairs(infilename, outfilename):
	out = codecs.open(outfilename, 'w', 'utf8')
	for line in codecs.open(infilename, 'r', 'utf8'):
		line = line.strip()
		if len(line) == 0: continue
		a,b = line.split(';')
		if a.isalpha() and b.isalpha() and a.islower() and b.islower() and len(a) > 1 and len(b) > 1:
			out.write(line + '\n')
		

def main():
	filter_pairs('pairs.csv', 'pairs_filtered.csv')

if __name__ == '__main__':
	main()