[sword-svn] r71 - trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse

mgruner at crosswire.org mgruner at crosswire.org
Mon Jul 10 09:56:58 MST 2006


Author: mgruner
Date: 2006-07-10 09:56:50 -0700 (Mon, 10 Jul 2006)
New Revision: 71

Removed:
   trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java
   trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java
   trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java
Modified:
   trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java
Log:


Deleted: trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java
===================================================================
--- trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java	2006-07-09 11:23:32 UTC (rev 70)
+++ trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java	2006-07-10 16:56:50 UTC (rev 71)
@@ -1,72 +0,0 @@
-package WLC2OSIS.Parse ;
-
-import WLC2OSIS.* ;
-import WLC2OSIS.Translate.* ;
-//==============================================================================
-/**
- *  <b>Processes books.</b>
- *
- *  Special to WLC.
- */
-//==============================================================================
-public class Books{
-
-WLC2OSIS A ;
-Parser P ;
-public BookName[] BookNames ;
-BookName BookObject ;
-//-----------------------------------------------------------------------------
-
-public Books(WLC2OSIS A, Parser P ) {
-    this.A = A ;
-    this.P = P ;
-    BookNames = BookName.setBookNames() ;
-    }    
-//------------------------------------------------------------------------------
-
-// Starts a book.  Enter with WLC BookCode
-
-public void start(String BookCode){
-
-    BookObject = BookName.getBookName(BookNames, BookCode) ;
-    P.Book = BookObject.name ;
-    P.BookAbbrev = BookObject.abbrev ;
-    P.TanachBookCount = P.TanachBookCount + 1 ;
-    P.BookVerseCount = 0;
-    P.BookChapterCount = 0 ;
-
-//-----------------------------------------------------------------------------
-
-// Begin writing the book into the existing file
-
-    
-    P.ChapterNumber = 0 ;
-    P.VerseNumber = 0 ;
-    P.WordNumber = 0 ;
-//     A.wlc.openTag("tanach", 0) ;
-    A.writer.openTag("div type=\"book\" osisID=\"" + BookObject.abbrev + "\"", 1) ;
-
-/*    A.writer.writeAttributedString("title", 2, "type=\"section\" subType=\"x-Section\" subtype=\"x-preverse\"",
-      BookObject.hebrewname);
-    A.writer.writeAttributedString("title", 2, "type=\"main\" ",    	BookObject.hebrewname);*/
-      
-    
-    }
-//------------------------------------------------------------------------------
-
-// Ends a book.
-
-public void end(){
-    if (P.Book != null){
-    
-        P.BookChapterCount = P.ChapterNumber ;
-        P.TanachChapterCount = P.TanachChapterCount + P.ChapterNumber ;
-        
-        A.writer.closeTag("div", 1) ;
-        System.out.println( BookObject.name + " has been written." ) ;
-        }
-    }
-//----------------------------------------------------------------------------
-}
-//==============================================================================
-//==============================================================================

Deleted: trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java
===================================================================
--- trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java	2006-07-09 11:23:32 UTC (rev 70)
+++ trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java	2006-07-10 16:56:50 UTC (rev 71)
@@ -1,48 +0,0 @@
-package WLC2OSIS.Parse ;
-
-import WLC2OSIS.* ;
-//==============================================================================
-/**
- *  <b>Processes chapters.</b>
- */
-//==============================================================================
-public class Chapters{
-
-WLC2OSIS A ;
-Parser P ;
-//-----------------------------------------------------------------------------
-
-public Chapters(WLC2OSIS A, Parser P ) {
-    this.A = A ;
-    this.P = P ;
-    }    
-//------------------------------------------------------------------------------
-
-// Starts a book.
-
-public void start(){
-    P.ChapterVerseCount = 0 ;
-    P.ChapterNumber = P.ChapterNumber + 1 ;
-    P.VerseNumber = 0 ;
-    P.WordNumber = 0 ;
-    String num = new Integer(P.ChapterNumber).toString();
-    A.writer.openTag("chapter osisID=\"" + P.BookAbbrev + "." + num + "\"", 2) ;
-    }
-//------------------------------------------------------------------------------
-
-// Ends a book.
-
-public void end(){
-    if (P.ChapterNumber != 0){
-        P.ChapterVerseCount = P.VerseNumber ;
-        P.BookVerseCount = P.BookVerseCount + P.VerseNumber ;
-        P.TanachVerseCount = P.TanachVerseCount + P.VerseNumber ;
-    
-    	A.writer.closeTag("chapter", 2) ;
-	
-        }
-    }
-//----------------------------------------------------------------------------
-}
-//==============================================================================
-//==============================================================================

Modified: trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java
===================================================================
--- trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java	2006-07-09 11:23:32 UTC (rev 70)
+++ trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java	2006-07-10 16:56:50 UTC (rev 71)
@@ -17,9 +17,6 @@
 
 //  Working classes
 
-public Books b ;
-Chapters c ;
-Verses v ;
 public Words w ;
 Translate T ;
 Markers m ;
@@ -30,43 +27,22 @@
 public boolean MarkerWritten ;  // Indicates a marker has been written
                                 // between two words.
 
-// String BookName ;
-
-String Book ;
-String BookAbbrev ;
-int Chapter ;
-int Verse ;
-
-String LastBookCode = "" ;
-int LastChapter = -1 ;
-int LastVerse = -1 ;
-
-
 // Assorted counts
 public int ChapterVerseCount ;
 public int BookVerseCount ;
 public int BookChapterCount ;
 
-public int TanachVerseCount ;
-public int TanachChapterCount ;
-public int TanachBookCount ;
-
-int ChapterNumber ;
-int VerseNumber ;
 int WordNumber ;
 
 BufferedReader file;
 
+
 //-----------------------------------------------------------------------------
 public Parser(WLC2OSIS A, boolean wlc_only) {
     this.A = A ;
 
     T = new Translate(A, this) ;
   
-// Set up the Tanach, Books, Chapters, Verses, Words, and Markers classes.
-    b = new Books(A, this) ;
-    c = new Chapters(A, this) ;
-    v = new Verses(A, this) ;
     w = new Words(A, this) ;
     m = new Markers(A, this) ;
     wkq = new WKQ(this) ;
@@ -81,7 +57,7 @@
 
 public void parse(){
     String s ;
-    System.out.println("\n") ;
+    System.out.println("\n");
     
    	try{
 	    file = new BufferedReader( new FileReader( A.InputFilename ));
@@ -89,7 +65,16 @@
 	catch (IOException e) {
 		System.out.println("File not found: " + e) ;
     }
+	
+	BookName[] bookNames = BookName.setBookNames();
+	
+	String oldBookCode = "";
+	int oldChapter = 0;
+	int oldVerse = 0;
+	int oldWordNumber = 0;
+	int oldSubWordNumber = 0;
 
+
     java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(\\w\\w)(\\d+):(\\d+),(\\d+)\\.(\\d+)(\\]\\S)?\\s(\\S+)\\s(\\S+)(?:@|%)(\\S+)");
      
     while ( true ){
@@ -115,56 +100,36 @@
         	continue;
         }
 
-		java.util.regex.Matcher m = pattern.matcher( s );
-		if (!m.matches()){
+		java.util.regex.Matcher match = pattern.matcher( s );
+		if (!match.matches()){
 			System.out.println("No match found: " +s);
 			System.exit(1);
 		}
 		
 // Parse the identifier
-		String BookCode = m.group(1);
-		int Chapter = Integer.parseInt( m.group(2) );
-		int Verse   = Integer.parseInt( m.group(3) );
-		int wordNumber	= Integer.parseInt( m.group(4) );
-		int subWordNumber = Integer.parseInt( m.group(5) );
-		String note = m.group(6);
-		String expression = m.group(7);
-		String lemma	= m.group(8);
-		String grammar  = m.group(9);
-            
-      //  System.out.println(BookCode + " " + Chapter + " " + Verse + " " + wordNumber + " " + subWordNumber + " " +expression+" "+lemma+" "+grammar+ " Note: "+note);
-/*
-// Change in Book, start a book.
-            if(BookCode.compareTo(LastBookCode) != 0){
-                v.end() ;
-                c.end() ;
-                b.end() ;
-                b.start(BookCode) ;
-                c.start() ;
-                v.start() ;
-                LastBookCode = BookCode ;
-                LastChapter = 1 ;
-                LastVerse = 1 ;
-                }
-                
-// Change in Chapter, start a Chapter.
-            if(Chapter != LastChapter){
-                v.end() ;
-                c.end() ;
-                c.start() ;
-                v.start() ;
-                LastChapter = Chapter ;
-                LastVerse = 1 ;
-                }
-                
-// Change in Verse, start a Verse.
-            if(Verse != LastVerse){
-                v.end() ;
-                v.start() ;
-                LastVerse = Verse ;
-                }*/
-//-----------------------------------------------------------------------------
-
+		String newBookCode = match.group(1);
+		int newChapter = Integer.parseInt( match.group(2) );
+		int newVerse   = Integer.parseInt( match.group(3) );
+		int newWordNumber	= Integer.parseInt( match.group(4) );
+		int newSubWordNumber = Integer.parseInt( match.group(5) );
+		String note = match.group(6);
+		String expression = match.group(7);
+		String lemma	= match.group(8);
+		String grammar  = match.group(9);
+		
+		if ((newBookCode != oldBookCode) || (newChapter != oldChapter) || (newVerse != oldVerse))
+		{
+			if (oldVerse >= 1) A.writer.closeTag("verse", 2);
+		    A.writer.openTag(
+		    		"verse osisID=\""+
+		    		BookName.getBookName(bookNames, newBookCode).abbrev+"."+
+		    		newChapter+"."+
+		    		newVerse+"\"", 2);
+		    oldBookCode = newBookCode;
+		    oldChapter = newChapter;
+		    oldVerse = newVerse;
+		}
+  
 //   Process a word.
               
 /*                if (s.length() > 1){
@@ -186,10 +151,9 @@
                         }
                      }*/
 	        }
-    v.end() ;
-    c.end() ;
-    b.end() ;   
     
+    A.writer.closeTag("verse", 2);
+    
     return ;
     }
 //----------------------------------------------------------------------------

Deleted: trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java
===================================================================
--- trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java	2006-07-09 11:23:32 UTC (rev 70)
+++ trunk/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java	2006-07-10 16:56:50 UTC (rev 71)
@@ -1,43 +0,0 @@
-package WLC2OSIS.Parse ;
-
-import WLC2OSIS.* ;
-//==============================================================================
-/**
- *  <b>Processes verses.</b>
- */
-//==============================================================================
-public class Verses{
-
-WLC2OSIS A ;
-Parser P ;
-//-----------------------------------------------------------------------------
-
-public Verses(WLC2OSIS A, Parser P ) {
-    this.A = A ;
-    this.P = P ;
-    }    
-//------------------------------------------------------------------------------
-
-// Starts a book.
-
-public void start(){
-    P.VerseNumber = P.VerseNumber + 1 ;
-    P.WordNumber = 0 ;
-    
-    String chapternum = new Integer(P.ChapterNumber).toString();
-    String versenum =   new Integer(P.VerseNumber).toString();
-    A.writer.openTag("verse osisID=\""+P.BookAbbrev+"."+chapternum+"."+versenum+"\"", 3) ;
-    }
-//------------------------------------------------------------------------------
-
-// Ends a book.
-
-public void end(){
-    if( P.VerseNumber != 0){
-    	A.writer.closeTag("verse", 3) ;
-        }
-    }
-//----------------------------------------------------------------------------
-}
-//==============================================================================
-//==============================================================================



More information about the sword-cvs mailing list