示例#1
0
    def test_shaddalike(self):

        # shaddalike(partial, fully)
        word1 = u"ردّ"
        word2 = u"ردَّ"
        word3 = u"رد"
        self.assertTrue(Araby.shaddalike(word1, word2))
        self.assertFalse(Araby.shaddalike(word1, word3))
示例#2
0
 def check_shadda(word_vocalised,
                  resulted_data,
                  fully_vocalized_input=False):
     """
     if the entred word is like the found word in dictionary,
     to treat some normalized cases,
     the analyzer return the vocalized like words.
     This function treat the Shadda case.
     @param word_vocalised: the input word.
     @type word_vocalised: unicode.
     @param resulted_data: the founded resulat from dictionary.
     @type resulted_data: list of dict.
     @param fully_vocalized_input: if the two words must resect the shadda and vocalized.
     @type fully_vocalized_input: Boolean, default is False.
     @return: list of dictionaries of analyzed words with tags.
     @rtype: list.
     """
     #~return filter(lambda item: araby.shaddalike(word_vocalised,
     #~item.__dict__.get('vocalized', '')), resulted_data)
     #~x for x in [1, 1, 2] if x == 1
     #~ return [
     #~ x for x in resulted_data
     #~ if araby.shaddalike(word_vocalised, x.__dict__.get('vocalized', '')) ]
     if fully_vocalized_input:
         return [
             x for x in resulted_data
             if araby.strip_harakat(word_vocalised) == araby.strip_harakat(
                 x.__dict__.get('vocalized', ''))
         ]
     else:
         return [
             x for x in resulted_data if araby.shaddalike(
                 word_vocalised, x.__dict__.get('vocalized', ''))
         ]
示例#3
0
	def check_shadda(self, word_vocalised,resulted_data):
		"""
		if the entred word is like the found word in dictionary, to treat some normalized cases, 
		the analyzer return the vocalized like words.
		This function treat the Shadda case.
		@param word_vocalised: the input word.
		@type word_vocalised: unicode.
		@param resulted_data: the founded resulat from dictionary.
		@type resulted_data: list of dict.
		@return: list of dictionaries of analyzed words with tags.
		@rtype: list.
		"""
		return [x for x in resulted_data if araby.shaddalike(word_vocalised, getattr(x, 'vocalized', ''))]
示例#4
0
文件: analex.py 项目: ATouhou/mishkal
    def check_shadda(self, word_vocalised, resulted_data):
        """
		if the entred word is like the found word in dictionary, to treat some normalized cases, 
		the analyzer return the vocalized like words.
		This function treat the Shadda case.
		@param word_vocalised: the input word.
		@type word_vocalised: unicode.
		@param resulted_data: the founded resulat from dictionary.
		@type resulted_data: list of dict.
		@return: list of dictionaries of analyzed words with tags.
		@rtype: list.
		"""
        return filter(lambda item: araby.shaddalike(word_vocalised, item.__dict__.get("vocalized", "")), resulted_data)
示例#5
0
	def check_shadda(self, word_vocalised,resulted_data):
		"""
		if the entred word is like the found word in dictionary, to treat some normalized cases, 
		the analyzer return the vocalized like words.
		This function treat the Shadda case.
		@param word_vocalised: the input word.
		@type word_vocalised: unicode.
		@param resulted_data: the founded resulat from dictionary.
		@type resulted_data: list of dict.
		@return: list of dictionaries of analyzed words with tags.
		@rtype: list.
		"""
		return filter(lambda item: araby.shaddalike(word_vocalised, item.__dict__.get('vocalized','')), resulted_data)
示例#6
0
def check_shadda(word_vocalised, resulted_data):
    """
    if the entred word is like the found word in dictionary, 
    to treat some normalized cases, 
    the analyzer return the vocalized like words.
    This function treat the Shadda case.
    @param word_vocalised: the input word.
    @type word_vocalised: unicode.
    @param resulted_data: the founded resulat from dictionary.
    @type resulted_data: list of dict.
    @return: list of dictionaries of analyzed words with tags.
    @rtype: list.
    """
    #~return filter(lambda item: araby.shaddalike(word_vocalised, 
    #~item.__dict__.get('vocalized', '')), resulted_data)
#~x for x in [1, 1, 2] if x == 1
    return [x for x in resulted_data if araby.shaddalike(word_vocalised, 
    x.__dict__.get('vocalized', ''))]
示例#7
0
    def check_shadda(self, word_vocalised, resulted_data):
        """
		if the entred word is like the found word in dictionary, to treat some normalized cases, 
		the analyzer return the vocalized like words.
		This function treat the Shadda case.
		@param word_vocalised: the input word.
		@type word_vocalised: unicode.
		@param resulted_data: the founded resulat from dictionary.
		@type resulted_data: list of dict.
		@return: list of dictionaries of analyzed words with tags.
		@rtype: list.
		"""
        # print word_vocalised.encode('utf8');
        filtred_data = filter(
            lambda item: araby.shaddalike(word_vocalised, item.__dict__.get("vocalized", "")), resulted_data
        )
        # filtred_data=[];
        # for item in  resulted_data:
        # # if item.__dict__.has_key('vocalized')  and araby.shaddalike(word_vocalised, item.__dict__['vocalized']):
        # if araby.shaddalike(word_vocalised, item.__dict__.get('vocalized','')):
        # #item['tags']+=':a';
        # filtred_data.append(item);
        return filtred_data
示例#8
0
 def test_shaddalike(self):
     """Test if shadda  like?"""
     word1 = u"ردّ"
     word2=u"ردَّ"
     self.assertTrue(ar.shaddalike(word1, word2))
示例#9
0
 def test_shaddalike(self):
     """Test if shadda  like?"""
     word1 = u"ردّ"
     word2=u"ردَّ"
     self.assertTrue(ar.shaddalike(word1, word2))