summaryrefslogtreecommitdiffstats
path: root/modules/hebrew-wlc
diff options
context:
space:
mode:
authorMartin Gruner <mg.pub@gmx.net>2006-07-07 16:50:30 +0000
committerMartin Gruner <mg.pub@gmx.net>2006-07-07 16:50:30 +0000
commit2d399010f514bb257d650362c12e2494ac154700 (patch)
tree2c54aa79a0e11d36166bb5aed06e702e0c19bc83 /modules/hebrew-wlc
parentc4c0a9afca605ea50e0158b01f26d6eeeb4b675e (diff)
downloadsword-tools-2d399010f514bb257d650362c12e2494ac154700.tar.gz
update; unusable atm
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@68 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/hebrew-wlc')
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java165
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java355
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java34
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java176
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java87
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java11
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java69
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java106
-rw-r--r--modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java40
9 files changed, 88 insertions, 955 deletions
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java
deleted file mode 100644
index ed8d1a7..0000000
--- a/modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package Utilities;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import java.io.File ;
-//==============================================================================
-/**
-*
-* <b>Positionable version of JFileChooser.</b><p>
-*
-* (The JFileChooser position isn't set or read by setLocation(...)
-* or getLocation.)<p>
-*
-*
-*<pre>
-*Dear Mr. Kimball,
-*
-*This is a known bug:
-*
-* http://developer.java.sun.com/developer/bugParade/bugs/4390885.html
-*
-*We are working on a solution for a later release. In the meantime, the
-*only workaround I can think of is to subclass JFileChooser and override
-*the method showDialog(), adding a call to setLocation().
-*
-*See example code below.
-*
-*Regards,
-*
-*Leif Samuelsson
-*
-*Sun Microsystems, Inc.
-*Java Swing Team
-*</pre>
-*/
-//==============================================================================
-
-public class FileChooser extends JFileChooser {
- private JDialog dialog;
-
- private int returnValue = ERROR_OPTION;
- private Point Location = new Point(250, 250) ;
- private Dimension Size = new Dimension( 600, 250) ;
-
-//------------------------------------------------------------------------------
-/**
-*
-* Constructor is the same as the no-argument version of JFileChooser.<p>
-*
-* Use setCurrentDirectory to set the initial directory.
-*
-*/
- public FileChooser(){
- super() ;
- }
-//------------------------------------------------------------------------------\/**
-
-/** Replaces showDialog of JFileChooser */
-
- public int showDialog(Component parent, String approveButtonText) {
- if (approveButtonText != null) {
- setApproveButtonText(approveButtonText);
- setDialogType(CUSTOM_DIALOG);
- }
-
- Frame frame = parent instanceof Frame ? (Frame) parent
- : (Frame)SwingUtilities.getAncestorOfClass(Frame.class, parent);
- String title = getUI().getDialogTitle(this);
-
- dialog = new JDialog(frame, title, true);
- dialog.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- returnValue = CANCEL_OPTION;
- }
- });
- dialog.getContentPane().add(this, BorderLayout.CENTER);
- dialog.pack();
- dialog.setLocation(Location) ;
- dialog.setSize(Size) ;
-
- rescanCurrentDirectory();
- returnValue = ERROR_OPTION;
-
- dialog.show();
- Location = dialog.getLocation() ;
- Size = dialog.getSize() ;
- return returnValue;
- }
-//------------------------------------------------------------------------------\/**
-
-/** Replaces approveSelection of JFileChooser */
- public void approveSelection() {
- returnValue = APPROVE_OPTION;
- if (dialog != null) {
- dialog.setVisible(false);
- }
- super.approveSelection();
- }
-//------------------------------------------------------------------------------\/**
-
-/** Replaces cancelSelection of JFileChooser */
- public void cancelSelection() {
- returnValue = CANCEL_OPTION;
- if (dialog != null) {
- dialog.setVisible(false);
- }
- super.cancelSelection();
- }
-//------------------------------------------------------------------------------\/**
-
-/** Sets the location of the FileChooser */
-
-public void setLocation(Point P) {
- this.Location = P ;
- }
-//------------------------------------------------------------------------------\/**
-
-/** Sets the size of the FileChooser */
-
-public void setSize(Dimension D) {
- this.Size = D ;
- }
-//------------------------------------------------------------------------------\/**
-
-/** Returns the location of the FileChooser */
-
-public Point getLocation() {
- return Location ;
- }
-//------------------------------------------------------------------------------\/**
-
-/** Returns the size of the FileChooser */
-
-public Dimension getSize() {
- return Size ;
- }
-//------------------------------------------------------------------------------\/**
-
-/** Test program provided by Leif Samuelsson */
-
- public static void main(String[] s) throws Exception {
- JFrame frame = new JFrame("FileChooser test");
- frame.setVisible(true);
- JFileChooser chooser = new FileChooser();
- chooser.setLocation(new Point(200,200)) ;
- int returnVal = chooser.showOpenDialog(frame);
- System.out.println("Position: " + chooser.getLocation()) ;
- switch (returnVal) {
- case APPROVE_OPTION:
- System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
- break;
-
- case CANCEL_OPTION:
- System.out.println("Cancelled");
- break;
-
- case ERROR_OPTION:
- System.out.println("An error occurred");
- break;
- }
- System.exit(0);
- }
-}
-//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java
deleted file mode 100644
index de6ae93..0000000
--- a/modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java
+++ /dev/null
@@ -1,355 +0,0 @@
-package Utilities ;
-
-import java.text.* ;
-import java.text.Format.* ;
-import java.io.* ;
-import java.awt.*;
-//==============================================================================
-/**
-*
-* <b>Formating tools.</b><p>
-*
-* <pre>
-* F = new Fmt() ;
-* System.out.println(F.i(2,10)) ; // 10 digit integer field.
-* System.out.println(F.f(3.1415,10, 2)) ; // 10 digit F10.2 field.
-* System.out.println(F.fill("-", 10)) ; // 10 digits of "-".
-* System.out.println(F.prepad(F.fill("-",10), 12) ;
-* // 2 digits of blank before fill.
-* </pre>
-*
-*/
-//==============================================================================
-
-public class Fmt{
-
-NumberFormat NF = NumberFormat.getInstance() ; // Provides commas in integers
-
-//-----------------------------------------------------------------------------
-/**
-* Simple constructor: Fmt F = new Fmt() ;
-*
-*/
-public Fmt(){
-}
-//-----------------------------------------------------------------------------
-/**
-*
-* Yields a string of specified FieldWidth and DecimalDigits containing
-* the given double.<p>
-*
-* @param f double to be converted.
-* @param FieldWidth Maximum number of characters to be produced. If more
-* characters are produced, the field is filled with *.
-* @param DecimalDigits int number of points after the decimal point.
-* @return String String of exactly FieldWidth characters.
-*
-*/
-public String f( double f, int FieldWidth, int DecimalDigits) {
- if(DecimalDigits>FieldWidth-2){
- String s = fill("!", FieldWidth) ;
- return s ;
- }
- String FormatString = "0." ;
- for (int k = 0; k < DecimalDigits; k++){
- FormatString = FormatString + "0" ;
- }
- while (FormatString.length() < FieldWidth){
- FormatString = "#" + FormatString ;
- }
-
- DecimalFormat DF = new DecimalFormat(FormatString) ;
- String s = DF.format(f) ;
- if (s.length()< FieldWidth){
- s = prepad(s, FieldWidth) ;
- }
- else if(s.length()>FieldWidth){
- s = fill("*", FieldWidth) ;
- }
- return s ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Yields a string of specified FieldWidth containing the given integer.<p>
-*
-* @param i integer to be converted.
-* @param FieldWidth Maximum number of characters to be produced. If more
-* characters are produced, the field is filled with *.
-* @return String String of exactly FieldWidth characters.
-*
-*/
-public String i( int i, int FieldWidth) {
- String s = NF.format(i) ;
- if (s.length()< FieldWidth){
- s = prepad(s, FieldWidth) ;
- }
- else if(s.length()>FieldWidth){
- s = "";
- for(int k = 0; k<FieldWidth; k++){
- s = s + "*" ;
- }
- }
- return s ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Yields a string containing the given integer.<p>
-*
-* @param i integer to be converted.
-* @return String String representing i.
-*
-*/
-public String i( int i) {
- return NF.format(i) ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Yields a string of Width specified characters.<p>
-*
-* @param c String (usually a single character) to be repeated.
-* @param Width int number of times to repeat S.
-* @return String of Width characters.
-*
-*/
-public String fill( String c, int Width){
- String s = "" ;
- for(int i = 0; i < Width; i++){
- s = s + c ;
- }
- return s;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Prints a string of Width specified characters to a specified PrintStream.<p>
-*
-* @param P PrintStream such as System.out.
-* @param c String (usually a single character) to be repeated.
-* @param Width int number of times to repeat S.
-*
-*/
-public void bar(PrintStream P, String c, int Width){
- String s = "" ;
- for(int i = 0; i < Width; i++){
- s = s + c ;
- }
- P.println(s) ;
- return ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Prints a string of Width specified characters to System.out.<p>
-*
-* @param c String (usually a single character) to be repeated.
-* @param Width int number of times to repeat S.
-* @return String String of Width characters.
-*
-*/
-public void bar(String c, int Width){
- bar(System.out, c, Width) ;
- return ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Removes blanks anywhere in String.<p>
-*
-* @param c String to be deblanked.
-* @return String String without any blanks.
-*
-*/
-public String deblank(String c){
- String s = "" ;
- for (int i = 0; i < c.length(); i++){
- if(c.charAt(i) != ' '){
- s = s + c.charAt(i) ;
- }
- }
- return s ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Pads the front of a String, giving a String of a specified length.<p>
-*
-* @param s String to be prepaded.
-* @param n Desired length of output string.
-* @return String Prepadded String.
-*
-*/
-public String prepad(String s, int n){
- int len = s.length() ;
- if (len == n){ // String is already long enough.
- return s ;
- }
- else if(len > n){
- return fill("!", n) ;
- }
-// Prepad
- String OutString = "" ;
- int Pads = n - len ;
- for (int i = 0; i < Pads; i++){
- OutString = OutString + " " ;
- }
-// Original String
- OutString = OutString + s ;
- return OutString ;
- }
-//-----------------------------------------------------------------------------
-/**
-*
-* Pads the end of a String, giving a String of a specified length.<p>
-*
-* @param s String to be postpaded.
-* @param n Desired length of output string.
-* @return String Prepadded String.
-*
-*/
-public String postpad(String s, int n){
- int len = s.length() ;
- if (len == n){ // String is already long enough.
- return s ;
- }
- else if(len > n){
- return fill("!", n) ;
- }
-// Original String
-// Postpad
- String OutString = "" ;
- for (int i = 0; i < len; i++){
- OutString = OutString + s.charAt(i) ;
- }
-// Postpad
- while (OutString.length() <= n){
- OutString = OutString + " " ;
- }
- return OutString ;
- }
-//-----------------------------------------------------------------------------
-/**
-* Gives a convenient maximum size for a text area
-* specified in rows, columns.<p>
-*
-* @param font Font of text.
-* @param rows int giving number of rows of text.
-* @param columns int giving number of columns of text.
-* @return D Dimension of best size.
-*/
-public Dimension areaSize( Font font, int rows, int columns ){
- double XFactor = 0.70 ;
-// double YFactor = 1.42;
- double YFactor = 1.65;
-
- Integer X = new Integer( font.getSize() ) ;
- double x = XFactor*X.doubleValue()*columns ;
- Integer Y = new Integer( font.getSize() ) ;
- double y = YFactor*Y.doubleValue()*rows ;
- Dimension D = new Dimension( (new Double(x)).intValue(),
- (new Double(y)).intValue() ) ;
- return D ;
- }
-//-----------------------------------------------------------------------------
-/**
-* Gives a convenient maximum size for a text area
-* specified as a dimension.<p>
-*
-* @param font Font of text.
-* @param d Dimnsion object giving number of rows and columns of text.
-* @return D Dimension of best size.
-*/
-public Dimension areaSize( Font font, Dimension d){
- double XFactor = 0.70 ;
- double YFactor = 1.42;
-
- Integer X = new Integer( font.getSize() ) ;
- double x = XFactor*X.doubleValue()*d.getWidth() ;
- Integer Y = new Integer( font.getSize() ) ;
- double y = YFactor*Y.doubleValue()*d.getHeight() ;
- Dimension D = new Dimension( (new Double(x)).intValue(),
- (new Double(y)).intValue() ) ;
- return D ;
- }
-//-----------------------------------------------------------------------------
-/**
-* Removes the extension, including the ".", from a file name String.<p>
-*
-* If the Name doesn't contain a ".", the original Name is returned.
-*
-* @param Name String containing file name.
-* @return String with extension and "." removed.
-*/
-public static String removeExtension( String Name){
-
- boolean HasDot = false ;
- for (int k = 0; k < Name.length() ; k++){
- if(Name.charAt(k) == '.'){
- HasDot = true ;
- }
- }
- if(!HasDot) return Name ;
-
- String NewName = "" ;
- for (int k = Name.length()-1; k >= 0; k--){
- if( Name.charAt(k) == '.'){
- for (int j = 0; j < k ; j ++) {
- NewName = NewName + Name.charAt(j) ;
- }
- break ;
- }
- }
- if (NewName == "."){
- NewName = "" ;
- }
- return NewName ;
- }
-//-----------------------------------------------------------------------------
-/**
-* gets the extension, including the ".", from a file name String.<p>
-*
-* If the Name doesn't contain a ".", the original Name is returned.
-* From Sun JFileChooser tutorial
-*
-* @param s String containing file name with extension.
-* @return String giving the extension.
-*/
-public static String getExtension( String s){
-
- String ext = "";
- int i = s.lastIndexOf('.');
-
- if (i > 0 && i < s.length() - 1) {
- ext = s.substring(i+1).toLowerCase();
- }
- return ext;
- }
-//-----------------------------------------------------------------------------
-/**
-* Prints the name of the calling location
-* plus the current Thread to System.out.<p>
-*
-* @param Location String giving location of call.
-*/
-public void printThread( String Location){
- Thread t = Thread.currentThread() ;
- System.out.println("At " + Location + ", the current Thread is "
- + t.getName() );
- return;
- }
-//-----------------------------------------------------------------------------
-/**
-* Test program.<p>
-*/
-public static void main( String[] args) {
- Fmt F = new Fmt() ;
- String Name = "XYX.txt.spa" ;
- System.out.println(Name) ;
- System.out.println(F.removeExtension(Name)) ;
- System.out.println(F.removeExtension(F.removeExtension(Name))) ;
- }
- } // End of class
-//==============================================================================
-//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java
deleted file mode 100644
index 80e0f2a..0000000
--- a/modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package Utilities ;
-
-import java.awt.*;
-import javax.swing.*;
-//==============================================================================
-/**
- * <b>Gets ultimate parent Frame of a component.</b><p>
- *
- * From page 274 of Pure JFC Swing.<p>
- *
- */
-//==============================================================================
-
-public class GetParentFrame{
-
-//-------------------------------------------------------------------------------
-/**
- * Gets the ultimate parent Frame of a Component.<p>
- *
- * @param comp a Component whose parent is sought.
- * @return a Frame Ultimate parent Frame of component.
- */
-static public Frame GetParentFrame(Component comp){
- if (comp instanceof Frame) return (JFrame)comp ;
- for (Component c = comp; c!= null; c = c.getParent() ){
- if (c instanceof Frame){
- return (Frame)c ;
- }
- }
- return null ;
- }
-// end of class
-}
-//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java
deleted file mode 100644
index b03c3b9..0000000
--- a/modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package Utilities ;
-
-import java.awt.*;
-import java.applet.* ;
-import java.awt.event.*;
-import javax.swing.*;
-//==============================================================================
-/**
-*
-* <b>Container object with JApplet, JFrame, and JDialog properties.<p></b>
-*
-*/
-//==============================================================================
-public class SuperContainer{
-
-Container InputContainer ;
-JRootPane RP ;
-Frame SuperFrame ; // Frame of overall screen.
-
-boolean IsJApplet = false ;
-boolean IsJFrame = false ;
-boolean IsJDialog = false ;
-boolean IsWindow = false ;
-
-/**
-* Container object with JApplet, JFrame, and JDialog properties.
-*
-* @param InputContainer Container, either a JApplet, JFrame, or JDialog.
-*/
-public SuperContainer(Container InputContainer){
- this.InputContainer = InputContainer ;
- if(InputContainer instanceof JApplet){
- IsJApplet = true ;
- RP = ((JApplet) InputContainer).getRootPane() ;
- }
- else if(InputContainer instanceof JFrame){
- IsJFrame = true ;
- RP = ((JFrame) InputContainer).getRootPane() ;
- }
- else if(InputContainer instanceof JDialog){
- RP = ((JDialog) InputContainer).getRootPane() ;
- IsJDialog = true ;
- }
- else{
- System.out.println("SuperContainer: Bad input type!") ;
- }
- IsWindow = IsJFrame | IsJDialog ;
- SuperFrame = GetParentFrame.GetParentFrame(RP.getContentPane()) ;
- }
-//------------------------------------------------------------------------------
-public Container getContentPane(){
- return RP.getContentPane() ;
- }
-//------------------------------------------------------------------------------
-public boolean isApplet(){
- return IsJApplet ;
- }
-//------------------------------------------------------------------------------
-public boolean isWindow(){
- return IsWindow ;
- }
-//------------------------------------------------------------------------------
-public void setResizable(boolean Resizable) {
- if(IsJDialog){
- ((Dialog)InputContainer).setResizable(Resizable) ;
- }
- else{
- SuperFrame.setResizable(Resizable) ;
- }
- }
-//------------------------------------------------------------------------------
-public void setTitle(String Title) {
- if(IsJFrame){
- ((JFrame) InputContainer).setTitle(Title);
- }
- else if(IsJDialog){
- ((JDialog) InputContainer).setTitle(Title);
- }
- return ;
- }
-//------------------------------------------------------------------------------
-public void addWindowListener(WindowListener WL) {
- if (IsWindow){
- ((Window)InputContainer).addWindowListener(WL) ;
- }
- return ;
- }
-//------------------------------------------------------------------------------
-public void setLocation( Point P ) {
- if (IsWindow){
- ((Window)InputContainer).setLocation(P) ;
- }
- return ;
- }
-//------------------------------------------------------------------------------
-public void setSize( Dimension D ) {
- if (IsWindow){
- ((Window)InputContainer).setSize(D) ;
- }
- return ;
- }
-//------------------------------------------------------------------------------
-public void setVisible(boolean Visible) {
- ((Component)InputContainer).setVisible(Visible) ;
- return ;
- }
-//------------------------------------------------------------------------------
-public void dispose() {
- if (IsWindow){
- ((Window)InputContainer).dispose() ;
- }
- else{
- // Restart ?
- }
- return ;
- }
-//------------------------------------------------------------------------------
-public Point getLocation() {
- if (IsWindow){
- return ((Window)InputContainer).getLocation() ;
- }
- else{
- return null ;
- }
- }
-//------------------------------------------------------------------------------
-public void pack() {
- if (IsWindow){
- ((Window)InputContainer).pack() ;
- }
- return ;
- }
-//------------------------------------------------------------------------------
-public Dimension getSize() {
- if (IsWindow){
- return ((Window)InputContainer).getSize() ;
- }
- else{
- return null ;
- }
- }
-//------------------------------------------------------------------------------
-public void setIconImage(Image I) {
- if (IsWindow){
- SuperFrame.setIconImage(I) ;
- }
- }
-//------------------------------------------------------------------------------
-public Frame superFrame() {
- return SuperFrame ;
- }
-//------------------------------------------------------------------------------
-public void showStatus(String Status) {
- if (!IsWindow){
- ((Applet)InputContainer).getAppletContext().showStatus(Status) ;
- }
- }
-//------------------------------------------------------------------------------
-public Component getGlassPane() {
- return RP.getGlassPane() ;
- }
-//------------------------------------------------------------------------------
-public void setGlassPane(Component GP) {
- RP.setGlassPane(GP) ;
- }
-//------------------------------------------------------------------------------
-public JRootPane getRootPane() {
- return RP.getRootPane() ;
- }
-//------------------------------------------------------------------------------
-public void addMouseListener(MouseListener ML) {
- RP.addMouseListener(ML);
- }
-//------------------------------------------------------------------------------
-}
-//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java
index fbd33b2..bd06e43 100644
--- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java
+++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java
@@ -1,5 +1,6 @@
package WLC2OSIS.Parse ;
+import java.io.*;
import WLC2OSIS.* ;
import WLC2OSIS.Translate.* ;
import WLC2OSIS.Utilities.* ;
@@ -56,6 +57,8 @@ int ChapterNumber ;
int VerseNumber ;
int WordNumber ;
+BufferedReader file;
+
//-----------------------------------------------------------------------------
public Parser(WLC2OSIS A) {
this.A = A ;
@@ -86,37 +89,52 @@ public void parse(){
boolean PreviousEOL = true ;
System.out.println("\n") ;
- A.w = new XMLWriter(A.OutputDirectory, "WLC_OSIS") ;
-
// Write the header
- Header.writeHeader(A, A.w) ;
+ 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) ;
+ }
- for (int k = 0; k < A.InputChars.length ; k++){
+ while ( true ){
+ s="";
+ try{
+ s= file.readLine();
+ }
+ catch (IOException e) {
+ System.out.println("Read error: " + e) ;
+ break;
+ }
- s = t.nextToken() ;
- System.out.println("processing: " + s);
-
- if(s.compareTo(t.EOF) == 0){
- break ;
- }
-
-//-----------------------------------------------------------------------------
+// System.out.println("processing: " + s);
-// Process a line identifier
-
- if (PreviousEOL){
- int ColonIndex = s.indexOf(':') ;
- if(ColonIndex <=0 ){
- System.out.println("Parser: Incorrect line identifier: " + s + " !") ;
- break ;
- }
- PreviousEOL= false ;
-
+ 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 );
+ if (!m.matches()){
+ System.out.println("No match!");
+ System.exit(1);
+ }
+
// Parse the identifier
- String BookCode = s.substring(0,2) ;
- int Chapter = Integer.parseInt( s.substring(2, ColonIndex) ) ;
- int Verse = Integer.parseInt( s.substring(ColonIndex+1) ) ;
-
+ 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 expression = m.group(6);
+ String lemma = m.group(7);
+ String grammar = m.group(8);
+
+ System.out.println(BookCode + " " + Chapter + " " + Verse + " " + wordNumber + " " + subWordNumber + " " +expression+" "+lemma+" "+grammar);
+/*
// Change in Book, start a book.
if(BookCode.compareTo(LastBookCode) != 0){
v.end() ;
@@ -145,18 +163,12 @@ public void parse(){
v.end() ;
v.start() ;
LastVerse = Verse ;
- }
- }
+ }*/
//-----------------------------------------------------------------------------
// Process a word.
- else{
- if(s.compareTo(t.EOL) == 0){
- PreviousEOL = true ;
- }
- else{
- if (s.length() > 1){
+/* if (s.length() > 1){
w.process(s) ;
}
else{
@@ -173,11 +185,8 @@ public void parse(){
else{ // It's a word
w.process(s) ;
}
- }
- }
- }
-
- }
+ }*/
+ }
v.end() ;
c.end() ;
b.end() ;
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java
index a0aff2b..2821580 100644
--- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java
+++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java
@@ -17,7 +17,7 @@ public class Tokenizer{
public final String EOF = "***EOF***" ;
public final String EOL = "***EOL***" ;
WLC2OSIS A ;
-CharArrayReader car ;
+//CharArrayReader car ;
StreamTokenizer st ;
//-----------------------------------------------------------------------------
@@ -27,8 +27,13 @@ public Tokenizer(WLC2OSIS A ) {
// Set up the tokenizer
- car = new CharArrayReader(A.InputChars) ;
- st = new StreamTokenizer( car) ;
+// car = new CharArrayReader(A.InputChars) ;
+ try{
+ st = new StreamTokenizer( new FileInputStream( A.InputFilename ) ) ;
+ }
+ catch (IOException e) {
+ System.exit(0);
+ }
st.resetSyntax() ;
st.wordChars(33, 126 ) ; // All printables are word characters
st.ordinaryChar(63) ; // ? is a special symbol, the EOL marker.
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java
deleted file mode 100644
index d05a6c7..0000000
--- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package WLC2OSIS.Translate ;
-
-import WLC2OSIS.* ;
-import WLC2OSIS.Translate.* ;
-import WLC2OSIS.Utilities.* ;
-
-// import java.util.Date ;
-// import java.text.SimpleDateFormat ;
-//==============================================================================
-/**
- * <b>Header information for Tanach.</b><p>
- */
-//==============================================================================
-public class Header{
-
-// static SimpleDateFormat DateFormat = new SimpleDateFormat("dd MMM yyyy") ;
-// static String DateTime ;
-
-public Header(){
- }
-//-----------------------------------------------------------------------------
-
-// Writes the Notes to the XML file.
-
-public static void writeHeader(WLC2OSIS A, XMLWriter w) {
-// Date DT = new Date() ;
-// DateTime = DateFormat.format(DT) ;
- A.w.openTag("osisText osisIDWork=\"WLC\" osisRefWork=\"bible\" xml:lang=\"he\"", 0) ;
- A.w.openTag("header", 0) ;
-
- A.w.openTag("work osisWork=\"WLC\"", 1) ;
-
- A.w.writeString("title", 2, "Westminster Leningrad Codex");
- A.w.writeAttributedString("contributor", 2, "role=\"encoder\"", "Martin Gruner");
- A.w.writeAttributedString("type", 2, "type=\"OSIS\"", "Bible");
- A.w.writeAttributedString("identifier", 2, "type=\"OSIS\"", "Bible.he.WLC.2004");
- A.w.writeAttributedString("rights", 2, "type=\"x-copyright\"",
- "The WLC is maintained by the Westminster Hebrew Institute, Philadelphia, PA (http://whi.wts.edu/WHI)");
- A.w.writeString("scope", 2, "Hebrew Bible, Old Testament");
- A.w.writeString("refSystem", 2, "MT");
-
- A.w.closeTag("work", 1);
-
- A.w.closeTag("header", 0);
-
-// A.w.writeString("hebrewname", 1, H.Tnk) ;
-// A.w.writeString("title", 1, A.Title) ;
-// A.w.writeString("shortdescription", 1, A.ShortDescription) ;
-// for (int i =0; i < A.Description.length; i++){
-// A.w.writeString("description", 1, A.Description[i]) ;
-// }
-// //A.w.writeString("date", 1, A.Date) ;
-// A.w.writeString("transcriptiondate", 1, DateTime) ;
-// A.w.writeString("copyright", 1, "\u00A9 C. V. Kimball 2004") ;
-// A.w.writeString("filename", 1, A.InputFilename) ;
-//
-// A.w.closeTag("header", 0) ;
- }
-
-//==============================================================================
-
-public static void writeFooter(WLC2OSIS A, XMLWriter w) {
-
- A.w.closeTag("osisText", 0);
-
- }
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-}//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java
deleted file mode 100644
index 340db8f..0000000
--- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package WLC2OSIS.Utilities ;
-
-import WLC2OSIS.* ;
-import Utilities.FileChooser ;
-//import Utilities.Message ;
-
-import java.io.* ;
-import javax.swing.* ;
-import java.awt.* ;
-//==============================================================================
-/**
- * <b>Reads the input file.</b>
- */
-//==============================================================================
-public class FileRead{
-
-
-WLC2OSIS A ;
-int InputLength ;
-public byte[] InputBuffer ;
-File F ;
-FileInputStream FIS ;
-boolean Error ;
-//-----------------------------------------------------------------------------
-
-public FileRead(WLC2OSIS A ) {
- this.A = A ;
- InputBuffer = new byte[A.InputBufferSize] ;
- Error = false ;
- }
-//------------------------------------------------------------------------------
-
-// Reads the specified file, forming the char[] InputChars and StringBuffer Input.
-
-public void read(String Filename){
- Error = true ;
-
-// Open the file
-
- F = new File(Filename) ;
-
- try{
- FIS = new FileInputStream(F);
- if (FIS.available() > InputBuffer.length){
- System.out.println(
- "The input file length, " + FIS.available()
- + " bytes,\nis too long for the internal buffer of "
- + InputBuffer.length + " bytes.") ;
- return ;
- }
- }
- catch(IOException e){
- System.out.println(
- "FileRead.read: Error in opening FileInputStream.\n\n"
- + F.getPath() + "\n\n"
- + e.toString() + "\nNo further action taken.") ;
- return ;
- }
-//------------------------------------------------------------------------------
-
-// Read the file
-
- try{
- InputLength = FIS.read(InputBuffer) ;
- }
- catch(IOException e){
- System.out.println(
- "FileRead.read: Error on read of input file.\n\n"
- + F.getPath() + "\n\n"
- + e.toString() + "\nNo further action taken.") ;
- return;
- }
-
-// Close the file.
-
- try{
- FIS.close() ;
- }
- catch(IOException e){
- System.out.println(
- "FileRead.read: Error on close of input file.\n\n"
- + F.getPath() + "\n\n"
- + e.toString() + "\nNo further action taken.") ;
- }
-
-// Convert bytes to char[] array.
-
- A.InputChars = new char[InputLength] ;
- for (int k = 0; k < InputLength; k++){
- short shrt = (short) InputBuffer[k] ;
- A.InputChars[k] = (char) shrt ;
- }
-
- Error = false ;
- }
-//------------------------------------------------------------------------------
-
-// Gets the error condition.
-
-public boolean getError(){
- return Error ;
- }
-//-----------------------------------------------------------------------------
-}
-//==============================================================================
-//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java
index 76d687d..8b03f60 100644
--- a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java
+++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java
@@ -70,10 +70,12 @@ public String MorphologicalDivisionMarker = MorphologicalSegmentEnd + Morphologi
//-----------------------------------------------------------------------------
-public final int InputBufferSize = 40000000 ; // Length of input in bytes.
+//public final int InputBufferSize = 40000000 ; // Length of input in bytes.
public char[] InputChars ; // Input char[] array set by FileRead.
public Parser p ;
-public XMLWriter w ;
+public XMLWriter wlc;
+public XMLWriter morph;
+
public Fmt F = new Fmt() ;
// public boolean StandAlone = true ; // If used by another app,
@@ -82,21 +84,43 @@ public WLC2OSIS( String file, String directory ){
InputFilename = file ;
OutputDirectory = directory ;
-// Identifying printouts
-
F.bar("=", 80) ;
System.out.println("\nWLC2OSIS: " + Title + " " + ShortDescription ) ;
System.out.println("\nInput file: " + InputFilename ) ;
-// System.out.println( "Input file date: " + Date ) ;
System.out.println("\nOutput directory: " + OutputDirectory ) ;
- FileRead FR = new FileRead(this) ;
- FR.read(InputFilename) ;
-
// Read, parse, and write the book files.
+
+ wlc = new XMLWriter(A.OutputDirectory, "wlc_osis") ;
+ morph = new XMLWriter(A.OutputDirectory, "morph_osis") ;
+
+
+ wlc.openTag("osisText osisIDWork=\"WLC\" osisRefWork=\"bible\" xml:lang=\"he\"", 0) ;
+ wlc.openTag("header", 0) ;
+
+ wlc.openTag("work osisWork=\"WLC\"", 1) ;
+
+ wlc.writeString("title", 2, "Westminster Leningrad Codex");
+ wlc.writeAttributedString("contributor", 2, "role=\"encoder\"", "Martin Gruner");
+ wlc.writeAttributedString("type", 2, "type=\"OSIS\"", "Bible");
+ wlc.writeAttributedString("identifier", 2, "type=\"OSIS\"", "Bible.he.WLC.2004");
+ wlc.writeAttributedString("rights", 2, "type=\"x-copyright\"",
+ "The WLC is maintained by the Westminster Hebrew Institute, Philadelphia, PA (http://whi.wts.edu/WHI)");
+ wlc.writeString("scope", 2, "Hebrew Bible, Old Testament");
+ wlc.writeString("refSystem", 2, "MT");
+
+ wlc.closeTag("work", 1);
+ wlc.closeTag("header", 0);
+
+
+
+
+
p = new Parser(this) ;
p.parse() ;
+ wlc.closeTag("osisText", 0);
+
done() ;
}