Exemplo n.º 1
0
class ProperNoun(object):
    """
     # PyUML: Do not remove this line! # XMI_ID:_hUBlqI34Ed-gg8GOK1TmhA
    """
    '''
    classdocs
    '''
    
    VoweledForm = '';
            
    
    UnvoweledForm = '';
    
    
    POS = NominalPOS();

    def __init__(self, unvoweled, voweled):
        '''
        Constructor
        '''
        self.VoweledForm = voweled;
        self.UnvoweledForm = unvoweled;
        
        self.POS = NominalPOS();
        self.POS.SubClass = NominalPOSConstants.SubClass.Proper_Noun;
        self.POS.Definiteness = NominalPOSConstants.Definiteness.Definite_by_Itself;
        self.POS.Number = CliticlessPOSConstants.Number.Singular;
    pass
    
    def ReturnAsUnderivedCliticless(self):
        underivedCliticless = UnderivedCliticless(self.UnvoweledForm, self.VoweledForm);
        underivedCliticless.POS = self.POS.Clone();
        
        return underivedCliticless;
    pass
Exemplo n.º 2
0
 def __init__(self, unvoweled, voweled):
     '''
     Constructor
     '''
     self.VoweledForm = voweled;
     self.UnvoweledForm = unvoweled;
     
     self.POS = NominalPOS();
     self.POS.SubClass = NominalPOSConstants.SubClass.Proper_Noun;
     self.POS.Definiteness = NominalPOSConstants.Definiteness.Definite_by_Itself;
     self.POS.Number = CliticlessPOSConstants.Number.Singular;
Exemplo n.º 3
0
    def __init__(self, unvoweled, voweled):
        '''
        Constructor
        '''
        self.VoweledForm = voweled
        self.UnvoweledForm = unvoweled

        self.POS = NominalPOS()
        self.POS.MainClass = POSConstants.MainClass.Noun
Exemplo n.º 4
0
 def __init__(self, id, voweledForm, canonicForm):
     '''
     Constructor
     '''
     self.ID = id;
     self.VoweledForm = voweledForm;
     self.CanonicForm = canonicForm;
     
     self.POS = NominalPOS();
     self.POS.MainClass = NominalPOSConstants.MainClass.Noun;
     
     pass
Exemplo n.º 5
0
    def CreateClitic(self, clticString, clticWithDiacritics, cliticState):
        pos = NominalPOS()
        pos.SubClass = self.PronounSubClass
        pos.Definiteness = NominalPOSConstants.Definiteness.Definite_by_Itself
        pos.Gender = self.CliticGender
        pos.Number = self.CliticNumber
        pos.Person = self.CliticPerson

        #جميع ما في قاعدة بيانات الأوزان هي ضمائر رفع وجميع ما في اللواصق اللاحقة هي ضمائر نصب
        pos.CaseAndMood = CliticlessPOSConstants.CaseAndMood.AccusativeOrSubjunctive

        particle = UnderivedCliticless(clticString, clticWithDiacritics)
        particle.POS = pos

        return particle
Exemplo n.º 6
0
    def GetInternalEnclitic(self):

        if(type(self) is list):
            x = 0;
        if(self.POS.MainClass & POSConstants.MainClass.Verb == 0):
            return [None, 0];
        if(self.POS.Number & CliticlessPOSConstants.Number.Singular != 0 and \
           self.POS.Person & VerbalPOSConstants.Person.Third_Person  != 0 ):
            
                #قد يكون ضمير مستتر وقد لا يكون
#                unvoweled = 'هو';
#                voweled = 'هُوَ';
            return [None, 0];
        

        unvoweled = '';
        voweled = '';
        
        isHidden = False;
        
        #المتحول التالي يستخدم لفصل الضمير المظاهر عن الكلمة
        #ولكن العملية تحتاج إلى معالجة أكثر تعقيداً
        #لذلك إلى أن تتم المعالجة بالشكل الأمثل
        #قمت بإسناد القيمة 0 لهذا المتحول في نهاية هذا التابع
        cutLength = 0;
        
#            "مسند إلى المتكلم أنا"
        if(self.POS.Number == VerbalPOSConstants.Number.Singular and \
            self.POS.Gender == VerbalPOSConstants.Gender.all_Cases and \
            self.POS.Person == VerbalPOSConstants.Person.First_Person):
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                unvoweled = 'ت';
                voweled = 'تُ';
            else:
                #ضمير مستتر
                isHidden = True;
                unvoweled = 'أنا';
                voweled = 'أَنَاْ';            
            
#            "مسند إلى المتكلمين (نحن)"
        if(self.POS.Number == VerbalPOSConstants.Number.Plural and \
            self.POS.Gender == VerbalPOSConstants.Gender.all_Cases and \
            self.POS.Person == VerbalPOSConstants.Person.First_Person):
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                #ضمير ظاهر
                unvoweled = 'نا';
                voweled = 'نَاْ';
                cutLength = 2;
            else:
                #ضمير مستتر
                isHidden = True;
                unvoweled = 'نحن';
                voweled = 'نحن';
        
#            "مسند إلى المخاطَب أنت"
        if(self.POS.Number == VerbalPOSConstants.Number.Singular and \
            self.POS.Gender == VerbalPOSConstants.Gender.Masculine and \
            self.POS.Person == VerbalPOSConstants.Person.Second_Person):
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                #ضمير ظاهر
                unvoweled = 'ت';
                voweled = 'تَ';
                cutLength = 1;
            else:
                #ضمير مستتر
                isHidden = True;
                unvoweled = 'أنت';
                voweled = 'أَنْتَ';

#            "مسند إلى المخاطبة (أنتِ)"
        if(self.POS.Number == VerbalPOSConstants.Number.Singular and \
            self.POS.Gender == VerbalPOSConstants.Gender.Feminine and \
            self.POS.Person == VerbalPOSConstants.Person.Second_Person):
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                #ضمير ظاهر
                unvoweled = 'ت';
                voweled = 'تِ';
                cutLength = 1;
            else:
                unvoweled = 'ي';
                voweled = 'ي';
                if(self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
                   self.POS.CaseAndMood == VerbalPOSConstants.CaseAndMood.NominativeOrIndicative):
                    cutLength = 2;                    
                else:                    
                    cutLength = 1;

            
#            "مسند إلى المخاطَبَين (أنتما)"
        if(self.POS.Number == VerbalPOSConstants.Number.Dual and \
            self.POS.Gender == VerbalPOSConstants.Gender.Masculine and \
            self.POS.Person == VerbalPOSConstants.Person.Second_Person):
            #ضمير ظاهر
            unvoweled = 'ا';
            voweled = 'اْ';
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                cutLength = 3;
            elif((self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.CaseAndMood == VerbalPOSConstants.CaseAndMood.NominativeOrIndicative) \
               or (self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted)):
                cutLength = 2;
            else:
                cutLength = 1;

#            "مسند إلى المخاطبين (أنتم)"
        if(self.POS.Number == VerbalPOSConstants.Number.Plural and \
            self.POS.Gender == VerbalPOSConstants.Gender.Masculine and \
            self.POS.Person == VerbalPOSConstants.Person.Second_Person):
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                #ضمير مستتر
                isHidden = True;
                unvoweled = 'أنتم';
                voweled = 'أَنْتُمْ';
                cutLength = 2;
            else:
                #ضمير ظاهر
                unvoweled = 'و';
                voweled = 'وْ';
                if(self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
                   self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted):                    
                    cutLength = 1;
                else:
                    cutLength = 2;
        
#            "مسند إلى المخاطَبات (أنتن)"
        if(self.POS.Number == VerbalPOSConstants.Number.Plural and \
            self.POS.Gender == VerbalPOSConstants.Gender.Feminine and \
            self.POS.Person == VerbalPOSConstants.Person.Second_Person):
            #ضمير ظاهر
            unvoweled = 'ن';
            voweled = 'نَ';
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                cutLength = 2;
            elif(self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted):
                cutLength = 3;                    
            else:                    
                cutLength = 1;
#                
##            "مسند إلى الغائب (هو)"
#        if(self.POS.Number == VerbalPOSConstants.Number.Singular and \
#            self.POS.Gender == VerbalPOSConstants.Gender.Masculine and \
#            self.POS.Person == VerbalPOSConstants.Person.Third_Person):
#            unvoweled = '';
#            voweled = '';
#
##            "مسند إلى الغائبة (هي)"
#        if(self.POS.Number == VerbalPOSConstants.Number.Singular and \
#            self.POS.Gender == VerbalPOSConstants.Gender.Feminine and \
#            self.POS.Person == VerbalPOSConstants.Person.Third_Person):
#            unvoweled = '';
#            voweled = '';

#            "مسند إلى الغائبَين (هما)"
        if(self.POS.Number == VerbalPOSConstants.Number.Dual and \
            self.POS.Gender == VerbalPOSConstants.Gender.Masculine and \
            self.POS.Person == VerbalPOSConstants.Person.Third_Person):
            #ضمير ظاهر
            unvoweled = 'ا';
            voweled = 'اْ';
            if((self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.CaseAndMood == VerbalPOSConstants.CaseAndMood.NominativeOrIndicative) \
               or (self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted)):
                cutLength = 2;
            else:
                cutLength = 1;

#            "مسند إلى الغائبتين (هما)"
        if(self.POS.Number == VerbalPOSConstants.Number.Dual and \
            self.POS.Gender == VerbalPOSConstants.Gender.Feminine and \
            self.POS.Person == VerbalPOSConstants.Person.Third_Person):
            #ضمير ظاهر
            unvoweled = 'ا';
            voweled = 'اْ';
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Perfective):
                cutLength = 2;
            elif((self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.CaseAndMood == VerbalPOSConstants.CaseAndMood.NominativeOrIndicative) \
               or (self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted)):
                cutLength = 2;
            else:
                cutLength = 1;
        
#            "مسند إلى الغائبين (هم)"
        if(self.POS.Number == VerbalPOSConstants.Number.Plural and \
            self.POS.Gender == VerbalPOSConstants.Gender.Masculine and \
            self.POS.Person == VerbalPOSConstants.Person.Third_Person):
            unvoweled = 'و';
            voweled = 'وْ';
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted):
                cutLength = 1;
            else:
                cutLength = 2;
                
#            "مسند إلى الغائبات (هن)"
        if(self.POS.Number == VerbalPOSConstants.Number.Singular and \
            self.POS.Gender == VerbalPOSConstants.Gender.Feminine and \
            self.POS.Person == VerbalPOSConstants.Person.Third_Person):
            unvoweled = 'ن';
            voweled = 'نَ';
            if(self.POS.Aspect == VerbalPOSConstants.Aspect.Imperfective and \
               self.POS.Asserted == VerbalPOSConstants.Asserted.Asserted):
                cutLength = 1;
            else:
                cutLength = 2;
        
        pos = NominalPOS();
        
        if(isHidden == False):
            pos.Substantivness = NominalPOSConstants.Substantivness.Substantive;
        else:
            pos.Substantivness = NominalPOSConstants.Substantivness.Hidden;
        pos.Number = self.POS.Number;
        pos.Gender = self.POS.Gender;    
        pos.CaseAndMood = CliticlessPOSConstants.CaseAndMood.NominativeOrIndicative;  
        pos.SubClass = NominalPOSConstants.SubClass.Nominative_Pronoun; 
        pos.Definiteness = NominalPOSConstants.Definiteness.Definite_by_Itself; 
                   
        
        particle  = Particle(unvoweled, voweled, ParticleConstants.State.Enclitic, pos);
        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
        #المتحول التالي يستخدم لفصل الضمير المظاهر عن الكلمة
        #ولكن العملية تحتاج إلى معالجة أكثر تعقيداً
        #لذلك إلى أن تتم المعالجة بالشكل الأمثل
        #قمت بإسناد القيمة 0 لهذا المتحول في نهاية هذا التابع
        cutLength = 0;
        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        return [particle, cutLength];
Exemplo n.º 7
0
class ClosedNoun(object):
    """
     # PyUML: Do not remove this line! # XMI_ID:_hUBlgI34Ed-gg8GOK1TmhA
    """
    '''
    Enclosed Nouns
    '''

    VoweledForm = ''

    UnvoweledForm = ''

    PrefixeClasses = ''

    SuffixeClasses = ''

    POS = NominalPOS()

    def __init__(self, unvoweled, voweled):
        '''
        Constructor
        '''
        self.VoweledForm = voweled
        self.UnvoweledForm = unvoweled

        self.POS = NominalPOS()
        self.POS.MainClass = POSConstants.MainClass.Noun

    pass



    def AssignFromAlKalilDB(self, prefixeClasses, suffixeClasses,\
        type, definiteness, gender, case, number):
        #سابقاً كان يتم تعبئته من الملف
        #toolwords.xml
        #ولاحقاً أصبح من
        #closednouns.xml

        self.PrefixeClasses = prefixeClasses
        self.SuffixeClasses = suffixeClasses

        if (type == 'اسم شرط'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Conditional_Noun
        elif (type == 'ظرف'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Adverb_of_Time
            self.POS.SubClass += NominalPOSConstants.SubClass.Adverb_of_Place
        elif (type == 'ظرف مكان'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Adverb_of_Place
        elif (type == 'ظرف زمان'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Adverb_of_Time
        elif (type == 'ضمير منفصل'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Nominative_Pronoun
        elif (type == 'ضمير نصب'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Accusative_or_Genitive_Pronoun
        elif (type == 'اسم إشارة'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Demonstrative_Noun
        elif (type == 'اسم موصول خاص'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Special_Relative_Noun
        elif (type == 'اسم موصول مشترك'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Common_Relative_Noun
        elif (type == 'كناية'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Allusive
        elif (type == 'اسم جامد'):
            self.POS.SubClass = NominalPOSConstants.SubClass.Indeclinable_Noun
        else:
            print('Warning: This type [' + type +
                  '] is not processed for this Enclosed Noun [' +
                  unvoweledform + ']!')

#        definiteness, gender, case, number
        if (definiteness == 'م'):
            self.POS.Definiteness = NominalPOSConstants.Definiteness.Definite_by_Itself
        elif (definiteness == 'ن'):
            self.POS.Definiteness = NominalPOSConstants.Definiteness.Indefinite
        elif (definiteness == 'ك'):
            self.POS.Definiteness = NominalPOSConstants.Definiteness.all_Cases
        else:
            raise Exception('This value for definiteness [' + definiteness +
                            '] is not known!')

        if (gender == 'ذ'):
            self.POS.Gender = CliticlessPOSConstants.Gender.Masculine
        elif (gender == 'ث'):
            self.POS.Gender = CliticlessPOSConstants.Gender.Feminine
        elif (gender == 'ك'):
            self.POS.Gender = CliticlessPOSConstants.Gender.all_Cases
        elif (gender == ''):
            self.POS.Gender = CliticlessPOSConstants.Gender.Unprocessed
        else:
            raise Exception('This value for gender [' + gender +
                            '] is not known!')

        if (case == 'ر'):
            self.POS.CaseAndMood = CliticlessPOSConstants.CaseAndMood.NominativeOrIndicative
        elif (case == 'ن'):
            self.POS.CaseAndMood = CliticlessPOSConstants.CaseAndMood.AccusativeOrSubjunctive
        elif (case == 'ج'):
            self.POS.CaseAndMood = CliticlessPOSConstants.CaseAndMood.GenitiveOrJussive
        elif (case == 'نج'):
            self.POS.CaseAndMood = CliticlessPOSConstants.CaseAndMood.GenitiveOrJussive + \
                CliticlessPOSConstants.CaseAndMood.AccusativeOrSubjunctive
        elif (case == 'ك'):
            self.POS.CaseAndMood = CliticlessPOSConstants.CaseAndMood.all_Cases
        elif (case == ''):
            self.POS.CaseAndMood = CliticlessPOSConstants.CaseAndMood.Unprocessed
        else:
            raise Exception('This value for case [' + case + '] is not known!')

        if (number == '1'):
            self.POS.Number = CliticlessPOSConstants.Number.Singular
        elif (number == '2'):
            self.POS.Number = CliticlessPOSConstants.Number.Dual
        elif (number == '3'):
            self.POS.Number = CliticlessPOSConstants.Number.Plural
        elif (number == 'ك'):
            self.POS.Number = CliticlessPOSConstants.Number.all_Cases
        elif (number == ''):
            self.POS.Number = CliticlessPOSConstants.Number.Unprocessed
        else:
            raise Exception('This value for number [' + number +
                            '] is not known!')