Class MicrosoftMTConnector

    • Constructor Detail

      • MicrosoftMTConnector

        public MicrosoftMTConnector()
      • MicrosoftMTConnector

        public MicrosoftMTConnector​(org.apache.http.impl.client.CloseableHttpClient httpClient)
    • Method Detail

      • close

        public void close()
        Description copied from interface: IQuery
        Closes this connector.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface IQuery
      • getName

        public String getName()
        Description copied from interface: IQuery
        Gets the name of the connector.
        Specified by:
        getName in interface IQuery
        Returns:
        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 interface IQuery
        Returns:
        a display representation of the current settings.
      • open

        public void open()
        Description copied from interface: IQuery
        Opens this query engine.
        Specified by:
        open in interface IQuery
      • query

        public int query​(String plainText)
        Description copied from interface: IQuery
        Starts a query for a give plain text.
        Specified by:
        query in interface IQuery
        Parameters:
        plainText - text to query.
        Returns:
        The number of hits for the given query.
      • query

        public int query​(TextFragment frag)
        Description copied from interface: IQuery
        Starts a query for a given text.
        Specified by:
        query in interface IQuery
        Parameters:
        frag - The text to query.
        Returns:
        The number of hits for the given query.
      • leverage

        public void leverage​(ITextUnit tu)
        Description copied from interface: IQuery
        Leverages a text unit (segmented or not) based on the current settings. Any options or attributes needed must be set before calling this method.
        Specified by:
        leverage in interface IQuery
        Overrides:
        leverage in class BaseConnector
        Parameters:
        tu - the text unit to leverage.
      • batchLeverage

        public void batchLeverage​(List<ITextUnit> tuList)
        Description copied from class: BaseConnector
        Slow default implementation using leverage(TextUnit). Override in sub-class if you want a custom batchLeverage
        Specified by:
        batchLeverage in interface IQuery
        Overrides:
        batchLeverage in class BaseConnector
        Parameters:
        tuList - list of the text units to process.
      • batchQueryText

        public List<List<QueryResult>> batchQueryText​(List<String> plainTexts)
        Description copied from interface: IQuery
        Starts a batch query for a given list of plain texts.
        Note that batchQueryText does not use hasNext and next methods. Callers must use the returned list directly.
        Specified by:
        batchQueryText in interface IQuery
        Overrides:
        batchQueryText in class BaseConnector
        Parameters:
        plainTexts - list of the plain texts to translate.
        Returns:
        a list of lists of query result. Each list corresponds to a source text (in the same order)
      • batchQuery

        public List<List<QueryResult>> batchQuery​(List<TextFragment> fragments)
        Description copied from class: BaseConnector
        Slow default implementation using query!! Override to take advantage of servers batch API
        Specified by:
        batchQuery in interface IQuery
        Overrides:
        batchQuery in class BaseConnector
        Parameters:
        fragments - list of the text fragments to translate.
        Returns:
        a list of lists of query result. Each list corresponds to a source text (in the same order)
      • toInternalCode

        protected String toInternalCode​(LocaleId locale)
        Description copied from class: BaseConnector
        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.
        Overrides:
        toInternalCode in class BaseConnector
        Parameters:
        locale - the locale identifier to convert.
        Returns:
        the internal string code for language/locale code for this connector.
      • getParameters

        public Parameters getParameters()
        Description copied from interface: IQuery
        Gets the current parameters of this connector.
        Specified by:
        getParameters in interface IQuery
        Overrides:
        getParameters in class BaseConnector
        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 interface IQuery
        Overrides:
        setParameters in class BaseConnector
        Parameters:
        params - the parameters to set.
      • next

        public QueryResult next()
        Description copied from interface: IQuery
        Gets the next hit for the last query.
        Specified by:
        next in interface IQuery
        Specified by:
        next in interface Iterator<QueryResult>
        Overrides:
        next in class BaseConnector
        Returns:
        A QueryResult object that holds the source and target text of the hit, or null if there is no more hit.
      • getMaximumHits

        public int getMaximumHits()
        Description copied from interface: ITMQuery
        Gets the current maximum number of hits to retrieve.
        Specified by:
        getMaximumHits in interface ITMQuery
        Returns:
        the current maximum number of hits to retrieve.
      • setMaximumHits

        public void setMaximumHits​(int maximumHits)
        Description copied from interface: ITMQuery
        Sets the maximum number of hits to retrieve.
        Specified by:
        setMaximumHits in interface ITMQuery
        Parameters:
        maximumHits - The 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 interface ITMQuery
        Returns:
        The current threshold value to use for the query.
      • setThreshold

        public void setThreshold​(int threshold)
        Description copied from interface: ITMQuery
        Sets the threshold value to use for the query.
        Specified by:
        setThreshold in interface ITMQuery
        Parameters:
        threshold - The threshold value (between 0 and 100).
      • 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 interface IQuery
        Overrides:
        setLanguages in class BaseConnector
        Parameters:
        sourceLocale - Code of the source locale.
        targetLocale - Code of the target locale.