public abstract class BaseConnector extends Object implements IQuery
IQuery interface.| Modifier and Type | Field and Description |
|---|---|
protected int |
current |
protected QueryResult |
result |
protected String |
srcCode |
protected LocaleId |
srcLoc |
protected String |
trgCode |
protected LocaleId |
trgLoc |
| Constructor and Description |
|---|
BaseConnector() |
| Modifier and Type | Method and Description |
|---|---|
void |
batchLeverage(List<ITextUnit> tus)
Slow default implementation using leverage(TextUnit).
|
protected void |
batchLeverageUsingBatchQuery(List<ITextUnit> tuList)
Call this method inside the overriding
batchLeverage(List) method
of the derived class, if that class offers a fast batchQuery(List) method. |
List<List<QueryResult>> |
batchQuery(List<TextFragment> fragments)
Slow default implementation using query!!
Override to take advantage of servers batch API
|
List<List<QueryResult>> |
batchQueryText(List<String> plainTexts)
Starts a batch query for a given list of plain texts.
|
void |
clearAttributes()
Removes all attributes from this query engine.
|
int |
getNoQueryThreshold()
Gets the threshold for when to avoid a query.
|
IParameters |
getParameters()
Gets the current parameters of this connector.
|
LocaleId |
getSourceLanguage()
Gets the current source language for this query engine.
|
LocaleId |
getTargetLanguage()
Gets the current target language for this query engine.
|
int |
getWeight()
Get the weight for this connector.
|
boolean |
hasNext()
Indicates of there is a hit available.
|
void |
leverage(ITextUnit tu)
Leverages a text unit (segmented or not) based on the current settings.
|
protected void |
leverageUsingBatchQuery(ITextUnit tu)
Call this method inside the overriding
leverage(ITextUnit) method
of the derived class, if that class offers a fast batchQuery(List) method. |
QueryResult |
next()
Gets the next hit for the last query.
|
void |
removeAttribute(String name)
Removes a given attribute from this query engine.
|
void |
setAttribute(String name,
String value)
Sets an attribute for this query engine.
|
void |
setLanguages(LocaleId sourceLocale,
LocaleId targetLocale)
Sets the source and target languages for this query engine.
|
void |
setNoQueryThreshold(int noQueryThreshold)
Sets the threshold for when to avoid executing a query.
|
void |
setParameters(IParameters params)
Sets the parameters for opening and querying this connector.
|
void |
setRootDirectory(String rootDir)
Sets the root directory that may be used to replace the available ${rootDir} in the
parameters of this object.
|
void |
setWeight(int weight)
Set the relative weight of this
IQuery connector as compared to
other connectors. |
protected String |
toInternalCode(LocaleId locId)
Converts a locale identifier to the internal string value for a language/locale code for this connector.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getName, getSettingsDisplay, open, query, queryforEachRemaining, removeprotected LocaleId srcLoc
protected String srcCode
protected LocaleId trgLoc
protected String trgCode
protected QueryResult result
protected int current
public LocaleId getSourceLanguage()
IQuerygetSourceLanguage in interface IQuerypublic LocaleId getTargetLanguage()
IQuerygetTargetLanguage in interface IQuerypublic void setLanguages(LocaleId sourceLocale, LocaleId targetLocale)
IQuerysetLanguages in interface IQuerysourceLocale - Code of the source locale.targetLocale - Code of the target locale.public boolean hasNext()
IQueryhasNext in interface Iterator<QueryResult>hasNext in interface IQuerypublic QueryResult next()
IQuerynext in interface Iterator<QueryResult>next in interface IQuerypublic void clearAttributes()
IQueryclearAttributes in interface IQuerypublic void removeAttribute(String name)
IQueryremoveAttribute in interface IQueryname - The name of the attribute to remove.public void setAttribute(String name, String value)
IQuerysetAttribute in interface IQueryname - name of the attribute.value - Value of the attribute.public void setRootDirectory(String rootDir)
IQuerysetRootDirectory in interface IQueryrootDir - the root directory.public IParameters getParameters()
IQuerygetParameters in interface IQuerypublic void setParameters(IParameters params)
IQuerysetParameters in interface IQueryparams - the parameters to set.public int getWeight()
IQuerypublic void setWeight(int weight)
IQueryIQuery connector as compared to
other connectors. Used to set QueryResult.weight.public List<List<QueryResult>> batchQueryText(List<String> plainTexts)
IQuerybatchQueryText in interface IQueryplainTexts - list of the plain texts to translate.public List<List<QueryResult>> batchQuery(List<TextFragment> fragments)
batchQuery in interface IQueryfragments - list of the text fragments to translate.public void leverage(ITextUnit tu)
IQuerypublic void batchLeverage(List<ITextUnit> tus)
batchLeverage in interface IQuerytus - list of the text units to process.public void setNoQueryThreshold(int noQueryThreshold)
IQueryIf the entry to leverage has already one candidate with a score equals or above this value, no query is performed. Use 101 to always allow the query.
setNoQueryThreshold in interface IQuerynoQueryThreshold - no-query threshold (a value between 0 and 101).public int getNoQueryThreshold()
IQuerygetNoQueryThreshold in interface IQueryprotected void leverageUsingBatchQuery(ITextUnit tu)
leverage(ITextUnit) method
of the derived class, if that class offers a fast batchQuery(List) method.tu - the text unit to leverage.protected void batchLeverageUsingBatchQuery(List<ITextUnit> tuList)
batchLeverage(List) method
of the derived class, if that class offers a fast batchQuery(List) method.tuList - list of the text units to leverage.protected String toInternalCode(LocaleId locId)
locId - the locale identifier to convert.Copyright © 2022. All rights reserved.