avi-perl/Hebrew

Hebrew.no_taamim fails with "AttributeError: 'str' object has no attribute 'string'"

Opened this issue · 4 comments

Trying this:

hebrew_text = "\u05d1\u05b8\u05bc\u05a3\u05d8\u05b7\u05d7 \u05d1\u05b8\u05bc\u05ad\u05d4\u05bc \u05dc\u05b5\u05a3\u05d1 \u05d1\u05b7\u05bc\u05e2\u05b0\u05dc\u05b8\u0591\u05d4\u05bc \u05d5\u05b0\u059d\u05e9\u05b8\u05c1\u05dc\u05b8\u0597\u05dc \u05dc\u05b9\u05a3\u05d0 \u05d9\u05b6\u05d7\u05b0\u05e1\u05b8\u05bd\u05e8\u05c3"
print (hebrew_text)
hebrew_text2 = Hebrew.no_taamim(hebrew_text, False, False)
print (hebrew_text2)

Error is this:


בָּ֣טַח בָּ֭הּ לֵ֣ב בַּעְלָ֑הּ וְ֝שָׁלָ֗ל לֹ֣א יֶחְסָֽר׃
Traceback (most recent call last):
  File "C:\GitHub\GetBible\CommonTransliterate.py", line 74, in <module>
    hebrew_text2 = Hebrew.no_taamim(hebrew_text, False, False)
  File "C:\GitHub\GetBible\hebrew\hebrew_obj.py", line 169, in no_taamim
    string = self.no_maqaf().string if remove_maqaf else self.string
AttributeError: 'str' object has no attribute 'string'

Same with:
hebrew_text2 = Hebrew.no_taamim(hebrew_text)
hebrew_text2 = Hebrew.no_taamim(hebrew_text, True, True)

Are you planning on adding a transliteration function? I'm working on that now.

Thanks,
Neal

Ok, my mistake. I didn't build an object from your class. That seems kind of heavy. Not sure why I can't just call a function.
The following works. But please let me know if you are adding a transliteration function.

hebrew_text = "\u05d1\u05b8\u05bc\u05a3\u05d8\u05b7\u05d7 \u05d1\u05b8\u05bc\u05ad\u05d4\u05bc \u05dc\u05b5\u05a3\u05d1 \u05d1\u05b7\u05bc\u05e2\u05b0\u05dc\u05b8\u0591\u05d4\u05bc \u05d5\u05b0\u059d\u05e9\u05b8\u05c1\u05dc\u05b8\u0597\u05dc \u05dc\u05b9\u05a3\u05d0 \u05d9\u05b6\u05d7\u05b0\u05e1\u05b8\u05bd\u05e8\u05c3"
print (hebrew_text)
hebrew_obj = Hebrew(hebrew_text)
hebrew_text2 = Hebrew.no_taamim(hebrew_obj, False, False)
print (hebrew_text2)

I can also make my own function like this:

def remove_taamim(arg_hebrew_text):
    hebrew_obj = Hebrew(arg_hebrew_text)
    return Hebrew.no_taamim(hebrew_obj, False, False)

Then just do:

hebrew_text2 = remove_taamim(hebrew_text)

Hi there,

I have looked at adding transliteration and recently got my hands on some source material that could help, but I haven't made much progress. I'm definitely interested in adding it.

If you would have any interest in contributing to that effort, that would be amazing and I would certainly welcome it. I'd also be happy to do any additional work that's necessary to add the feature so that you could focus on that, such as adding full unit testing to your functionality.

In general, the functionality as currently written in the class is not necessarily the most efficient. If you are working with very large amounts of text, you might be best off recreating some of the functions yourself.

As far as the correct way to use the class, try this:

Hebrew(my_hebrew_str).no_taamim()

I wrote a crude transliteration that met my needs. Do you want to talk more about it here, or somewhere else?
I was testing with Eshet Chayil (Proverbs 31) text that I got from a library called GetBible.
I had to reverse the order of some of the Nikudim to get it to work, for example the dot on the Shin had to come before the vowel or the other dagesh.
It cannot tell when a kamatz is an 'oh' vs 'ah'., and likewise cannot determine vocal vs non-vocal shva's.
Neal