How to edit non-Bible modules (.twm)

Share your favorite tips, workarounds and shortcuts for theWord
jaredaseltzer
Posts: 41
Joined: Sat Sep 14, 2013 3:55 pm

Re: How to edit non-Bible modules (.twm)

Post by jaredaseltzer »

I'm putting together an Aramaic Peshitta Lexicon (dct.twm) for TheWord based on an eSword module.

But I'm not a fan of the Latin transliterated scheme that the esword module uses, so I'm converting the transliterated mumbo-jumbo into unicode Hebrew block script for the entries, or perhaps I'll assign numbers to the entries like Strongs ( such as <A1234> for Aramaic as opposed to <G1234> for Greek or <H1234> for Hebrew). I have all the data in excel worksheets and I'm ready to make a *.dct.twn file.

As preparation for doing so, I've been looking at other dct modules in SQLite Expert Pro, trying to reverse engineer them. But I am still very confused about one thing: Some dct modules--in the "main.topics_wordindex" table--have a "priority" field/column. What is it used for, what does it do, or what does it mean or indicate?
csterg
Site Admin
Posts: 8627
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

Ignore the topics_wordindex table for now. This is maintained automatically, you should normally NOT populate this by yourself.
This is useful to populate yourse only if you want to make your dictionary do lookups with more words than those in the topics. Is that the case for you?

Costas
jaredaseltzer
Posts: 41
Joined: Sat Sep 14, 2013 3:55 pm

Re: How to edit non-Bible modules (.twm)

Post by jaredaseltzer »

Thank you Costas. I've taken your advice and have a basic Aramaic Lexicon module which satisfactorily accompanies the Peshitta NT in Hebrew + Vowels that I put together last week.

But try as I did, I could not figure out how to include Hebrew script included within the content of my dictionary. I had each entry formatted thus:

\par אבאש \par \par Vocalized: אַבֶאש \par \par Transliteration: 'a-VeSh \par \par Root: באש \par \par \par Definition: offended, be offended; ill-treat.

then I loaded it into main.content with SQLite Expert Pro and opened it in TheWord, but the three Hebrew words showed up garbled and unintelligible. What should I do to successfully put Hebrew script into main.content so it displays within TheWord correctly? I am good with VBA and managing and formatting data within Excel, and I'd like to find a way to automate the process with these rather than going entry by entry. Instead of putting text into main.content, do I have to enter it into the database as a "blob"? I'm not familiar with "blobs".

Thank you
Attachments
PeshittaModScreenShot.PNG
PeshittaModScreenShot.PNG (74.55 KiB) Viewed 4217 times
csterg
Site Admin
Posts: 8627
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

The content in the table should be in rtf format. In rtf you cannot have non-ascii characters. The Hebrew characters are such, and so need to be encoded accordingly. To encode a unicode character in rtf you use the notation \uN, where N is the decimal unicode code of the character (see the rtf spec here: http://www.biblioscape.com/rtf15_spec.htm#Heading9).

Of course, you can write a small VBA function to convert unicode text to such format, here is one in pascal:

Code: Select all

function UnicodeToRTF(const ws: WideString): String;
const
  HEX: array[0..15] of char = ('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
var
  i, j, c, len: Integer;
  si: String;
begin
  len := Length(ws);
  SetLength(result, len);
  c := 1;
  for i:=1 to Length(ws) do begin
    if c + 10 > len then begin
      Inc(len, 10000);
      SetLength(result, len);
    end;

    if ws[i] < #128 then begin
      result[c] := Char(ws[i]);
      Inc(c);
    end
    else begin
      result[c] := '\';
      result[c+1] := 'u';
      Inc(c,2);
      si := IntToStr(Ord(ws[i]));
      for j:=1 to Length(si) do
        result[c+j-1] := si[j];
      Inc(c, Length(si)+1);
      result[c-1] := '?'; // \uc1 is the default...
    end;
  end;
  SetLength(result, c-1);
end;

HTH
Costas
jaredaseltzer
Posts: 41
Joined: Sat Sep 14, 2013 3:55 pm

Re: How to edit non-Bible modules (.twm)

Post by jaredaseltzer »

Nice! This is what I've been looking for! Thank you Costas!
RubioTerra
Posts: 732
Joined: Wed Sep 23, 2009 5:13 pm
Location: Brasília, Brazil

Re: How to edit non-Bible modules (.twm)

Post by RubioTerra »

Here's the conversion in Perl:

Code: Select all

sub UTF8AsRTF {
	my $text = shift;
	$text =~ s/([^[:ascii:]])/sprintf("\\u%d?",ord($1))/eg;
	$text;
}
Rúbio R. C. Terra
Brasília/DF - Brasil
jaredaseltzer
Posts: 41
Joined: Sat Sep 14, 2013 3:55 pm

Re: How to edit non-Bible modules (.twm)

Post by jaredaseltzer »

I use VB and VBA so I used this code:

Code: Select all

Function UnicodeToRTF(Hebrew As String) As String
    Dim i As Integer
    Dim cc As Integer
    Dim L As Integer
    Dim u As String
    
    L = Len(Hebrew)
    u = ""
 
    For i = 1 To L
        cc = AscW(Mid(Hebrew, i, 1))
        u = u & "\u" & CStr(cc)
    Next i
    UnicodeToRTF = u
End Function
It worked like a champ! Now I just need to change the fontsize and color of the Hebrew. I guess I use \pnf and \pncf ?
jaredaseltzer
Posts: 41
Joined: Sat Sep 14, 2013 3:55 pm

Re: How to edit non-Bible modules (.twm)

Post by jaredaseltzer »

Help, please. This is the format of each of my dictionary entries:

\cf1\fs28\b \u1488\u1463\u1489\u1464\u1488\b0 \cf0\fs24 \i (`a-Vo`) \i0
\par \b father; fruit. \b0
\par
\par Root: \u1488\u1489

The blue represents the Hebrew script. How can I make the first hebrew word dark red? I cannot figure it out.
csterg
Site Admin
Posts: 8627
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

The best way to do this is to add \f1 for Greek and \f2 for Hebrew (and \fs22 for Greek and Hebrew). This way, tw will fix the colors itself.
Post Reply