uk.ac.man.entitytagger.matching.matchers
Class ConcurrentMatcher
java.lang.Object
uk.ac.man.entitytagger.matching.matchers.ConcurrentMatcher
- All Implemented Interfaces:
- java.util.Iterator<Problem<TaggedDocument>>
public class ConcurrentMatcher
- extends java.lang.Object
- implements java.util.Iterator<Problem<TaggedDocument>>
Class for facilitating concurrent text matching.
This class should be used together with martin.common.compthreads.IteratorBasedMaster.
A IteratorBasedMaster object is created based on an object of this class, a thread is created from the master object, and match results can be retrieved from the master object.
Note that results returned from the master will be TaggedDocument if using the single-matcher constructor, and ArrayList if using the multi-matcher constructor.
Sample code:
ThreadMatcher tm = new ThreadMatcher(somematcher, somedocuments);
IteratorBasedMaster master = new IteratorBasedMaster(tm, somenumberofthreads);
new Thread(master).start();
while (master.hasNext()){
TaggedDocument td = (TaggedDocument) master.next();
//do something with the tagged document here
}
If an array of matchers had been given to the ThreadMatcher constructor, results would have been on the form ArrayList tds = (ArrayList master.next();.
- Author:
- Martin
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
matcher
private Matcher matcher
documents
private DocumentIterator documents
ConcurrentMatcher
public ConcurrentMatcher(Matcher matcher,
DocumentIterator documents)
- Create an object which will do matching using a single matcher over a number of documents.
- Parameters:
matcher
- documents
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator<Problem<TaggedDocument>>
next
public ConcurrentMatcher.MatchProblem next()
- Specified by:
next
in interface java.util.Iterator<Problem<TaggedDocument>>
remove
public void remove()
- Specified by:
remove
in interface java.util.Iterator<Problem<TaggedDocument>>