def vocalized_similarity(word1, word2):
    """
    if the two words has the same letters and the same harakats,  this function return True.
    The two words can be full vocalized, or partial vocalized

    @param word1: first word
    @type word1: unicode
    @param word2: second word
    @type word2: unicode
    @return: return if words are similar, else return negative number of errors
    @rtype: Boolean / int
    """

    stack1 = stack.Stack(word1)
    stack2 = stack.Stack(word2)
    last1 = stack1.pop()
    last2 = stack2.pop()
    err_count = 0
    vowels = HARAKAT
    while last1 != None and last2 != None:
        if last1 == last2:
            last1 = stack1.pop()
            last2 = stack2.pop()
        elif last1 in vowels and last2 not in vowels:
            last1 = stack1.pop()
        elif last1 not in vowels and last2 in vowels:
            last2 = stack2.pop()
        else:
            # break
            if last1 == SHADDA:
                last1 = stack1.pop()
            elif last2 == SHADDA:
                last2 = stack2.pop()
            else:
                last1 = stack1.pop()
                last2 = stack2.pop()
                err_count += 1
    if err_count > 0:
        return -err_count
    else:
        return True
def vocalized_similarity ( word1 , word2 ) : stack1 = stack . Stack ( word1 ) stack2 = stack . Stack ( word2 ) last1 = stack1 . pop ( ) last2 = stack2 . pop ( ) err_count = 0 vowels = HARAKAT while last1 != None and last2 != None : if last1 == last2 : last1 = stack1 . pop ( ) last2 = stack2 . pop ( ) elif last1 in vowels and last2 not in vowels : last1 = stack1 . pop ( ) elif last1 not in vowels and last2 in vowels : last2 = stack2 . pop ( ) else : if last1 == SHADDA : last1 = stack1 . pop ( ) elif last2 == SHADDA : last2 = stack2 . pop ( ) else : last1 = stack1 . pop ( ) last2 = stack2 . pop ( ) err_count += 1 if err_count > 0 : return - err_count else : return True
if the two words has the same letters and the same harakats,  this function return True.
    The two words can be full vocalized, or partial vocalized

    @param word1: first word
    @type word1: unicode
    @param word2: second word
    @type word2: unicode
    @return: return if words are similar, else return negative number of errors
    @rtype: Boolean / int