Package net.sf.okapi.lib.translation
Class BaseConnector
- java.lang.Object
-
- net.sf.okapi.lib.translation.BaseConnector
-
- All Implemented Interfaces:
AutoCloseable,Iterator<QueryResult>,IQuery
public abstract class BaseConnector extends Object implements IQuery
Abstract implementation of theIQueryinterface.
-
-
Constructor Summary
Constructors Constructor Description BaseConnector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbatchLeverage(List<ITextUnit> tus)Slow default implementation using leverage(TextUnit).protected voidbatchLeverageUsingBatchQuery(List<ITextUnit> tuList)Call this method inside the overridingbatchLeverage(List)method of the derived class, if that class offers a fastbatchQuery(List)method.List<List<QueryResult>>batchQuery(List<TextFragment> fragments)Slow default implementation using query!! Override to take advantage of servers batch APIList<List<QueryResult>>batchQueryText(List<String> plainTexts)voidclearAttributes()intgetNoQueryThreshold()IParametersgetParameters()LocaleIdgetSourceLanguage()LocaleIdgetTargetLanguage()intgetWeight()booleanhasNext()voidleverage(ITextUnit tu)protected voidleverageUsingBatchQuery(ITextUnit tu)Call this method inside the overridingleverage(ITextUnit)method of the derived class, if that class offers a fastbatchQuery(List)method.QueryResultnext()voidremoveAttribute(String name)voidsetAttribute(String name, String value)voidsetLanguages(LocaleId sourceLocale, LocaleId targetLocale)voidsetNoQueryThreshold(int noQueryThreshold)voidsetParameters(IParameters params)voidsetRootDirectory(String rootDir)voidsetWeight(int weight)protected StringtoInternalCode(LocaleId locId)Converts a locale identifier to the internal string value for a language/locale code for this connector.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.query.IQuery
close, getName, getSettingsDisplay, open, query, query
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
srcLoc
protected LocaleId srcLoc
-
srcCode
protected String srcCode
-
trgLoc
protected LocaleId trgLoc
-
trgCode
protected String trgCode
-
result
protected QueryResult result
-
current
protected int current
-
-
Method Detail
-
getSourceLanguage
public LocaleId getSourceLanguage()
- Specified by:
getSourceLanguagein interfaceIQuery
-
getTargetLanguage
public LocaleId getTargetLanguage()
- Specified by:
getTargetLanguagein interfaceIQuery
-
setLanguages
public void setLanguages(LocaleId sourceLocale, LocaleId targetLocale)
- Specified by:
setLanguagesin interfaceIQuery
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfaceIQuery- Specified by:
hasNextin interfaceIterator<QueryResult>
-
next
public QueryResult next()
- Specified by:
nextin interfaceIQuery- Specified by:
nextin interfaceIterator<QueryResult>
-
clearAttributes
public void clearAttributes()
- Specified by:
clearAttributesin interfaceIQuery
-
removeAttribute
public void removeAttribute(String name)
- Specified by:
removeAttributein interfaceIQuery
-
setAttribute
public void setAttribute(String name, String value)
- Specified by:
setAttributein interfaceIQuery
-
setRootDirectory
public void setRootDirectory(String rootDir)
- Specified by:
setRootDirectoryin interfaceIQuery
-
getParameters
public IParameters getParameters()
- Specified by:
getParametersin interfaceIQuery
-
setParameters
public void setParameters(IParameters params)
- Specified by:
setParametersin interfaceIQuery
-
batchQueryText
public List<List<QueryResult>> batchQueryText(List<String> plainTexts)
- Specified by:
batchQueryTextin interfaceIQuery
-
batchQuery
public List<List<QueryResult>> batchQuery(List<TextFragment> fragments)
Slow default implementation using query!! Override to take advantage of servers batch API- Specified by:
batchQueryin interfaceIQuery
-
batchLeverage
public void batchLeverage(List<ITextUnit> tus)
Slow default implementation using leverage(TextUnit). Override in sub-class if you want a custom batchLeverage- Specified by:
batchLeveragein interfaceIQuery- Parameters:
tus- list of the text units to process.
-
setNoQueryThreshold
public void setNoQueryThreshold(int noQueryThreshold)
- Specified by:
setNoQueryThresholdin interfaceIQuery
-
getNoQueryThreshold
public int getNoQueryThreshold()
- Specified by:
getNoQueryThresholdin interfaceIQuery
-
leverageUsingBatchQuery
protected void leverageUsingBatchQuery(ITextUnit tu)
Call this method inside the overridingleverage(ITextUnit)method of the derived class, if that class offers a fastbatchQuery(List)method.- Parameters:
tu- the text unit to leverage.
-
batchLeverageUsingBatchQuery
protected void batchLeverageUsingBatchQuery(List<ITextUnit> tuList)
Call this method inside the overridingbatchLeverage(List)method of the derived class, if that class offers a fastbatchQuery(List)method.- Parameters:
tuList- list of the text units to leverage.
-
toInternalCode
protected String toInternalCode(LocaleId locId)
Converts a locale identifier to the internal string value for a language/locale code for this connector. By default, this simply returns the string of the given LocaleId.- Parameters:
locId- the locale identifier to convert.- Returns:
- the internal string code for language/locale code for this connector.
-
-