Package net.sf.okapi.connectors.pensieve
Class PensieveTMConnector
- java.lang.Object
-
- net.sf.okapi.lib.translation.BaseConnector
-
- net.sf.okapi.connectors.pensieve.PensieveTMConnector
-
- All Implemented Interfaces:
AutoCloseable
,Iterator<QueryResult>
,IQuery
,ITMQuery
- Direct Known Subclasses:
BilingualFileConnector
public class PensieveTMConnector extends BaseConnector implements ITMQuery
-
-
Constructor Summary
Constructors Constructor Description PensieveTMConnector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAttributes()
Removes all attributes from this query engine.void
close()
Closes this connector.int
getMaximumHits()
Gets the current maximum number of hits to retrieve.String
getName()
Gets the name of the connector.IParameters
getParameters()
Gets the current parameters of this connector.String
getSettingsDisplay()
Gets a display representation of the current settings for this connector.int
getThreshold()
Gets the current threshold value to use for the query.boolean
hasNext()
Indicates of there is a hit available.QueryResult
next()
Gets the next hit for the last query.void
open()
Opens this query engine.int
query(String plainText)
Starts a query for a give plain text.int
query(TextFragment text)
Starts a query for a given text.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
setMaximumHits(int max)
Sets the maximum number of hits to retrieve.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
setThreshold(int threshold)
Sets the threshold value to use for the query.-
Methods inherited from class net.sf.okapi.lib.translation.BaseConnector
batchLeverage, batchLeverageUsingBatchQuery, batchQuery, batchQueryText, getNoQueryThreshold, getSourceLanguage, getTargetLanguage, getWeight, leverage, leverageUsingBatchQuery, setNoQueryThreshold, setWeight, toInternalCode
-
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
batchLeverage, batchQuery, batchQueryText, getNoQueryThreshold, getSourceLanguage, getTargetLanguage, getWeight, leverage, setNoQueryThreshold, setWeight
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:IQuery
Gets the name of the connector.
-
getSettingsDisplay
public String getSettingsDisplay()
Description copied from interface:IQuery
Gets a display representation of the current settings for this connector. This can be a display of some of the parameters for example, or some explanations about default non-modifiable settings.- Specified by:
getSettingsDisplay
in interfaceIQuery
- Returns:
- a display representation of the current settings.
-
setMaximumHits
public void setMaximumHits(int max)
Description copied from interface:ITMQuery
Sets the maximum number of hits to retrieve.- Specified by:
setMaximumHits
in interfaceITMQuery
- Parameters:
max
- The maximum number of hits to retrieve.
-
setThreshold
public void setThreshold(int threshold)
Description copied from interface:ITMQuery
Sets the threshold value to use for the query.- Specified by:
setThreshold
in interfaceITMQuery
- Parameters:
threshold
- The threshold value (between 0 and 100).
-
close
public void close()
Description copied from interface:IQuery
Closes this connector.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceIQuery
-
hasNext
public boolean hasNext()
Description copied from interface:IQuery
Indicates of there is a hit available.- Specified by:
hasNext
in interfaceIQuery
- Specified by:
hasNext
in interfaceIterator<QueryResult>
- Overrides:
hasNext
in classBaseConnector
- Returns:
- True if a hit is available, false if not.
-
next
public QueryResult next()
Description copied from interface:IQuery
Gets the next hit for the last query.- Specified by:
next
in interfaceIQuery
- Specified by:
next
in interfaceIterator<QueryResult>
- Overrides:
next
in classBaseConnector
- Returns:
- A QueryResult object that holds the source and target text of the hit, or null if there is no more hit.
-
open
public void open()
Description copied from interface:IQuery
Opens this query engine.
-
query
public int query(String plainText)
Description copied from interface:IQuery
Starts a query for a give plain text.
-
query
public int query(TextFragment text)
Description copied from interface:IQuery
Starts a query for a given text.
-
setAttribute
public void setAttribute(String name, String value)
Description copied from interface:IQuery
Sets an attribute for this query engine.- Specified by:
setAttribute
in interfaceIQuery
- Overrides:
setAttribute
in classBaseConnector
- Parameters:
name
- name of the attribute.value
- Value of the attribute.
-
clearAttributes
public void clearAttributes()
Description copied from interface:IQuery
Removes all attributes from this query engine.- Specified by:
clearAttributes
in interfaceIQuery
- Overrides:
clearAttributes
in classBaseConnector
-
removeAttribute
public void removeAttribute(String name)
Description copied from interface:IQuery
Removes a given attribute from this query engine.- Specified by:
removeAttribute
in interfaceIQuery
- Overrides:
removeAttribute
in classBaseConnector
- Parameters:
name
- The name of the attribute to remove.
-
setLanguages
public void setLanguages(LocaleId sourceLocale, LocaleId targetLocale)
Description copied from interface:IQuery
Sets the source and target languages for this query engine.- Specified by:
setLanguages
in interfaceIQuery
- Overrides:
setLanguages
in classBaseConnector
- Parameters:
sourceLocale
- Code of the source locale.targetLocale
- Code of the target locale.
-
getMaximumHits
public int getMaximumHits()
Description copied from interface:ITMQuery
Gets the current maximum number of hits to retrieve.- Specified by:
getMaximumHits
in interfaceITMQuery
- Returns:
- the current maximum number of hits to retrieve.
-
getThreshold
public int getThreshold()
Description copied from interface:ITMQuery
Gets the current threshold value to use for the query.- Specified by:
getThreshold
in interfaceITMQuery
- Returns:
- The current threshold value to use for the query.
-
getParameters
public IParameters getParameters()
Description copied from interface:IQuery
Gets the current parameters of this connector.- Specified by:
getParameters
in interfaceIQuery
- Overrides:
getParameters
in classBaseConnector
- Returns:
- the current parameters of this connector or null if no parameters are used.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IQuery
Sets the parameters for opening and querying this connector.- Specified by:
setParameters
in interfaceIQuery
- Overrides:
setParameters
in classBaseConnector
- Parameters:
params
- the parameters to set.
-
setRootDirectory
public void setRootDirectory(String rootDir)
Description copied from interface:IQuery
Sets the root directory that may be used to replace the available ${rootDir} in the parameters of this object.- Specified by:
setRootDirectory
in interfaceIQuery
- Overrides:
setRootDirectory
in classBaseConnector
- Parameters:
rootDir
- the root directory.
-
-