Example #1
0
    def get_sourcestr_representation(self):
        """
                DCharacterHBO.get_sourcestr_representation

                Return a string.
        """

        #.......................................................................
        # unknown char ? Nothing to do :
        #.......................................................................
        if self.unknown_char:
            if self.dstring_object.options["anonymize the unknown characters"] == 'yes':
                return UNKNOWN_CHAR_SYMBOL
            else:
                return self.base_char

        #.......................................................................
        # ok, the function can analyse <self> :
        #.......................................................................
        res = []

        if self.base_char is not None:

            base_char = self.base_char

            if base_char == "כ" and self.contextual_form == "final":
                base_char = "ך"

            if base_char == "מ" and self.contextual_form == "final":
                base_char = "ם"

            if base_char == "נ" and self.contextual_form == "final":
                base_char = "ן"

            if base_char == "פ" and self.contextual_form == "final":
                base_char = "ף"

            if base_char == "צ" and self.contextual_form == "final":
                base_char = "ץ"

            res.append( base_char )

        if self.shin_sin_dot is not None:
            res.append( SYMB_POINTS.get_default_symbol(self.shin_sin_dot) )

        if self.daghesh_mapiq:
            res.append( DEFAULTSYMB__DAGHESHMAPIQ )

        if self.vowel is not None:
            res.append( SYMB_VOWELS.get_default_symbol(self.vowel) )

        if self.methegh:
            res.append( DEFAULTSYMB__METEG )

        if self.raphe:
            res.append( DEFAULTSYMB__RAFE )

        if self.specialpoint is not None:
            res.append( SYMB_SPECIALPOINTS.get_default_symbol(self.specialpoint) )

        if self.cantillation_mark is not None:
            for cmark in self.cantillation_mark:
                res.append( SYMB_CANTILLATION_MARKS.get_default_symbol(cmark) )

        res = "".join(res)

        # composition with COMPLETE_NORMALIZE_NFC
        # we don't use NFC which "shuffle" the elements in an order incompatible
        # with our code.
        for src, dest in COMPLETE_NORMALIZE_NFC:
            res = res.replace(src, dest)

        return res