Example #1
0
    def predict(self,
                context_line,
                limit=20,
                case_insensitive=False,
                case_insensitive_smart=False,
                accent_insensitive=False,
                accent_insensitive_smart=False,
                ignore_capitalized=False,
                ignore_non_capitalized=False):
        """ Find completion/prediction choices. """
        LanguageModel = pypredict.LanguageModel
        options = 0
        if case_insensitive:
            options |= LanguageModel.CASE_INSENSITIVE
        if case_insensitive_smart:
            options |= LanguageModel.CASE_INSENSITIVE_SMART
        if accent_insensitive:
            options |= LanguageModel.ACCENT_INSENSITIVE
        if accent_insensitive_smart:
            options |= LanguageModel.ACCENT_INSENSITIVE_SMART
        if ignore_capitalized:
            options |= LanguageModel.IGNORE_CAPITALIZED
        if ignore_non_capitalized:
            options |= LanguageModel.IGNORE_NON_CAPITALIZED

        context, spans = pypredict.tokenize_context(context_line)
        choices = self._get_prediction(self.models, context, limit, options)
        _logger.debug("context=" + repr(context))
        _logger.debug("choices=" + repr(choices[:5]))
        return [x[0] for x in choices]
Example #2
0
 def tokenize_context(self, text):
     """ let the service find the words in text """
     tokens = []
     if 1:
         # avoid the D-Bus round-trip while we can
         tokens = pypredict.tokenize_context(text)
     else:
         tokens = self._call_method("tokenize_context", [], text)
     return tokens
Example #3
0
 def tokenize_context(self, text):
     """ let the service find the words in text """
     tokens = []
     if 1:
         # avoid the D-Bus round-trip while we can
         tokens = pypredict.tokenize_context(text)
     else:
         tokens = self._call_method("tokenize_context", [],
                                    text)
     return tokens
Example #4
0
    def predict(self, context_line, limit = 20,
                case_insensitive = False,
                accent_insensitive = False,
                ignore_capitalized = False,
                ignore_non_capitalized = False):
        """ Find completion/prediction choices. """
        LanguageModel = pypredict.LanguageModel
        options = 0
        if case_insensitive:
            options |= LanguageModel.CASE_INSENSITIVE
        if accent_insensitive:
            options |= LanguageModel.ACCENT_INSENSITIVE
        if ignore_capitalized:
            options |= LanguageModel.IGNORE_CAPITALIZED
        if ignore_non_capitalized:
            options |= LanguageModel.IGNORE_NON_CAPITALIZED

        context = pypredict.tokenize_context(context_line)
        choices = self._get_prediction(self.models, context, limit, options)
        _logger.debug("context=" + repr(context))
        _logger.debug("choices=" + repr(choices[:5]))
        return [x[0] for x in choices]
Example #5
0
 def tokenize_context(self, text):
     """ let the service find the words in text """
     return pypredict.tokenize_context(text)
Example #6
0
 def tokenize_context(self, text):
     """ let the service find the words in text """
     tokens = pypredict.tokenize_context(text)
     return tokens