文本挖掘問題進口OCR文字刪除空間:從章節標題,圖形字幕和其他地方,在許多PDF文件我得到這樣的句子:Perl的正則表達式從pdftotext
"T h e n as data we give the t r a j e c t o r i e s o f the particles between ..."
我想這是一個OCR問題與pdftotext。
我只能用鏈接的正則表達式序列刪除gappy文本中的空格,該序列首先增加空格,但這依賴於原始OCR文本中的單詞邊界,其間距至少爲2倍。例如,這裏有一個簡單的測試:
$ perl -e '$t="The \ \ \ \ t h i n g w r o n g h e r e is we have a gap s."; print "$t\n";
$t=~s/(\s{2,})/$1 /g; print "$t\n";
$t=~s/(\w)\s?/$1/g; print "$t\n";
$t=~s/\s+/ /g; print "$t\n";'
The t h i n g w r o n g h e r e is we have a gap s.
The t h i n g w r o n g h e r e is we have a gap s.
The t h i n g w r o n g h e r e is we have a gap s.
The thing wrong here is we have a gap s.
The thing wrong here is we have a gap s.
結束句句時間「gap s」。是故意的,它不應該關閉。
問題1.是否有更優雅的正則表達式來做到這一點?
問題2.單間隔的唯一OCR文本轉儲可以做些什麼?我認爲只能解決這個問題,一般是爲了清理表格的文本: 「當數據給出粒子之間的軌跡...」 當字邊界不清楚使用一些重型模塊,尋找字典一串單個字母中的單詞。有這樣的模塊嗎? (我已經搜索過但目前還沒有找到)
你試圖用正則表達式來操作自然語言。在最好的情況下,並且在你正在工作的空間中,可能是不可能的。繼續謹慎,這裏有龍... –
http://stackoverflow.com/questions/1136990/how-can-i-extract-text-from-a-pdf-file-in-perl – xxfelixxx
http:// search.cpan.org/~cdolan/CAM-PDF-1.60/bin/getpdftext.pl – xxfelixxx