dkpro / dkpro-wsd

DKPro WSD: A Java framework for word sense disambiguation
https://dkpro.github.io/dkpro-wsd
20 stars 10 forks source link

Clean up use of CAS/jCAS #70

Closed logological closed 9 years ago

logological commented 9 years ago

Originally reported on Google Code with ID 71

This suggestion comes from Richard:

In most cases, you should inherit from JCas-based components, e.g.

<pre>
public class MASCReader
    extends JCasResourceCollectionReader_ImplBase
</pre>

This is because getting the CAS from a JCas is a safe operation
while getting the JCas from a CAS requires handling a potential exception.

Bad:

<pre>
    public void getNext(CAS aCAS)
        throws IOException, CollectionException
    {
        JCas jCas;
        try {
            jCas = aCAS.getJCas();
        }
        catch (CASException e) {
            throw new CollectionException(e);
        }

</pre>

Good:

<pre>
    public void getNext(JCas jCas)
        throws IOException, CollectionException
    {
</pre>

Reported by tristan.miller@nothingisreal.com on 2015-01-09 14:03:07

logological commented 9 years ago

Reported by tristan.miller@nothingisreal.com on 2015-01-09 17:15:23