2011-08-12 12 views
1

こんにちは私はいつか情報検索に取り組んできましたが、いくつかの困難に直面していました。 最近、私はそれを実行して、私は、クエリまたは2を持っている出力を確認することができたものの、リンクゲート文法ANNIE

http://gate.ac.uk/wiki/code-repository/src/sheffield/examples/StandAloneAnnie.java を次の中からStandAloneAnnie.javaをダウンロードしました。

  1. このプログラムは、そのようなエンティティに注釈を付けるために格納された文法である人と場所に注釈を付けます。

  2. いくつかのデータを抽出し、それをStandAloneAnnie.javaのコピーで使用するための簡単な文法を作成するにはどうすればよいですか?

前の記事 Hundreds of RegEx on one stringNew to NLP, Question about annotation

答えて

3

、これが実行されますメインコードである人物のタグ付け高さのための簡単な文法

Phase: Meaurements 
Input: Token Number 
Options: control=appelt debug=true 



Rule: Height 
(
({Number}) 
({Token.string=~"[Ff]t"} | {Token.string=~"[Ii]n"} | {Token.string=~"[Cc]m"}) 
):height 
--> 
:height.Height= {value= :height.Number.value, unit= :height.Token.string} 

ある

public static void main(String arg[]) { 

      Gate.init(); 
      gate.Corpus corpus= (Corpus) Factory.createResource("gate.corpora.CorpusImpl"); 

//You need to register the plugin before you load it. 

      Gate.getCreoleRegister().registerDirectories(new File(Gate.getPluginsHome(), ANNIEConstants.PLUGIN_DIR).toURI().toURL()); 
      Gate.getCreoleRegister().registerDirectories(new URL("file:///GATE_HOME/plugins/Tagger_Numbers"));//change this path 


      Document doc = new DocumentImpl(); 
//The string to be annotated. 

String str = "Height is 60 in. Weight is 150 lbs pulse rate 90 Pulse rate 90"; 
DocumentContentImpl impl = new DocumentContentImpl(str); 
doc.setContent(impl); 

//Loading processing resources. refer http://gate.ac.uk/gate/doc/plugins.html for what class the plugin belongs to 

      ProcessingResource token = (ProcessingResource) Factory.createResource("gate.creole.tokeniser.DefaultTokeniser", Factory.newFeatureMap()); 
      ProcessingResource sspliter = (ProcessingResource) Factory.createResource("gate.creole.splitter.SentenceSplitter", Factory.newFeatureMap()); 
      ProcessingResource number = (ProcessingResource) Factory.createResource("gate.creole.numbers.NumbersTagger", Factory.newFeatureMap()); 


/*pipeline is an application that needs to be created to use resources loaded above. 
Reasources must be added in a particular order eg. below the 'number' resource requires the document to be tokenised. */ 

corpus.add(doc); 
SerialAnalyserController pipeline = (SerialAnalyserController) Factory.createResource("gate.creole.SerialAnalyserController", Factory.newFeatureMap(), Factory.newFeatureMap(), "ANNIE"); 
pipeline.setCorpus(corpus); 
pipeline.add(token); 
pipeline.add(sspliter); 
pipeline.add(number); 
pipeline.execute(); 

//Extract info from an annotated document. 

AnnotationSetImpl ann=(AnnotationSetImpl)doc.getAnnotations(); 
Iterator<Annotation>i = ann.get(vital).iterator(); 
Annotation annotation = i.next(); 
long start = annotation.getStartNode().getOffset(); 
long end = annotation.getEndNode().getOffset(); 
System.out.println(doc.toString().substring((int)start, (int)end)); 

} 

次の点に注意してください - 上記のコードで 、のための文法高さは.japeファイルに書き込まれます。この文法は、JAPE(JAPE Plus)トランスデューサを使用して実行する必要があります。メインコードでアプリケーション(パイプライン)を実行するだけで済みます。あなたはgate.ac.uk/sale/taoでjapeを書くためのチュートリアルを見つけることができます

+0

「注釈付き文書から情報を抽出する」コードの一部に 'while'ループを使用するべきではありませんか? – Identity1

0

文法が格納されている方法について説明しIntroduction to Annieパワーポイントがあります。彼らはJapeファイルにあります。

+0

これは私自身のJavaプログラムでどのように使うことができますか? – Sap

関連する問題