|
TestTokeniser |
|
1 /* 2 * TestTokeniser.java 3 * 4 * Copyright (c) 1998-2001, The University of Sheffield. 5 * 6 * This file is part of GATE (see http://gate.ac.uk/), and is free 7 * software, licenced under the GNU Library General Public License, 8 * Version 2, June 1991 (in the distribution as file licence.html, 9 * and also available at http://gate.ac.uk/gate/licence.html). 10 * 11 * Valentin Tablan, 25/10/2000 12 * 13 * $Id: TestTokeniser.java,v 1.13 2001/10/30 12:45:36 valyt Exp $ 14 */ 15 16 17 package gate.creole.tokeniser; 18 19 import java.util.*; 20 import java.io.*; 21 import java.net.*; 22 import java.beans.*; 23 import java.lang.reflect.*; 24 import junit.framework.*; 25 26 import gate.*; 27 import gate.util.*; 28 import gate.corpora.TestDocument; 29 30 public class TestTokeniser extends TestCase{ 31 32 public TestTokeniser(String name) { 33 super(name); 34 } 35 36 /** Fixture set up */ 37 public void setUp() throws Exception { 38 } 39 40 public void tearDown() throws Exception { 41 } // tearDown 42 43 /** Test the default tokeniser */ 44 public void testDefaultTokeniser() throws Exception { 45 //get a document 46 Document doc = Factory.newDocument( 47 new URL(TestDocument.getTestServerName() + "tests/doc0.html") 48 ); 49 //create a default tokeniser 50 FeatureMap params = Factory.newFeatureMap(); 51 params.put("tokeniserRulesURL", 52 "gate:/creole/tokeniser/DefaultTokeniser.rules"); 53 params.put("transducerGrammarURL", 54 "gate:/creole/tokeniser/postprocess.jape"); 55 56 params.put("encoding", "UTF-8"); 57 DefaultTokeniser tokeniser = (DefaultTokeniser) Factory.createResource( 58 "gate.creole.tokeniser.DefaultTokeniser", params); 59 60 tokeniser.setDocument(doc); 61 tokeniser.setAnnotationSetName("TokeniserAS"); 62 tokeniser.execute(); 63 assertTrue(! doc.getAnnotations("TokeniserAS").isEmpty()); 64 } 65 66 /** Test suite routine for the test runner */ 67 public static Test suite() { 68 return new TestSuite(TestTokeniser.class); 69 } // suite 70 71 public static void main(String[] args) { 72 try{ 73 Gate.init(); 74 TestTokeniser testTokeniser1 = new TestTokeniser(""); 75 testTokeniser1.setUp(); 76 testTokeniser1.testDefaultTokeniser(); 77 testTokeniser1.tearDown(); 78 }catch(Exception e){ 79 e.printStackTrace(); 80 } 81 } 82 } 83
|
TestTokeniser |
|