edu.northwestern.at.morphadorner.servlets
Class BaseAdornerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by edu.northwestern.at.utils.servlets.XHttpServlet
              extended by edu.northwestern.at.morphadorner.servlets.BaseAdornerServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
LanguageRecognizerServlet, LemmatizerServlet, LexiconLookupServlet, NameRecognizerServlet, ParserServlet, PartOfSpeechTaggerServlet, PluralizerServlet, SentenceSplitterServlet, SpellingStandardizerServlet, TextSegmenterServlet, VerbConjugatorServlet, WordTokenizerServlet

public abstract class BaseAdornerServlet
extends XHttpServlet

Base class for MorphAdorner example servlets.

Extends XHttpServlet with methods for MorphAdorner servlets. Also stores common objects used by multiple servlets.

See Also:
Serialized Form

Field Summary
protected static SpellingMapper britishToUS
          British to US spelling mapper.
protected static java.lang.String dataDirectory
          Data directory.
protected static java.lang.String defaultDataDirectory
          Default data directory.
protected static Dictionary dictionary
          Link grammar dictionary.
protected static AdornerInfo emeAdornerInfo
          Early modern English adorner information.
protected static java.lang.String emeSpellingPairsFileName
          Early modern English alternate to standard spelling pairs.
protected static java.lang.String emeSuffixLexiconFileName
          Early modern English suffix lexicon File name.
protected static java.lang.String emeTransitionMatrixFileName
          Early modern English transition matrix file name.
protected static java.lang.String emeWordLexiconFileName
          Early modern English word lexicon file name.
protected static TaggedStrings extraWords
          Extra words list.
protected static java.lang.String extraWordsFileName
          Extra words file name.
protected static Inflector inflector
          English inflector.
protected static int INITDONE
           
protected static int INITFAILED
           
protected static int initializationStatus
          Initialization complete.
protected static int INITINPROGRESS
           
protected static int INITNOTSTARTED
          Initialization states.
protected static Stemmer lancasterStemmer
          Lancaster stemmer.
protected static LanguageRecognizer languageRecognizer
          The language recognizer.
protected static TaggedStrings latinWords
          Latin words list.
protected static java.lang.String latinWordsFileName
          Latin words file name.
protected static Lemmatizer lemmatizer
          The lemmatizer.
protected static java.lang.String lgParserDataDirectory
          Link grammar parser data file directory.
protected static Names names
          Names.
protected static AdornerInfo ncfAdornerInfo
          19th century adorner information.
protected static java.lang.String ncfSpellingPairsFileName
          Alternate to standard spelling pairs for 19th century fiction.
protected static java.lang.String ncfSuffixLexiconFileName
          19th century fiction lexicon file name.
protected static java.lang.String ncfTransitionMatrixFileName
          19th century fiction transition matrix file name.
protected static java.lang.String ncfWordLexiconFileName
          19th century fiction lexicon file name.
protected  boolean outputFullHTML
          True to Output full top and bottom page HTML.
protected static ParseOptions parseOptions
          Link grammar parser options.
protected static Stemmer porterStemmer
          Porter stemmer.
protected static java.lang.String servletNotReadyMessage
          Servlet not ready message.
protected static java.lang.String servletNotReadyTitle
          Servlet not ready title.
protected static java.lang.String standardSpellingsFileName
          Standard spellings file name.
 
Constructor Summary
BaseAdornerServlet()
           
 
Method Summary
protected  ServletResult doHandleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle request.
protected static void doInitialization(javax.servlet.ServletConfig config)
          Initialize common objects.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle servlet post requests.
static AdornerInfo getAdornerInfo(java.lang.String adornerName)
          Select adorner to use.
static TaggedStrings getExtraWordsList()
          Get extra words list.
static int getIntValue(java.lang.String requestValue, int defaultValue)
          Gets integer parameter value.
static TaggedStrings getLatinWordsList()
          Get Latin words list.
protected abstract  ServletResult handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle request.
protected static void initialize(javax.servlet.ServletConfig config)
          Initialize common objects.
static boolean isReady()
          Check if servlet ready for use.
 void outputAdornerSelection(java.io.PrintWriter out, java.lang.String label, java.lang.String adornerName)
          Output adorner selection form field.
 void outputFooter(java.io.PrintWriter out)
          Output bottom of page.
 void outputHeader(java.io.PrintWriter out, java.lang.String title)
          Output top of page.
 ServletResult outputNotReady(java.lang.String notReadyMessage)
          Output servlet not ready message.
 void outputResults(javax.servlet.http.HttpServletResponse response, java.lang.String results, java.lang.String title)
          Return stored results.
 void outputSelect(java.io.PrintWriter out, java.lang.String selectValue, boolean selected)
          Output a select clause.
 void outputSpacerRow(java.io.PrintWriter out, int nColumns)
          Output empty table row as spacer.
 java.lang.String unTag(java.lang.String text)
          Remove HTML/XML tags from text.
 
Methods inherited from class edu.northwestern.at.utils.servlets.XHttpServlet
createRedirectURL, doGet
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputFullHTML

protected boolean outputFullHTML
True to Output full top and bottom page HTML. false to output only servlet output.


defaultDataDirectory

protected static java.lang.String defaultDataDirectory
Default data directory.


dataDirectory

protected static java.lang.String dataDirectory
Data directory.


ncfAdornerInfo

protected static AdornerInfo ncfAdornerInfo
19th century adorner information.


ncfWordLexiconFileName

protected static java.lang.String ncfWordLexiconFileName
19th century fiction lexicon file name.


ncfSuffixLexiconFileName

protected static java.lang.String ncfSuffixLexiconFileName
19th century fiction lexicon file name.


ncfSpellingPairsFileName

protected static java.lang.String ncfSpellingPairsFileName
Alternate to standard spelling pairs for 19th century fiction.


ncfTransitionMatrixFileName

protected static java.lang.String ncfTransitionMatrixFileName
19th century fiction transition matrix file name.


emeAdornerInfo

protected static AdornerInfo emeAdornerInfo
Early modern English adorner information.


emeWordLexiconFileName

protected static java.lang.String emeWordLexiconFileName
Early modern English word lexicon file name.


emeSuffixLexiconFileName

protected static java.lang.String emeSuffixLexiconFileName
Early modern English suffix lexicon File name.


emeTransitionMatrixFileName

protected static java.lang.String emeTransitionMatrixFileName
Early modern English transition matrix file name.


emeSpellingPairsFileName

protected static java.lang.String emeSpellingPairsFileName
Early modern English alternate to standard spelling pairs.


standardSpellingsFileName

protected static java.lang.String standardSpellingsFileName
Standard spellings file name.


lemmatizer

protected static Lemmatizer lemmatizer
The lemmatizer.


porterStemmer

protected static Stemmer porterStemmer
Porter stemmer.


lancasterStemmer

protected static Stemmer lancasterStemmer
Lancaster stemmer.


names

protected static Names names
Names.


languageRecognizer

protected static LanguageRecognizer languageRecognizer
The language recognizer.


inflector

protected static Inflector inflector
English inflector.


britishToUS

protected static SpellingMapper britishToUS
British to US spelling mapper.


extraWordsFileName

protected static java.lang.String extraWordsFileName
Extra words file name.


latinWordsFileName

protected static java.lang.String latinWordsFileName
Latin words file name.


latinWords

protected static TaggedStrings latinWords
Latin words list.


extraWords

protected static TaggedStrings extraWords
Extra words list.


dictionary

protected static Dictionary dictionary
Link grammar dictionary.


parseOptions

protected static ParseOptions parseOptions
Link grammar parser options.


lgParserDataDirectory

protected static java.lang.String lgParserDataDirectory
Link grammar parser data file directory.


INITNOTSTARTED

protected static final int INITNOTSTARTED
Initialization states.

See Also:
Constant Field Values

INITINPROGRESS

protected static final int INITINPROGRESS
See Also:
Constant Field Values

INITDONE

protected static final int INITDONE
See Also:
Constant Field Values

INITFAILED

protected static final int INITFAILED
See Also:
Constant Field Values

initializationStatus

protected static int initializationStatus
Initialization complete.


servletNotReadyMessage

protected static final java.lang.String servletNotReadyMessage
Servlet not ready message.

See Also:
Constant Field Values

servletNotReadyTitle

protected static final java.lang.String servletNotReadyTitle
Servlet not ready title.

See Also:
Constant Field Values
Constructor Detail

BaseAdornerServlet

public BaseAdornerServlet()
Method Detail

doInitialization

protected static void doInitialization(javax.servlet.ServletConfig config)
Initialize common objects.

Parameters:
config - Servlet configuration.

initialize

protected static void initialize(javax.servlet.ServletConfig config)
Initialize common objects.

Parameters:
config - Servlet configuration.

getLatinWordsList

public static TaggedStrings getLatinWordsList()
Get Latin words list.


getExtraWordsList

public static TaggedStrings getExtraWordsList()
Get extra words list.


getAdornerInfo

public static AdornerInfo getAdornerInfo(java.lang.String adornerName)
Select adorner to use.

Parameters:
adornerName - Adorner name.
Returns:
AdornerInfo for specified adorner.

isReady

public static boolean isReady()
Check if servlet ready for use.

Returns:
true if servlet ready for use.

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Handle servlet post requests.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - Servlet request.
response - Servlet response.
Throws:
javax.servlet.ServletException
java.io.IOException

outputHeader

public void outputHeader(java.io.PrintWriter out,
                         java.lang.String title)
Output top of page.

Parameters:
out - PrintWriter for servlet output.
title - The servlet title.

outputNotReady

public ServletResult outputNotReady(java.lang.String notReadyMessage)
Output servlet not ready message.

Parameters:
notReadyMessage - Server not ready message.

outputSpacerRow

public void outputSpacerRow(java.io.PrintWriter out,
                            int nColumns)
Output empty table row as spacer.

Parameters:
out - PrintWriter for servlet output.
nColumns - Number of empty table columns to output.

outputFooter

public void outputFooter(java.io.PrintWriter out)
Output bottom of page.

Parameters:
out - PrintWriter for servlet output.

outputSelect

public void outputSelect(java.io.PrintWriter out,
                         java.lang.String selectValue,
                         boolean selected)
Output a select clause.

Parameters:
out - PrintWriter for servlet output.
selectValue - The value.
selected - True if selected.

outputAdornerSelection

public void outputAdornerSelection(java.io.PrintWriter out,
                                   java.lang.String label,
                                   java.lang.String adornerName)
Output adorner selection form field.

Parameters:
out - PrintWriter for servlet output.
label - Column label. May be empty.
adornerName - Adorner name.

outputResults

public void outputResults(javax.servlet.http.HttpServletResponse response,
                          java.lang.String results,
                          java.lang.String title)
                   throws java.io.IOException
Return stored results.

Parameters:
response - Servlet response object.
results - Result string to return to client for display.
title - Title for output.
Throws:
java.io.IOException

unTag

public java.lang.String unTag(java.lang.String text)
Remove HTML/XML tags from text.

Parameters:
text - The text from which to remove tags.
Returns:
The text with tags removed.

doHandleRequest

protected ServletResult doHandleRequest(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)
                                 throws javax.servlet.ServletException,
                                        java.io.IOException
Handle request.

Parameters:
request - Servlet request.
response - Servlet response.
Returns:
Servlet results.
Throws:
javax.servlet.ServletException
java.io.IOException

getIntValue

public static int getIntValue(java.lang.String requestValue,
                              int defaultValue)
Gets integer parameter value.

Parameters:
requestValue - Parameter value from request.
defaultValue - Default parameter value if parameter null or invalid.
Returns:
The parameter value, or the defaultValue if paramValue is null or invalid.

handleRequest

protected abstract ServletResult handleRequest(javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response)
                                        throws javax.servlet.ServletException,
                                               java.io.IOException
Handle request. Must be overridden in subclass.

Parameters:
request - Servlet request.
response - Servlet response.
Returns:
Servlet results.
Throws:
javax.servlet.ServletException
java.io.IOException