ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen...@apache.org
Subject svn commit: r1538735 - /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/nlp/tokenizer/ContractionsPTB.java
Date Mon, 04 Nov 2013 19:43:20 GMT
Author: chenpei
Date: Mon Nov  4 19:43:20 2013
New Revision: 1538735

URL: http://svn.apache.org/r1538735
Log:
CTAKES-150 - Apostrophe parsing is not thread safe because of global variable.  Thanks Kim.

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/nlp/tokenizer/ContractionsPTB.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/nlp/tokenizer/ContractionsPTB.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/nlp/tokenizer/ContractionsPTB.java?rev=1538735&r1=1538734&r2=1538735&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/nlp/tokenizer/ContractionsPTB.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/nlp/tokenizer/ContractionsPTB.java
Mon Nov  4 19:43:20 2013
@@ -30,9 +30,6 @@ import java.util.HashMap;
  * @author Mayo Clinic
  */
 public class ContractionsPTB {
-
-
-    static ContractionResult contractionResult = new ContractionResult();
     
     static String[] MultiTokenWords = { "cannot", "gonna", "gotta", "lemme", "wanna", "whaddya",
"whatcha", };
     static int[] MultiTokenWordLenToken1 = { 3, 3, 3, 3, 3, 3, 3 };
@@ -224,10 +221,12 @@ public class ContractionsPTB {
 	    
 	    // if exact match with rest (end of sentence)
 	    if (s.equals("n't") && prev=='n' && lowerCasedText.charAt(apostrophePosition+1)=='t'
&& lowerCasedText.length()==apostrophePosition+1+1) {
-		contractionResult.setContractionTokenLen(3); // n't
+	    ContractionResult contractionResult = new ContractionResult();
+	    contractionResult.setContractionTokenLen(3); // n't
 		contractionResult.setWordTokenLen(apostrophePosition-1 - position);
 		return contractionResult;
 	    } else if (restStartingWithApostrophe.equals(s)) {
+	    ContractionResult contractionResult = new ContractionResult();	    	
 		contractionResult.setContractionTokenLen(s.length());
 		contractionResult.setWordTokenLen(apostrophePosition - position);
 		return contractionResult;
@@ -250,11 +249,12 @@ public class ContractionsPTB {
 	    }
 	    if (restStartingWithApostrophe.startsWith(s) && Character.isLetter(prev) &&
!Character.isLetter(after)) {
 		// there was at least one letter before the apostrophe and after the apostrophe, and non
letter after the contraction
+	    ContractionResult contractionResult = new ContractionResult();	    	
 		contractionResult.setContractionTokenLen(s.length());
 		contractionResult.setWordTokenLen(apostrophePosition - position);
 		return contractionResult;
 	    } else if (s.equals("n't") && prev=='n' && restStartingWithApostrophe.startsWith("'t")
&& !Character.isLetter(after)) {
-		
+	    ContractionResult contractionResult = new ContractionResult();		
 		contractionResult.setContractionTokenLen(3); // n't
 		contractionResult.setWordTokenLen(apostrophePosition-1 - position);
 		return contractionResult;



Mime
View raw message