Python: конвертировать PDF в CSV / JSON - PullRequest
0 голосов
/ 26 апреля 2018

Я новый Python с конвертированием файлов. Я пытаюсь конвертировать PDF в CSV в этом коде, и я имею в виду это репозиторий Git: https://github.com/bhishan/PDFMiningUsingLessAndSubprocess

Я получаю сообщение об ошибке типа «не удалось выполнить файл A Test Suite for Evaluation of English-to-Korean.pdf». Все работает нормально, кроме «subprocess.Popen». Что я здесь не так делаю?

Ссылка на файл PDF (невозможно добавить вложение в git): http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.503.4016&rep=rep1&type=pdf

import subprocess
import glob
import time
import csv

csvwriter = csv.writer(file('translation.csv', 'wb'))
csvwriter.writerow(['title','contributornames','institutions','abstract'])

def parse_pdf_buffer(buffer_file):
    with open(buffer_file, 'rb') as f:
        all_content = f.readlines()
        for each_line in all_content[0:29]:
            title_part = each_line[0]
            contributornames = each_line[1]
            institutions = each_line[1:3]
            abstract = each_line[7:27]
            title_part = " ".join(desc_part.split())
            contributornames_part = " ".join(withdraw_part.split())
            institutions_part = " ".join(desc_part.split())
            abstract_part = " ".join(desc_part.split())
            csvwriter.writerow(['title','contributornames','institutions','abstract'])

def read_pdf_file(file_name):
   print file_name
   try:
       fileptr = open('koreanenglish_extracted.txt', 'wb') #parsed it from different code
       command_out = subprocess.Popen(['less', file_name], stdout=fileptr, stderr=subprocess.STDOUT) #ERROR occurs here
       time.sleep(2)
       parse_pdf_buffer('koreanenglish_extracted.txt') #parsed it from different code 
   except:
       print "failed for file", file_name

def main():
   for file_name in glob.glob("*.pdf"): #capture all the pdf
       read_pdf_file(file_name)

if __name__ == '__main__':
    main()

FortunatoScienceParsed.txt содержимое: скопировать вставить в текстовом формате. Извините, я не смог загрузить файлы в виде вложения. Я отправлю весь koreanenglish_extracted.txt в чат, если это необходимо. Помощь очень ценится !!!

A Test Suite for Evaluation of English-to-Korean Machine Translation Systems
Sungryong Koh, Jinee Maeng, Ji-Young Lee, Young-Sook Chae, Key-Sun ChoiKorea Terminology Research Center for Language and Knowledge Engineering (KORTERM)
Korea Advanced Institute of Science and Technology (KAIST) 
Kusong-dong Yusong-gu Taejon 305-701 Korea
{koh,aphroditejin,jinny206}@world.kaist.ac.kr
, pinochae@chollian.net
, kschoi@cs.kaist.ac.kr
Abstract
This paper describes KORTERM™s test suite and their practicability.
 The test-sets have been being constructed on the basis of f
ine-
grained classification of linguistic phenomena 
to evaluate the technical st
atus of English-to-Korean 
MT systems systematically.
 They
consist of about 5000 test-sets and are growi
ng.  
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...