コード例 #1
0
ファイル: daw_tools.py プロジェクト: RaaH/dawawin
def rawi_poem(text):
    if is_machtor(text):
        list_poem, n = my_split(text, 1)
    else:
        list_poem, n = my_split(text, 0)
    if len(list_poem) == 1:
        txt = daw_araby.stripTashkeel(text)
        if txt[-1] == u'ا':
            if txt[-2] == u'و':
                return txt[-3]
            else:
                return txt[-2]
        if text[-2:] == u'هْ':
            return txt[-2]
        elif text[-1] in [u'ي', u'و', u'ه']:
            return txt[-2]
        elif txt[-1] == u'ة':
            return u'ت'
        elif txt[-1] == u'ى':
            return u'ا'
        else:
            return txt[-1]
    elif len(list_poem) > 1:
        n = 0
        ls = []
        for a in list_poem:
            if n == 2: break
            if a[1] == 'half':
                ls.append(a[0])
                n += 1
            elif a[1] == 'title':
                continue
            else:
                ls.append(a[1])
                n += 1 
        txt1 = daw_araby.stripTashkeel(ls[0])
        txt2 = daw_araby.stripTashkeel(ls[1])
        h11 = txt1[-1]
        h12 = txt1[-2]
        h13 = txt1[-3]
        h21 = txt2[-1]
        h22 = txt2[-2]
        h23 = txt2[-3]
        if h11 == u'ا' and h12 == u'ه':
            if h13 == h23: return h13
            else: return h12
        if h11 in [u'ا', u'ى', u'ه', u'ة', u'و', u'ي']:
            if h12 == h22 or h12 == h21: return h12
            else: return h11
        else: return h11
コード例 #2
0
ファイル: daw_stemming.py プロジェクト: RaaH/dawawin
def get_stem(text):
    'return list by all bearable stems'
    if len(text) < 3: return
    stems = []
    if daw_araby.stripTashkeel(text) == u'الله': 
        stems.append(u'الله')
        return stems
    text = daw_araby.stripHarakat(text)
    without_prefix = _del_prefix(text)
    for a in without_prefix:
        without_suffix = _del_suffix(a)
        for b in without_suffix:
            if len(b) <= 9:
                stems.append(b)
    return stems
コード例 #3
0
ファイル: daw_customs.py プロジェクト: RaaH/dawawin
def tashkil(text):
    if daw_config.getv('tashkil') == '0': return daw_araby.stripTashkeel(text)
    else: return text