Пример #1
0
def try_handler(self, word):
    """
    Tries to use a :class:`quepy.handlers.Handler` on word
    and returns the semantic associated or None otherwise.
    """

    from quepy import handlers

    handler = handlers.get_handler(word)

    if handler:
        return handler(word)
Пример #2
0
def try_handler(self, word):
    """
    Tries to use a :class:`quepy.handlers.Handler` on word
    and returns the semantic associated or None otherwise.
    """

    from quepy import handlers

    handler = handlers.get_handler(word)

    if handler:
        return handler(word)
Пример #3
0
def handle_nounlike(word):
    """
    Handles things that might be a noun or a special
    thing like a Handler.

    Returns an :class:`quepy.expression.Expression`.
    """

    from quepy import handlers
    from quepy.semantics import HasKeyword

    handler = handlers.get_handler(word)

    if handler:
        return handler(word)
    elif word.pos in (u"NN", u"NP", u"NNP", u"NNS"):
        return HasKeyword(word.lemma)
    else:
        raise UnhandledWord(u"Couldn't handle word {0!r}".format(word))
Пример #4
0
def handle_nounlike(word):
    """
    Handles things that might be a noun or a special
    thing like a Handler.

    Returns an :class:`quepy.expression.Expression`.
    """

    from quepy import handlers
    from quepy.semantics import HasKeyword

    handler = handlers.get_handler(word)

    if handler:
        return handler(word)
    elif word.pos in (u"NN", u"NP", u"NNP", u"NNS"):
        return HasKeyword(word.lemma)
    else:
        raise UnhandledWord(u"Couldn't handle word {0!r}".format(word))