You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by mb...@apache.org on 2008/02/12 09:52:00 UTC

svn commit: r620725 - in /incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test: java/org/apache/uima/annotator/regex/ resources/performanceTest/ resources/performanceTest/fileSet1/

Author: mbaessler
Date: Tue Feb 12 00:51:56 2008
New Revision: 620725

URL: http://svn.apache.org/viewvc?rev=620725&view=rev
Log:
UIMA-760

add RegexAnnotator performance test

https://issues.apache.org/jira/browse/UIMA-760

Added:
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/RegexAnnotatorPerfTest.java
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/RegExAnnotPerf.xml
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/fileSet1/
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/fileSet1/perfTestInput.txt
    incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/perfRules.xml

Added: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/RegexAnnotatorPerfTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/RegexAnnotatorPerfTest.java?rev=620725&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/RegexAnnotatorPerfTest.java (added)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/java/org/apache/uima/annotator/regex/RegexAnnotatorPerfTest.java Tue Feb 12 00:51:56 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.annotator.regex;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.uima.test.junit_extension.AnnotatorPerformanceTester;
+import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.test.junit_extension.PerformanceTestResult;
+
+/**
+ * 
+ * RegexAnnotator performance test class
+ */
+public class RegexAnnotatorPerfTest extends TestCase {
+
+  /**
+   * test annotator performance for sample rule set.
+   * 
+   * @throws Exception
+   */
+  public void testPerformanceSet1() throws Exception {
+    // get descriptor
+    File descFile = JUnitExtension.getFile("performanceTest/RegexAnnotPerf.xml");
+    File testFileDir = JUnitExtension.getFile("performanceTest/fileSet1");
+    // run performance test
+    PerformanceTestResult result = AnnotatorPerformanceTester.runPerformanceTest(true, 10000, descFile, testFileDir,
+            null, true);
+    // get result file
+    assertEquals(180000, result.getNumberOfCreatedAnnotations());
+    System.out.println(result);
+  }
+
+  /**
+   * main method to start the tests not a JUnit test.
+   * 
+   * @param args
+   */
+  public static void main(String[] args) {
+    RegexAnnotatorPerfTest perf = new RegexAnnotatorPerfTest();
+    try {
+      perf.testPerformanceSet1();
+    } catch (Exception ex) {
+      ex.printStackTrace();
+    }
+  }
+
+}
\ No newline at end of file

Added: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/RegExAnnotPerf.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/RegExAnnotPerf.xml?rev=620725&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/RegExAnnotPerf.xml (added)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/RegExAnnotPerf.xml Tue Feb 12 00:51:56 2008
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>true</primitive>
+  <annotatorImplementationName>org.apache.uima.annotator.regex.impl.RegExAnnotator</annotatorImplementationName>
+  <analysisEngineMetaData>
+    <name>RegExAnnotator</name>
+    <description>Matches regular expressions in document text.</description>
+    <configurationParameters>
+           	
+       <configurationParameter>
+          <name>ConceptFiles</name>
+          <description>list of concept files to configure the annotator
+          </description>
+          <type>String</type>
+          <multiValued>true</multiValued>
+          <mandatory>true</mandatory>
+       </configurationParameter>
+       
+    </configurationParameters>
+    
+    <configurationParameterSettings>
+
+       <nameValuePair>
+          <name>ConceptFiles</name>
+          <value>
+          	<array>
+          	   <string>performanceTest/perfRules.xml</string> 
+          	</array>
+          </value>
+       </nameValuePair>
+    
+    </configurationParameterSettings>
+   <typeSystemDescription>
+      <types>
+        <typeDescription>
+          <name>org.apache.uima.EmailAddress</name>
+          <description/>
+          <supertypeName>uima.tcas.Annotation</supertypeName>
+          <features>
+            <featureDescription>
+              <name>localPart</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>domainPart</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>normalizedEmail</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+          </features>
+        </typeDescription>
+
+        <typeDescription>
+          <name>org.apache.uima.ISBNNumber</name>
+          <description/>
+          <supertypeName>uima.tcas.Annotation</supertypeName>
+          <features>
+            <featureDescription>
+              <name>confidence</name>
+              <description/>
+              <rangeTypeName>uima.cas.Float</rangeTypeName>
+            </featureDescription>            
+          </features>
+        </typeDescription>
+
+        <typeDescription>
+          <name>org.apache.uima.MoneyAmount</name>
+          <description/>
+          <supertypeName>uima.tcas.Annotation</supertypeName>
+          <features>
+            <featureDescription>
+              <name>amount</name>
+              <description/>
+              <rangeTypeName>uima.cas.Float</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>amountText</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>currency</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+          </features>
+        </typeDescription>
+
+        <typeDescription>
+          <name>org.apache.uima.CreditCardNumber</name>
+          <description/>
+          <supertypeName>uima.tcas.Annotation</supertypeName>
+          <features>
+            <featureDescription>
+              <name>confidence</name>
+              <description/>
+              <rangeTypeName>uima.cas.Float</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>cardType</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+          </features>
+        </typeDescription>
+         
+       </types>
+    </typeSystemDescription>
+        
+    <typePriorities>
+	</typePriorities>
+    
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs/>
+        <languagesSupported/>
+      </capability>
+    </capabilities>
+    <operationalProperties>
+      <modifiesCas>true</modifiesCas>
+      <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+      <outputsNewCASes>false</outputsNewCASes>
+    </operationalProperties>
+  </analysisEngineMetaData>
+
+</analysisEngineDescription>

Added: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/fileSet1/perfTestInput.txt
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/fileSet1/perfTestInput.txt?rev=620725&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/fileSet1/perfTestInput.txt (added)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/fileSet1/perfTestInput.txt Tue Feb 12 00:51:56 2008
@@ -0,0 +1 @@
+<!--
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 -->

email addresses:
sample@sample.com
apache.uima@sample.com
apache_uima@mmm-xxx.zzz.de
test@sample.com
uima@sample.com
uima@apache

isbn numbers:
0-306-40615-2
978-0-306-40615-7
 
9971-5-0210-0
0306406152
9780306406157

faked credit card numbers:
4552720412345677
5490 1234 5678 9128

money amounts:
12$  
120.0€  
12 million $  
45 $
\ No newline at end of file

Added: incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/perfRules.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/perfRules.xml?rev=620725&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/perfRules.xml (added)
+++ incubator/uima/sandbox/trunk/RegularExpressionAnnotator/src/test/resources/performanceTest/perfRules.xml Tue Feb 12 00:51:56 2008
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	* Licensed to the Apache Software Foundation (ASF) under one
+	* or more contributor license agreements.  See the NOTICE file
+	* distributed with this work for additional information
+	* regarding copyright ownership.  The ASF licenses this file
+	* to you under the Apache License, Version 2.0 (the
+	* "License"); you may not use this file except in compliance
+	* with the License.  You may obtain a copy of the License at
+	* 
+	*   http://www.apache.org/licenses/LICENSE-2.0
+	* 
+	* Unless required by applicable law or agreed to in writing,
+	* software distributed under the License is distributed on an
+	* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	* KIND, either express or implied.  See the License for the
+	* specific language governing permissions and limitations
+	* under the License.
+-->
+<conceptSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns="http://incubator.apache.org/uima/regex"
+	xsi:schemaLocation="concept.xsd">
+
+	<concept name="emailAddressDetection">
+		<rules>
+			<rule
+				regEx="([a-zA-Z0-9!#$%*+'/=?^_-`{|}~.\x26]+)@([a-zA-Z0-9._-]+[a-zA-Z]{2,4})"
+				matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation" />
+		</rules>
+		<createAnnotations>
+			<annotation id="emailAnnot"
+				type="org.apache.uima.EmailAddress">
+				<begin group="0" />
+				<end group="0" />
+				<setFeature name="localPart" type="String"
+					normalization="ToLowerCase">
+					$1
+				</setFeature>
+				<setFeature name="domainPart" type="String"
+					normalization="ToLowerCase">
+					$2
+				</setFeature>
+				<setFeature name="normalizedEmail" type="String"
+					normalization="ToLowerCase">
+					$0
+				</setFeature>
+			</annotation>
+		</createAnnotations>
+	</concept>
+
+	<concept name="isbnNumberDetection">
+		<rules>
+			<rule regEx="(97(8|9))?-?(\d{9}|(\d|-){11})-?(\d|X)"
+				matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation"
+				confidence="1.0" />
+		</rules>
+		<createAnnotations>
+			<annotation id="isbnNumber"
+				type="org.apache.uima.ISBNNumber"
+				validate="org.apache.uima.annotator.regex.extension.impl.ISBNNumberValidator">
+				<begin group="0" />
+				<end group="0" />
+				<setFeature name="confidence" type="Confidence" />
+			</annotation>
+		</createAnnotations>
+	</concept>
+
+	<concept name="creditCardNumberDetection" processAllRules="true">
+		<rules>
+			<rule ruleId="AmericanExpress"
+				regEx="(((34|37)\d{2}[- ]?)(\d{6}[- ]?)\d{5})"
+				matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation"
+				confidence="1.0" />
+			<rule ruleId="Visa"
+				regEx="((4\d{3}[- ]?)(\d{4}[- ]?){2}\d{4})" matchStrategy="matchAll"
+				matchType="uima.tcas.DocumentAnnotation" confidence="1.0" />
+			<rule ruleId="MasterCard"
+				regEx="((5[1-5]\d{2}[- ]?)(\d{4}[- ]?){2}\d{4})"
+				matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation"
+				confidence="1.0" />
+			<rule ruleId="unknown"
+				regEx="(([1-6]\d{3}[- ])(\d{4}[- ]){2}\d{4})|([1-6]\d{13,18})|([1-6]\d{3}[- ]\d{6}[- ]\d{5})"
+				matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation"
+				confidence="1.0" />
+		</rules>
+		<createAnnotations>
+			<annotation id="creditCardNumber"
+				type="org.apache.uima.CreditCardNumber"
+				validate="org.apache.uima.annotator.regex.extension.impl.CreditCardNumberValidator">
+				<begin group="0" />
+				<end group="0" />
+				<setFeature name="confidence" type="Confidence" />
+				<setFeature name="cardType" type="RuleId" />
+			</annotation>
+		</createAnnotations>
+	</concept>
+
+	<concept name="MoneyAmountDetection" processAllRules="true">
+	<!-- \p{Sc} -> currentySymbol -->
+	<!-- (?i) -> case insensitive match -->
+		<rules>
+  			<rule regEx="\m{currency}(\p{Sc}\s?|(?i)USD\s?|(?i)Dollars\s?|(?i)Dollar\s?|(?i)CNY\s?|(?i)CAD\s?|(?i)GBP\s?|(?i)Pounds\s?|(?i)Pound\s?|(?i)EUR\s?|(?i)Euro\s?|(?i)Yen\s?)\m{amount}(\d+(,\d\d\d)*(\.\d\d?)?)\m{amountText}(\s?(?i)million|\s?(?i)billion)?"
+      			  matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation"/> 
+            <rule regEx="\m{amount}(\d+(,\d\d\d)*(\.\d\d?\d?)?)\m{amountText}(\s?(?i)million|\s?(?i)billion)?\m{currency}(\s?\p{Sc}|\s?(?i)USD|\s?(?i)Dollars|\s?(?i)Dollar|\s?(?i)CNY|\s?(?i)CAD|\s?(?i)GBP|\s?(?i)Pounds|\s?(?i)Pound|\s?(?i)EUR|\s?(?i)Euro|\s?(?i)Yen)"
+                  matchStrategy="matchAll" matchType="uima.tcas.DocumentAnnotation"/>
+		</rules>
+		<createAnnotations>
+			<annotation type="org.apache.uima.MoneyAmount">
+				<begin group="0" />
+				<end group="0" />
+				<setFeature name="currency" type="String" normalization="Trim">${currency}</setFeature>
+				<setFeature name="amount" type="Float">${amount}</setFeature>
+				<setFeature name="amountText" type="String" normalization="Trim">${amountText}</setFeature>
+			</annotation>
+		</createAnnotations>
+	</concept>
+</conceptSet>