|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkr.ac.kaist.swrc.jhannanum.hannanum.Workflow
public class Workflow
This class is for the HanNanum work flow, which can be set up with more than one
HanNanum plug-in. The work flow can be used with the following steps:
1. Create the work flow using one of the constructors with suitable configurations.
2. Set the plug-ins up on the work flow regarding the purpose of analysis and the characteristics of input.
3. Activate the work flow in the multi-thread mode or the single thread mode.
4. Analyze the target text with the work flow.
5. Get the result with some relevant data type or string representation.
6. Repeat the step 4-5 you need it.
7. Close the work flow when it will not be used anymore.
Take a look the demo program - kr.ac.kaist.swrc.jhannanum.demo.WorkflowWithHMMTagger for an example.
Field Summary | |
---|---|
private java.lang.String |
baseDir
The path for the base directory data and configuration files. |
private boolean |
isInitialized
It is true when the work flow is ready for analysis. |
private boolean |
isThreadMode
The flag for the thread mode. true: multi-thread mode, false: single-thread mode. |
static int |
MAX_SUPPLEMENT_PLUGIN_NUM
The default value for the maximum number of the supplement plug-ins on each phase. |
private int |
maxSupplementPluginNum
The maximum number of the supplement plug-ins of each phase. |
private MorphAnalyzer |
morphAnalyzer
The second phase, major plug-in - morphological analyzer. |
private java.lang.String |
morphAnalyzerConfFile
The configuration file for the morphological analyzer. |
private int |
morphemePluginCnt
The number of the morpheme processors. |
private MorphemeProcessor[] |
morphemeProcessors
The second phase, supplement plug-ins, morpheme processors. |
private java.lang.String[] |
morphemeProcessorsConfFiles
The configuration files for the morpheme processors. |
private int |
outputPhaseNum
The analysis phase of the work flow. |
private int |
outputQueueNum
The number of the plug-ins for the last phase of the work flow. |
private int |
plainTextPluginCnt
The number of the plain text processors. |
private PlainTextProcessor[] |
plainTextProcessors
The first phase, supplement plug-ins, plain text processors. |
private java.lang.String[] |
plainTextProcessorsConfFiles
The configuration files for the plain text processors. |
private int |
posPluginCnt
The number of pos processors. |
private java.lang.String[] |
posProcessorConfFiles
The configuration file for the pos processors. |
private PosProcessor[] |
posProcessors
The third phase, supplement plug-ins, pos processors. |
private PosTagger |
posTagger
The third phase, major plug-in - POS tagger. |
private java.lang.String |
posTaggerConfFile
The configuration file for the POS tagger. |
(package private) java.util.ArrayList<java.util.concurrent.LinkedBlockingQueue<PlainSentence>> |
queuePhase1
The communication queues for the fist phase plug-ins. |
(package private) java.util.ArrayList<java.util.concurrent.LinkedBlockingQueue<SetOfSentences>> |
queuePhase2
The communication queues for the second phase plug-ins. |
(package private) java.util.ArrayList<java.util.concurrent.LinkedBlockingQueue<Sentence>> |
queuePhase3
The communication queues for the third phase plug-ins. |
private java.util.LinkedList<java.lang.Thread> |
threadList
Plug-in thread list. |
Constructor Summary | |
---|---|
Workflow()
Constructor. |
|
Workflow(java.lang.String baseDir)
Constructor. |
|
Workflow(java.lang.String baseDir,
int maxSupplementPluginNum)
Constructor. |
Method Summary | ||
---|---|---|
void |
activateWorkflow(boolean threadMode)
It activates the work flow with the plug-ins that were set up. |
|
void |
analyze(java.io.File document)
It adds the specified input text to the input queue of the work flow. |
|
void |
analyze(java.lang.String document)
It adds the specified input text to the input queue of the work flow. |
|
private void |
analyzeInSingleThread()
Analyze the text in the single thread. |
|
void |
appendMorphemeProcessor(MorphemeProcessor plugin,
java.lang.String configFile)
Appends the morpheme processor plug-in, which is the supplement plug-in on the second phase, on the work flow. |
|
void |
appendPlainTextProcessor(PlainTextProcessor plugin,
java.lang.String configFile)
Appends the plain text processor plug-in, which is the supplement plug-in on the first phase, on the work flow. |
|
void |
appendPosProcessor(PosProcessor plugin,
java.lang.String configFile)
Appends the POS processor plug-in, which is the supplement plug-in on the third phase, on the work flow. |
|
void |
clear()
It removes the plug-ins on the work flow. |
|
void |
close()
It ends the threads for each plug-in on the work flow. |
|
java.lang.String |
getResultOfDocument()
Returns the analysis result list for all sentence in the result. |
|
|
getResultOfDocument(T a)
Returns the analysis result list for all sentence in the result. |
|
java.lang.String |
getResultOfSentence()
Returns the analysis result for one sentence at the top of the result queue. |
|
|
getResultOfSentence(T a)
Returns the analysis result for one sentence at the top of the result queue. |
|
private void |
runThreads()
It starts the threads for each plug-in on the work flow, when the work flow was activated with the multi-thread mode. |
|
void |
setMorphAnalyzer(MorphAnalyzer ma,
java.lang.String configFile)
Sets the morphological analyzer plug-in, which is the major plug-in on second phase, on the work flow. |
|
void |
setPosTagger(PosTagger tagger,
java.lang.String configFile)
Sets the POS tagger plug-in, which is the major plug-in on the third phase, on the work flow. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int MAX_SUPPLEMENT_PLUGIN_NUM
private int maxSupplementPluginNum
private boolean isThreadMode
private int outputPhaseNum
private int outputQueueNum
private java.util.LinkedList<java.lang.Thread> threadList
private MorphAnalyzer morphAnalyzer
private java.lang.String morphAnalyzerConfFile
private PosTagger posTagger
private java.lang.String posTaggerConfFile
private PlainTextProcessor[] plainTextProcessors
private java.lang.String[] plainTextProcessorsConfFiles
private int plainTextPluginCnt
private MorphemeProcessor[] morphemeProcessors
private java.lang.String[] morphemeProcessorsConfFiles
private int morphemePluginCnt
private PosProcessor[] posProcessors
private java.lang.String[] posProcessorConfFiles
private int posPluginCnt
private boolean isInitialized
private java.lang.String baseDir
java.util.ArrayList<java.util.concurrent.LinkedBlockingQueue<PlainSentence>> queuePhase1
java.util.ArrayList<java.util.concurrent.LinkedBlockingQueue<SetOfSentences>> queuePhase2
java.util.ArrayList<java.util.concurrent.LinkedBlockingQueue<Sentence>> queuePhase3
Constructor Detail |
---|
public Workflow()
public Workflow(java.lang.String baseDir)
baseDir
- - the path for base directory, which should have the 'conf' and 'data' directorypublic Workflow(java.lang.String baseDir, int maxSupplementPluginNum)
baseDir
- - the path for base directory, which should have the 'conf' and 'data' directorymaxSupplementPluginNum
- - the maximum number of supplement plug-ins for each phaseMethod Detail |
---|
public void setMorphAnalyzer(MorphAnalyzer ma, java.lang.String configFile)
ma
- - the morphological analyzer plug-inconfigFile
- - the path for the configuration file (relative path to the base directory)public void setPosTagger(PosTagger tagger, java.lang.String configFile)
tagger
- - the POS tagger plug-inconfigFile
- - the path for the configuration file (relative path to the base directory)public void appendPlainTextProcessor(PlainTextProcessor plugin, java.lang.String configFile)
plugin
- - the plain text processor plug-inconfigFile
- - the path for the configuration file (relative path to the base directory)public void appendMorphemeProcessor(MorphemeProcessor plugin, java.lang.String configFile)
plugin
- - the morpheme processor plug-inconfigFile
- - the path for the configuration file (relative path to the base directory)public void appendPosProcessor(PosProcessor plugin, java.lang.String configFile)
plugin
- - the plain POS processor plug-inconfigFile
- - the path for the configuration file (relative path to the base directory)public void activateWorkflow(boolean threadMode) throws java.lang.Exception
threadMode
- - true: multi-thread mode, false: sigle thread mode
java.lang.Exception
private void runThreads()
public void close()
public void clear()
public void analyze(java.lang.String document)
document
- - sequence of sentences separated with newlines.public void analyze(java.io.File document) throws java.io.IOException
document
- - the path for the text file to be analyzed
java.io.IOException
public <T> T getResultOfSentence(T a) throws ResultTypeException
T
- - One of PlainSentence (for the first phase), Sentence (for the second phase), and SetOfSentences (for the third phase).a
- - the object to get the result
ResultTypeException
public java.lang.String getResultOfSentence()
ResultTypeException
public <T> java.util.LinkedList<T> getResultOfDocument(T a) throws ResultTypeException
T
- - One of PlainSentence (for the first phase), Sentence (for the second phase), and SetOfSentences (for the third phase).a
- - the object to specify the return type
ResultTypeException
public java.lang.String getResultOfDocument()
ResultTypeException
private void analyzeInSingleThread()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |