Package org.languagetool.synthesis
Class BaseSynthesizer
- java.lang.Object
-
- org.languagetool.synthesis.BaseSynthesizer
-
- All Implemented Interfaces:
Synthesizer
public class BaseSynthesizer extends Object implements Synthesizer
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>
possibleTags
String
SPELLNUMBER_TAG
-
Constructor Summary
Constructors Constructor Description BaseSynthesizer(String sorosFileName, String resourceFileName, String tagFileName, Language lang)
BaseSynthesizer(String resourceFileName, String tagFileName, Language lang)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected morfologik.stemming.IStemmer
createStemmer()
Creates a newIStemmer
based on the configureddictionary
.protected morfologik.stemming.Dictionary
getDictionary()
Returns theDictionary
used for this synthesizer.String
getPosTagCorrection(String posTag)
Gets a corrected version of the POS tag used for synthesis.String
getSpelledNumber(String arabicNumeral)
Spells out a numbermorfologik.stemming.IStemmer
getStemmer()
protected void
initPossibleTags()
protected void
lookup(String lemma, String posTag, List<String> results)
Lookup the inflected forms of a lemma defined by a part-of-speech tag.String[]
synthesize(AnalyzedToken token, String posTag)
Get a form of a given AnalyzedToken, where the form is defined by a part-of-speech tag.String[]
synthesize(AnalyzedToken token, String posTag, boolean posTagRegExp)
Generates a form of the word with a given POS tag for a given lemma.
-
-
-
Field Detail
-
SPELLNUMBER_TAG
public final String SPELLNUMBER_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDictionary
protected morfologik.stemming.Dictionary getDictionary() throws IOException
Returns theDictionary
used for this synthesizer. The dictionary file can be defined in theconstructor
.- Throws:
IOException
- In case the dictionary cannot be loaded.
-
createStemmer
protected morfologik.stemming.IStemmer createStemmer()
Creates a newIStemmer
based on the configureddictionary
. The result must not be shared among threads.- Since:
- 2.3
-
lookup
protected void lookup(String lemma, String posTag, List<String> results)
Lookup the inflected forms of a lemma defined by a part-of-speech tag.- Parameters:
lemma
- the lemma to be inflected.posTag
- the desired part-of-speech tag.results
- the list to collect the inflected forms.
-
synthesize
public String[] synthesize(AnalyzedToken token, String posTag) throws IOException
Get a form of a given AnalyzedToken, where the form is defined by a part-of-speech tag.- Specified by:
synthesize
in interfaceSynthesizer
- Parameters:
token
- AnalyzedToken to be inflected.posTag
- The desired part-of-speech tag.- Returns:
- inflected words, or an empty array if no forms were found
- Throws:
IOException
-
synthesize
public String[] synthesize(AnalyzedToken token, String posTag, boolean posTagRegExp) throws IOException
Description copied from interface:Synthesizer
Generates a form of the word with a given POS tag for a given lemma. POS tag can be specified using regular expressions.- Specified by:
synthesize
in interfaceSynthesizer
- Parameters:
token
- the token to be used for synthesisposTag
- POS tag of the form to be generatedposTagRegExp
- Specifies whether the posTag string is a regular expression.- Throws:
IOException
-
getPosTagCorrection
public String getPosTagCorrection(String posTag)
Description copied from interface:Synthesizer
Gets a corrected version of the POS tag used for synthesis. Useful when the tagset defines special disjunction that need to be converted into regexp disjunctions.- Specified by:
getPosTagCorrection
in interfaceSynthesizer
- Parameters:
posTag
- original POS tag to correct- Returns:
- converted POS tag
-
getStemmer
public morfologik.stemming.IStemmer getStemmer()
- Returns:
- the stemmer interface to be used.
- Since:
- 2.5
-
initPossibleTags
protected void initPossibleTags() throws IOException
- Throws:
IOException
-
getSpelledNumber
public String getSpelledNumber(String arabicNumeral)
Description copied from interface:Synthesizer
Spells out a number- Specified by:
getSpelledNumber
in interfaceSynthesizer
- Parameters:
arabicNumeral
- in arabic numerals- Returns:
- String of the spelled out number
-
-