opennlp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "william.colen@gmail.com" <william.co...@gmail.com>
Subject Re: svn commit: r1158465 - in /incubator/opennlp/trunk/opennlp-tools/src: main/java/opennlp/tools/chunker/ main/java/opennlp/tools/doccat/ main/java/opennlp/tools/postag/ main/java/opennlp/tools/sentdetect/ main/java/opennlp/tools/tokenize/ test/java
Date Wed, 17 Aug 2011 10:23:39 GMT
Wow, thanks. The error is from NameSample.equals. I copied the it without
checking if it was ok.

Should the equals take care with null members or all class members are
expected to be set?

On Wed, Aug 17, 2011 at 5:30 AM, Jörn Kottmann <kottmann@gmail.com> wrote:

> Hello William,
>
> all the new equals methods look like the one below.
> At the end in the else clause you return true, but that should really be
> false,
> otherwise two objects which are not of the same type are equals.
>
> Jörn
>
>
> On 8/17/11 12:30 AM, colen@apache.org wrote:
>
>> Modified: incubator/opennlp/trunk/**opennlp-tools/src/main/java/**
>> opennlp/tools/chunker/**ChunkSample.java
>> URL: http://svn.apache.org/viewvc/**incubator/opennlp/trunk/**
>> opennlp-tools/src/main/java/**opennlp/tools/chunker/**
>> ChunkSample.java?rev=1158465&**r1=1158464&r2=1158465&view=**diff<http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/chunker/ChunkSample.java?rev=1158465&r1=1158464&r2=1158465&view=diff>
>> ==============================**==============================**
>> ==================
>> --- incubator/opennlp/trunk/**opennlp-tools/src/main/java/**
>> opennlp/tools/chunker/**ChunkSample.java (original)
>> +++ incubator/opennlp/trunk/**opennlp-tools/src/main/java/**
>> opennlp/tools/chunker/**ChunkSample.java Tue Aug 16 22:30:53 2011
>> @@ -195,4 +195,20 @@ public class ChunkSample {
>>            }
>>            return chunkString.toString();
>>          }
>> +
>> +  @Override
>> +  public boolean equals(Object obj) {
>> +    if (this == obj) {
>> +      return true;
>> +    } else if (obj instanceof ChunkSample) {
>> +      ChunkSample a = (ChunkSample) obj;
>> +
>> +      return Arrays.equals(getSentence(), a.getSentence())
>> +&&  Arrays.equals(getTags(), a.getTags())
>> +&&  Arrays.equals(getPreds(), a.getPreds());
>> +    } else {
>> +      return true;
>> +    }
>> +  }
>> +
>>  }
>>
>>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message