# Path: support/yaraspell/spelltools.py
# def edits1(word):
#    splits     = [(word[:i], word[i:]) for i in range(len(word) + 1)]
#    deletes    = [a + b[1:] for a, b in splits if b]
#    transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1]
#    replaces   = [a + c + b[1:] for a, b in splits for c in alphabet if b]
#    inserts    = [a + c + b     for a, b in splits for c in alphabet]
#    return set(deletes + transposes + replaces + inserts)


import re
import operator
import os
import sys
import string
import tashaphyne.stemming 
import pyarabic.araby as araby
from .spelltools import edits1
from . import stem_const 
from . import spelltools
from . import spelldb
        @type  word: unicode
        @return: True if word exists else False
        @rtype: Boolean
        """
        if not word: 
            return True
        if word.isdigit():
            return True
        for c in word:
            if c in string.punctuation:
                return True
        # test if the word is previouslly spelled
        # can get True or False
        if word in self.worddict:
            test = self.worddict.get(word, False)
        else:
            # if the word is not spelled
            word = araby.strip_tatweel(word)
            self.stemmer.segment(word)        
            # extract the affix 
            stem = self.stemmer.get_stem()
            affix = u"-".join([self.stemmer.get_prefix(), self.stemmer.get_suffix()])
            # lookup in the database
            test = self.database.lookup(word, stem, affix)
            self.worddict[word] = test
        return test
        

    def known_edits2(self, word):


# Path: support/yaraspell/spelltools.py
# def edits1(word):
#    splits     = [(word[:i], word[i:]) for i in range(len(word) + 1)]
#    deletes    = [a + b[1:] for a, b in splits if b]
#    transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1]
#    replaces   = [a + c + b[1:] for a, b in splits for c in alphabet if b]
#    inserts    = [a + c + b     for a, b in splits for c in alphabet]
#    return set(deletes + transposes + replaces + inserts)


# Path: support/yaraspell/spelldict.py
import re
import operator
import os
import sys
import string
import tashaphyne.stemming 
import pyarabic.araby as araby
from .spelltools import edits1
from . import stem_const 
from . import spelltools
from . import spelldb

        @type  word: unicode
        @return: True if word exists else False
        @rtype: Boolean
        """
        if not word: 
            return True
        if word.isdigit():
            return True
        for c in word:
            if c in string.punctuation:
                return True
        # test if the word is previouslly spelled
        # can get True or False
        if word in self.worddict:
            test = self.worddict.get(word, False)
        else:
            # if the word is not spelled
            word = araby.strip_tatweel(word)
            self.stemmer.segment(word)        
            # extract the affix 
            stem = self.stemmer.get_stem()
            affix = u"-".join([self.stemmer.get_prefix(), self.stemmer.get_suffix()])
            # lookup in the database
            test = self.database.lookup(word, stem, affix)
            self.worddict[word] = test
        return test
        

    def known_edits2(self, word):


        return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if self.lookup(e2))