#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, os
import codecs

ENCODING = "utf-8"
INPUT_FILE = "tsi.src"
OUTPUT_FILE = "list.txt"

def list_generator():
    terms = []
    input_file = codecs.open(INPUT_FILE, "r", ENCODING)

    for line in input_file.readlines():
        term = line.split(" ")[0]
        if len(term) == 2 and term[0] != term[1] and term[0] != u"一":
            terms.append(term)

    input_file.close()
    terms = list(set(terms))
    output_file = codecs.open(OUTPUT_FILE, "w", ENCODING)

    for term in terms:
        output_file.write("%s\n" % term)
        
    output_file.close()
    print("%d terms colleclted." % len(terms))

if __name__ == "__main__":
    list_generator()
