jvanzyl     2002/09/20 07:00:41

  Modified:    betwixt  maven.xml
               betwixt/src/java/org/apache/commons/betwixt/strategy
                        DefaultPluralStemmer.java
               betwixt/src/test/org/apache/commons/betwixt/strategy
                        TestDefaultPluralStemmer.java
  Log:
  o Applying patch provided by John Thorhauer:
  
  I have a patch for betwixt.  The problem that I am having is with the
  DefaultPluralStemmer.  It does not deal real well with plurals that end
  in 'es'.  I have included a patch for both the test case and the patch
  for the DefaultPluralStemmer.  If you run the test without applying the
  fix you will see the problem.
  
  Revision  Changes    Path
  1.4       +2 -2      jakarta-commons/betwixt/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/maven.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- maven.xml 12 Aug 2002 19:29:15 -0000      1.3
  +++ maven.xml 20 Sep 2002 14:00:41 -0000      1.4
  @@ -4,8 +4,8 @@
       
       <echo>Copying test resources ...</echo>
       
  -    <copy todir="target/test-classes/org/apache/commons/betwixt/nowrap">
  -      <fileset dir="src/test/org/apache/commons/betwixt/nowrap">
  +    <copy todir="${basedir}/target/test-classes/org/apache/commons/betwixt/nowrap">
  +      <fileset dir="${basedir}/src/test/org/apache/commons/betwixt/nowrap">
           <include name="*.betwixt"/>
           <include name="*.xml"/>
         </fileset>
  
  
  
  1.3       +11 -6     
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultPluralStemmer.java
  
  Index: DefaultPluralStemmer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultPluralStemmer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultPluralStemmer.java 11 Jun 2002 16:05:21 -0000      1.2
  +++ DefaultPluralStemmer.java 20 Sep 2002 14:00:41 -0000      1.3
  @@ -90,6 +90,11 @@
           int foundKeyCount = 0;
           String keyFound = null;
           ElementDescriptor answer = (ElementDescriptor) map.get( propertyName + "s" 
);
  +
  +        if ( answer == null && !propertyName.endsWith( "y" )) {
  +            answer = (ElementDescriptor) map.get( propertyName + "es" );
  +        }
  +
           if ( answer == null ) {
               int length = propertyName.length();
               if ( propertyName.endsWith( "y" ) && length > 1 ) {
  @@ -126,7 +131,7 @@
               }
           }
           if (foundKeyCount > 1) {
  -            log.warn("More then one type matches, using closest match "+keyFound);
  +            log.warn("More than one type matches, using closest match "+keyFound);
           }
           return answer;
           
  
  
  
  1.2       +31 -7     
jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/strategy/TestDefaultPluralStemmer.java
  
  Index: TestDefaultPluralStemmer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/strategy/TestDefaultPluralStemmer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestDefaultPluralStemmer.java     11 Jun 2002 16:05:21 -0000      1.1
  +++ TestDefaultPluralStemmer.java     20 Sep 2002 14:00:41 -0000      1.2
  @@ -151,7 +151,7 @@
           ElementDescriptor result = dps.findPluralDescriptor("y", map);
           assertEquals(des, result);
       }
  -    
  +   
       /**
        * Tests to see if you get warned when there are multiple matches
        * found
  @@ -178,7 +178,31 @@
           result = dps.findPluralDescriptor("yesno", map);
           assertEquals(desyesno, result);
       }
  -    
  +   
  +    /**
  +     *  Test to find matched where plural ending is "es" 
  +     */
  +    public void testESPluralEndingMatch() {
  +        HashMap map = new HashMap();
  +
  +        ElementDescriptor index = new ElementDescriptor("index", "index","");
  +        map.put("index", index);
  +        ElementDescriptor indexes = new ElementDescriptor("indexes", "indexes","");
  +        map.put("indexes", indexes);
  +
  +        ElementDescriptor patch = new ElementDescriptor("patch", "patch","");
  +        map.put("patch", patch);
  +        ElementDescriptor patches = new ElementDescriptor("patches", "patches","");
  +        map.put("patches", patches);
  +
  +        DefaultPluralStemmer stemmer = new DefaultPluralStemmer();
  +        ElementDescriptor result = stemmer.findPluralDescriptor("index", map);
  +        assertEquals(indexes, result);
  +
  +        result = stemmer.findPluralDescriptor("patches", map);
  +        assertEquals(patches, result);
  +    }
  + 
       /**
        *  Test if the closest match mechanisme is working
        */
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to