Esempio n. 1
0
    def __convert_regex(self, p, tag, environ=None):
        u"""
        Converts the values of ``tag`` to ``Regex``s. Accepts a list of string 
        or just a string.
        """
        synonyms = environ['synonyms']
        meanings = environ['meanings']
        if p.has_key(tag):
            tagValues = p[tag]
            if tagValues is None or tagValues == u'':
                raise exceptions.InvalidTagValue(
                                    u'Invalid value for tag %s.'%tag)

            if isinstance(tagValues, (tuple, list)):
                values = tagValues
            else:
                values = [tagValues]

            normalized = [normalize_input(unicode(x), synonyms) for x in values]
            patterns = []
            for x in normalized:
                patterns.extend(get_meanings(x, meanings, self._mean))

            return [Regex(x, self._ignore) for x in patterns]
        else:
            return None
Esempio n. 2
0
    def __convert_regex(self, p, tag, environ=None):
        u"""
        Converts the values of ``tag`` to ``Regex``s. Accepts a list of string 
        or just a string.
        """
        synonyms = environ['synonyms']
        meanings = environ['meanings']
        if p.has_key(tag):
            tagValues = p[tag]
            if tagValues is None or tagValues == u'':
                raise exceptions.InvalidTagValue(u'Invalid value for tag %s.' %
                                                 tag)

            if isinstance(tagValues, (tuple, list)):
                values = tagValues
            else:
                values = [tagValues]

            normalized = [
                normalize_input(unicode(x), synonyms) for x in values
            ]
            patterns = []
            for x in normalized:
                patterns.extend(get_meanings(x, meanings, self._mean))

            return [Regex(x, self._ignore) for x in patterns]
        else:
            return None
Esempio n. 3
0
    def __convert_literal(self, p, tag, environ=None):
        u"""
        Converts the values of ``tag`` to ``Literal``s. Accepts a list of 
        string or just a string.
        """
        meanings = environ['meanings']
        if p.has_key(tag):
            tagValues = p[tag]
            if tagValues is None or tagValues == u'':
                raise exceptions.InvalidTagValue(
                                    'Invalid value for tag %s.'%tag)

            if isinstance(tagValues, (tuple, list)):
                values = tagValues
            else:
                values = [tagValues]

            patterns = []
            for x in values:
                patterns.extend(get_meanings(x, meanings, self._mean))

            return [Literal(unicode(x)) for x in patterns]
        else:
            return None
Esempio n. 4
0
    def __convert_literal(self, p, tag, environ=None):
        u"""
        Converts the values of ``tag`` to ``Literal``s. Accepts a list of 
        string or just a string.
        """
        meanings = environ['meanings']
        if p.has_key(tag):
            tagValues = p[tag]
            if tagValues is None or tagValues == u'':
                raise exceptions.InvalidTagValue('Invalid value for tag %s.' %
                                                 tag)

            if isinstance(tagValues, (tuple, list)):
                values = tagValues
            else:
                values = [tagValues]

            patterns = []
            for x in values:
                patterns.extend(get_meanings(x, meanings, self._mean))

            return [Literal(unicode(x)) for x in patterns]
        else:
            return None