خرید بک لینک

Vote count: 1

I am making a neural network based OCR software in python. I am using a pretrained language model, and a dataset from the Inteet for the OCR neural network. I need to specify the charset to make the neural network works, and I am extracting the charset from the dataset reading UTF-8 encoded text file.
However, the dataset documents says (the dataset and the pretrained model is made by another person) the number of the charset is 3877, but when I scan all of the file and remove the occurence using list(set(charset)), the number of the charset says 4488.
I want to know that do I need to use different way of coding when removing occurence of charset in UTF-8, or the number of dataset mentioned in the docs is wrong? Here's my code:

#!/usr/bin/env python
#-*- coding: utf-8 -*-

import operator
import sys
import codecs
from compiler.ast import flatten
i = 0
charset = []

#utf-8 stdout settings
sys.stdout = codecs.getwriter('utf_8')(sys.stdout)

while i < 5000:
    print "file number :", i , str(float(i)/5000.0 * 100.0 )+ "percent"
    f = codecs.open('0'+str(10000 + i)+".gt.txt",'r',"utf-8")
    char_file =  f.read()
    charset.append(char_file)
    i+=1

f.close()

fd = codecs.open('charset_jp.txt','w',"utf-8")
#remove next line code
charset = [charset[i].replace('n','') for i in range(len(charset))]

#flatten list and change as charset
charset = flatten(charset)
charset = list(set(charset))

print "charset size : ", len(charset)

charset_str = "".join(charset)

fd.write("".join(charset))
fd.close()  

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 1 فروردين 1395 ساعت: 9:51

صفحه بندی