fangfangli / cleartk

Automatically exported from code.google.com/p/cleartk
0 stars 0 forks source link

get rid of boolean parameter in UriCollectionReader #317

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Boolean parameters always make me uncomfortable. If you see code like:

UriCollectionReader.getCollectionReaderFromDirectory(textDirectory, true);

All you can do is guess what that "true" at the end is doing. I'd much prefer 
either an enum, or a class, or something that tells me more than the boolean. I 
should probably make a ticket that's broader than this one that says "get rid 
of all boolean parameters", but let's just deal with UriCollectionReader for 
the moment.

Here's my proposal: change the parameter to "predicate", and then provide a 
static class RejectSystemFilesPredicate that implements Predicate in exactly 
the way your anonymous "rejectSystemFile" Predicate does now. Then the method 
can look like:

UriCollectionReader.getCollectionReaderFromDirectory(textDirectory, 
RejectSystemFilesPredicate.class);

This would have the added benefit of allowing you to pass any arbitrary 
Predicate in to UriCollectionReader. And it shouldn't be a problem UIMA-wise, 
because we know how to pass classes in UIMA.

Original issue reported on code.google.com by steven.b...@gmail.com on 27 Jul 2012 at 7:06

GoogleCodeExporter commented 9 years ago

Original comment by lee.becker on 1 Aug 2012 at 8:57