diff options
author | Martin Gruner <mg.pub@gmx.net> | 2006-07-07 20:27:39 +0000 |
---|---|---|
committer | Martin Gruner <mg.pub@gmx.net> | 2006-07-07 20:27:39 +0000 |
commit | 1edc5c95a91b5efd433d36d16b8f7eb730cc6a4f (patch) | |
tree | 9f1a81aff577c16fc7333d52af545e4de1cbe0a8 /modules/hebrew-wlc/WLC2OSIS | |
parent | 2d399010f514bb257d650362c12e2494ac154700 (diff) | |
download | sword-tools-1edc5c95a91b5efd433d36d16b8f7eb730cc6a4f.tar.gz |
some more work, more needed
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@69 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/hebrew-wlc/WLC2OSIS')
12 files changed, 46 insertions, 129 deletions
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java index 1786351..d1d694e 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java @@ -2,7 +2,6 @@ package WLC2OSIS.Parse ; import WLC2OSIS.* ; import WLC2OSIS.Translate.* ; -//import WLC2OSIS.Utilities.* ; //============================================================================== /** * <b>Processes books.</b> @@ -44,12 +43,12 @@ public void start(String BookCode){ P.ChapterNumber = 0 ; P.VerseNumber = 0 ; P.WordNumber = 0 ; -// A.w.openTag("tanach", 0) ; - A.w.openTag("div type=\"book\" osisID=\"" + BookObject.abbrev + "\"", 1) ; +// A.wlc.openTag("tanach", 0) ; + A.wlc.openTag("div type=\"book\" osisID=\"" + BookObject.abbrev + "\"", 1) ; -/* A.w.writeAttributedString("title", 2, "type=\"section\" subType=\"x-Section\" subtype=\"x-preverse\"", +/* A.wlc.writeAttributedString("title", 2, "type=\"section\" subType=\"x-Section\" subtype=\"x-preverse\"", BookObject.hebrewname); - A.w.writeAttributedString("title", 2, "type=\"main\" ", BookObject.hebrewname);*/ + A.wlc.writeAttributedString("title", 2, "type=\"main\" ", BookObject.hebrewname);*/ } @@ -63,7 +62,7 @@ public void end(){ P.BookChapterCount = P.ChapterNumber ; P.TanachChapterCount = P.TanachChapterCount + P.ChapterNumber ; - A.w.closeTag("div", 1) ; + A.wlc.closeTag("div", 1) ; System.out.println( BookObject.name + " has been written." ) ; } } diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java index 8d4bf1c..214337b 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java @@ -26,7 +26,7 @@ public void start(){ P.VerseNumber = 0 ; P.WordNumber = 0 ; String num = new Integer(P.ChapterNumber).toString(); - A.w.openTag("chapter osisID=\"" + P.BookAbbrev + "." + num + "\"", 2) ; + A.wlc.openTag("chapter osisID=\"" + P.BookAbbrev + "." + num + "\"", 2) ; } //------------------------------------------------------------------------------ @@ -38,7 +38,7 @@ public void end(){ P.BookVerseCount = P.BookVerseCount + P.VerseNumber ; P.TanachVerseCount = P.TanachVerseCount + P.VerseNumber ; - A.w.closeTag("chapter", 2) ; + A.wlc.closeTag("chapter", 2) ; } } diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java index ddf0279..78ba491 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java @@ -29,8 +29,8 @@ public Markers(WLC2OSIS A, Parser P ) { // Samek public void samek(){ //parasah setumah, closed paragraph == small space in line testMaqafWord() ; -// A.w.writeMarker("samekh", 4) ; - A.w.appendText(" " + H.samekh + " ") ; +// A.wlc.writeMarker("samekh", 4) ; + A.wlc.appendText(" " + H.samekh + " ") ; P.MarkerWritten = true ; } //------------------------------------------------------------------------------ @@ -38,8 +38,8 @@ public void samek(){ //parasah setumah, closed paragraph == small space in line // Pe public void pe(){ // parasah petuhah, open paragraph == new line testMaqafWord() ; -// A.w.writeMarker("pe", 4) ; - A.w.appendText(" " + H.pe + " " + "<p/>") ; +// A.wlc.writeMarker("pe", 4) ; + A.wlc.appendText(" " + H.pe + " " + "<p/>") ; P.MarkerWritten = true ; } //------------------------------------------------------------------------------ diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java index bd06e43..70c89cf 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java @@ -15,7 +15,6 @@ import WLC2OSIS.Utilities.* ; public class Parser{ WLC2OSIS A ; -Tokenizer t ; // Working classes @@ -64,10 +63,7 @@ public Parser(WLC2OSIS A) { this.A = A ; T = new Translate(A, this) ; - -// Set up the tokenizer - t = new Tokenizer(A) ; - + // Set up the Tanach, Books, Chapters, Verses, Words, and Markers classes. b = new Books(A, this) ; c = new Chapters(A, this) ; @@ -89,16 +85,14 @@ public void parse(){ boolean PreviousEOL = true ; System.out.println("\n") ; - // Write the header - Header.writeHeader(A, A.wlc) ; - Header.writeHeader(A, A.morph) ; - try{ file = new BufferedReader( new FileReader( A.InputFilename )); } catch (IOException e) { System.out.println("File not found: " + e) ; } + + java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(\\w\\w)(\\d+):(\\d+),(\\d+)\\.(\\d+)\\S*\\s(\\S+)\\s(\\S+)(?:@|%)(\\S+)"); while ( true ){ s=""; @@ -110,14 +104,11 @@ public void parse(){ break; } -// System.out.println("processing: " + s); - if ( s.startsWith(">") ){ //ignore this line continue; } - java.util.regex.Pattern p = java.util.regex.Pattern.compile("(\\w\\w)(\\d+):(\\d+),(\\d+)\\.(\\d+)\\S*\\s(\\S+)\\s(\\S+)(?:@|%)(\\S+)"); - java.util.regex.Matcher m = p.matcher( s ); + java.util.regex.Matcher m = pattern.matcher( s ); if (!m.matches()){ System.out.println("No match!"); System.exit(1); @@ -190,12 +181,7 @@ public void parse(){ v.end() ; c.end() ; b.end() ; - - // Write the footer - Header.writeFooter(A, A.w) ; - - A.w.close(); return ; } //---------------------------------------------------------------------------- @@ -215,11 +201,11 @@ public int countChar(String W, char c){ // Prints a verse identification. -public void printPosition(){ +/*public void printPosition(){ System.out.print(" at " + Book + " " + A.F.i(ChapterNumber,3) + ":" + A.F.i(VerseNumber,2) + "." + A.F.i(WordNumber,2) + "\n") ; - } + }*/ //------------------------------------------------------------------------------ } //============================================================================== diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java index 0f64d16..09815f1 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java @@ -26,7 +26,7 @@ public void start(){ String chapternum = new Integer(P.ChapterNumber).toString(); String versenum = new Integer(P.VerseNumber).toString(); - A.w.openTag("verse osisID=\""+P.BookAbbrev+"."+chapternum+"."+versenum+"\"", 3) ; + A.wlc.openTag("verse osisID=\""+P.BookAbbrev+"."+chapternum+"."+versenum+"\"", 3) ; } //------------------------------------------------------------------------------ @@ -34,7 +34,7 @@ public void start(){ public void end(){ if( P.VerseNumber != 0){ - A.w.closeTag("verse", 3) ; + A.wlc.closeTag("verse", 3) ; } } //---------------------------------------------------------------------------- diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java index 4a7945e..720e75d 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java @@ -27,30 +27,15 @@ public Words(WLC2OSIS A, Parser P ) { //------------------------------------------------------------------------------ // Processes a word, - public void process(String W){ - -//---------------------------------------------------------------------------------- - -// Process WKQ P.wkq.process(W) ; - -//---------------------------------------------------------------------------------- - - -// System.out.println(P.Book + " " + A.F.i(P.ChapterNumber,2) + ":" -// + A.F.i(P.VerseNumber,2) -// + "." + A.F.i(P.WordNumber,2) + " " + W) ; } -//---------------------------------------------------------------------------------- -// Translates and writes a word (simple, ketib, qere) with exception markers. +// Translates and writes a word (simple, ketib, qere) with exception markers. // All returns leave P.MarkerWritten = false ; - public void write(String W, String Type) { - String Word = P.T.translate(W) ; // Check for any KQ markers which should NOT be here! @@ -59,7 +44,7 @@ public void write(String W, String Type) { if (asteriskcount > 0){ System.out.print("Words.write: Unexpected KQ character * ") ; - P.printPosition() ; +// P.printPosition() ; System.out.println("Word: " + W) ; } @@ -114,17 +99,17 @@ public void writeWord(String Word, String Type) { } if (Type.charAt(0) == 'w') { - A.w.appendText(A.MorphologicalSegmentStart + Out + A.MorphologicalSegmentEnd + " ") ; + A.wlc.appendText(A.MorphologicalSegmentStart + Out + A.MorphologicalSegmentEnd + " ") ; } else if (Type.charAt(0) == 'k') { - A.w.appendText("[" + A.MorphologicalSegmentStart + Out + A.MorphologicalSegmentEnd + " " + H.kaf + "] ") ; + A.wlc.appendText("[" + A.MorphologicalSegmentStart + Out + A.MorphologicalSegmentEnd + " " + H.kaf + "] ") ; } else if (Type.charAt(0) == 'q') { - A.w.appendText("("+A.MorphologicalSegmentStart + Out + A.MorphologicalSegmentEnd + " " + H.qof+ ") ") ; + A.wlc.appendText("("+A.MorphologicalSegmentStart + Out + A.MorphologicalSegmentEnd + " " + H.qof+ ") ") ; } else { System.out.println("Warning: unknown word type!"); - P.printPosition(); +// P.printPosition(); } P.MarkerWritten = false ; } diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java index a42f948..cc8c218 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java @@ -2,7 +2,6 @@ package WLC2OSIS.Translate ; import WLC2OSIS.* ; import WLC2OSIS.Translate.* ; -import Utilities.* ; import java.io.*; //============================================================================== diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java index aa9fc4d..410354e 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java @@ -1,7 +1,6 @@ package WLC2OSIS.Translate ; import WLC2OSIS.Utilities.* ; -import Utilities.* ; import java.io.*; //============================================================================== diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java index ba29c51..0e5a4c1 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java @@ -4,7 +4,6 @@ import WLC2OSIS.* ; import WLC2OSIS.Parse.* ; import WLC2OSIS.Translate.Note ; import WLC2OSIS.Utilities.* ; -import Utilities.* ; import java.io.* ; import java.util.Vector ; @@ -193,50 +192,25 @@ public String translate(String W){ setFinal(LastConsonant) ; } } -// System.out.println("ObjectCount: " + MCOs.size() ) ; -// System.out.println("ConsonantCount: " + ConsonantCount) ; -// System.out.println("LastConsonant: " + LastConsonant) ; - -// for (int k = 0; k < ConsonantCount; k++){ -// System.out.println("ConsonantPositions[" + k + "]: " + ConsonantPositions[k]) ; -// } -//----------------------------------------------------------------------------- if (ConsonantCount > 0){ - -// Set the final consonant, if any. - setFinal(LastConsonant) ; - -// print(MCOs) ; - -//----------------------------------------------------------------------------- - -// Order the MCOs - - OrderedMCOs = new Vector() ; - int Limit = 0 ; - for( int ConsonantNumber = 0; ConsonantNumber < ConsonantCount; ConsonantNumber++) { - if (ConsonantNumber+1 == ConsonantCount){ - Limit = MCOs.size() ; - } - else{ - Limit = ConsonantPositions[ConsonantNumber+1] ; - } - Order(MCOs, ConsonantPositions[ConsonantNumber], Limit, OrderedMCOs ) ; - - } - + OrderedMCOs = new Vector() ; + int Limit = 0 ; + for( int ConsonantNumber = 0; ConsonantNumber < ConsonantCount; ConsonantNumber++) { + if (ConsonantNumber+1 == ConsonantCount){ + Limit = MCOs.size() ; + } + else{ + Limit = ConsonantPositions[ConsonantNumber+1] ; + } + Order(MCOs, ConsonantPositions[ConsonantNumber], Limit, OrderedMCOs ) ; + } } else{ OrderedMCOs = MCOs ; } - -// print(OrderedMCOs) ; - -//----------------------------------------------------------------------------- - // Output the ordered Vector String S = "" ; @@ -247,17 +221,16 @@ public String translate(String W){ if (Type == MCO.Note){ S = S + "<note type=\"textual\" xml:lang=\"en\">"+ Note.Notes.get( M.Value)+ "</note>"; } - //Mark morph segments when a maqef is present - else if ( (M.Name).compareTo("maqef") == 0 ){ - S = S + A.MorphologicalSegmentEnd + M.Value + A.MorphologicalSegmentStart; - } + //Mark morph segments when a maqef is present + else if ( (M.Name).compareTo("maqef") == 0 ){ + S = S + A.MorphologicalSegmentEnd + M.Value + A.MorphologicalSegmentStart; + } else if ((Type == MCO.MorphologicalDivision)){ S = S + A.MorphologicalDivisionMarker ; } else{ S = S + M.Value ; -// System.out.println(Integer.toString( (int) M.Value.charAt(0), 16)) ; } } @@ -326,7 +299,7 @@ void Order( Vector MCOs, int StartIndex, int Limit, Vector OrderedMCOs) { public void message(String m){ System.out.print(m) ; - P.printPosition() ; +// P.printPosition() ; } //----------------------------------------------------------------------------- diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java index ffeb0c2..48d5ad4 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java @@ -1,7 +1,5 @@ package WLC2OSIS.Utilities ; -import Utilities.* ; - import java.lang.System ; import java.io.* ; //============================================================================== @@ -17,8 +15,6 @@ String IndentString = " " ; FileOutputStream FOS ; OutputStreamWriter OSW ; char[] CharBuffer ; -Fmt F = new Fmt() ; -// String XMLTag ; //----------------------------------------------------------------------------- /** * Writes an XML file. diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java index 8b03f60..612d728 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java @@ -2,13 +2,9 @@ package WLC2OSIS ; import WLC2OSIS.Parse.* ; import WLC2OSIS.Translate.* ; -import WLC2OSIS.Utilities.* ; -import Utilities.* ; +import WLC2OSIS.Utilities.XMLWriter ; -import java.awt.*; import java.io.*; -import java.awt.event.*; -import javax.swing.*; import java.util.*; //================================================================================================= /** @@ -70,29 +66,23 @@ public String MorphologicalDivisionMarker = MorphologicalSegmentEnd + Morphologi //----------------------------------------------------------------------------- -//public final int InputBufferSize = 40000000 ; // Length of input in bytes. -public char[] InputChars ; // Input char[] array set by FileRead. public Parser p ; public XMLWriter wlc; public XMLWriter morph; -public Fmt F = new Fmt() ; -// public boolean StandAlone = true ; // If used by another app, - public WLC2OSIS( String file, String directory ){ InputFilename = file ; OutputDirectory = directory ; - F.bar("=", 80) ; System.out.println("\nWLC2OSIS: " + Title + " " + ShortDescription ) ; System.out.println("\nInput file: " + InputFilename ) ; System.out.println("\nOutput directory: " + OutputDirectory ) ; // Read, parse, and write the book files. - wlc = new XMLWriter(A.OutputDirectory, "wlc_osis") ; - morph = new XMLWriter(A.OutputDirectory, "morph_osis") ; + wlc = new XMLWriter(OutputDirectory, "wlc_osis") ; + morph = new XMLWriter(OutputDirectory, "morph_osis") ; wlc.openTag("osisText osisIDWork=\"WLC\" osisRefWork=\"bible\" xml:lang=\"he\"", 0) ; @@ -112,14 +102,11 @@ public WLC2OSIS( String file, String directory ){ wlc.closeTag("work", 1); wlc.closeTag("header", 0); - - - - p = new Parser(this) ; p.parse() ; wlc.closeTag("osisText", 0); + wlc.close(); done() ; } @@ -130,7 +117,6 @@ public WLC2OSIS( String file, String directory ){ */ public void done(){ System.out.println("\nWLC2OSIS: Normal end.") ; - F.bar("=", 80) ; System.exit(0) ; } } diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java index ece113f..ece32c7 100644 --- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java @@ -1,17 +1,11 @@ package WLC2OSIS ; -import Utilities.* ; - -import java.awt.*; -import javax.swing.*; - - public class WLC2OSISMain{ static WLC2OSIS A ; /** - * Static main() method for use as an application or dialog. + * Static main() method * * @param args String[] */ |