3

토큰 화해야하는 여러 텍스트 파일 (POS 및 NER)이 있습니다. C&C taggers를 사용하고 있으며 튜토리얼을 실행했지만 여러 파일을 하나씩 태그 지정하는 방법이 있는지 궁금합니다.추가 처리를 위해 기본 이름을 유지하면서 여러 파일에 어떻게 루프합니까?

bin/pos --input working/tutorial/example.tok --model models/pos --output working/tutorial/example.pos 

그리고 마지막으로 명명 된 엔티티 인식 :

bin/ner --input working/tutorial/example.pos --model models/ner --output working/tutorial/example.ner 

I 다음 음성 태그의 일부는 다음과 같이

bin/tokkie --input working/tutorial/example.txt--quotes delete --output working/tutorial/example.tok 

: 순간

나는 파일을 tokenising하고 이 작업을 수행하고 입력과 동일한 파일 이름을 유지하는 루프를 만드는 방법에 대해 어떻게 확신 할 수 있습니까? 확장자는 태그가있는 것을 나타냅니다. 나는 bash 스크립트 나 Perl로 하여금 디렉토리를 열려고 생각했지만 스크립트를 이해하기 위해서는 C & C 명령어를 입력하는 방법에 대해서는 잘 모르겠습니다.

지금 내가 수동으로하고 있으며, 가장 적은 시간을 소비하는 데 꽤 시간이 걸립니다.

답변

3

테스트되지 않았으므로 일부 디렉토리 맹 글링이 필요할 수 있습니다. 배쉬에서

use autodie qw(:all); 
use File::Basename qw(basename); 

for my $text_file (glob 'working/tutorial/*.txt') { 
    my $base_name = basename($text_file, '.txt'); 
    system 'bin/tokkie', 
     '--input' => "working/tutorial/$base_name.txt", 
     '--quotes' => 'delete', 
     '--output' => "working/tutorial/$base_name.tok"; 
    system 'bin/pos', 
     '--input' => "working/tutorial/$base_name.tok", 
     '--model' => 'models/pos', 
     '--output' => "working/tutorial/$base_name.pos"; 
    system 'bin/ner', 
     '--input' => "working/tutorial/$base_name.pos", 
     '--model' => 'models/ner', 
     '--output' => "working/tutorial/$base_name.ner"; 
} 
+0

슈퍼 정말 고마워요을 – jenniem001

1

:

#!/bin/bash 
dir='working/tutorial' 
for file in "$dir"/*.txt 
do 
    noext=${file/%.txt} 

    bin/tokkie --input "$file" --quotes delete --output "$noext.tok" 

    bin/pos --input "$noext.tok" --model models/pos --output "$noext.pos" 

    bin/ner --input "$noext.pos" --model models/ner --output "$noext.ner" 

done 
관련 문제