Difference between revisions of "Converting SFM Bibles to OSIS"

From CrossWire Bible Society
Jump to: navigation, search
m (Stage 2: <ref> .... </ref>)
(Stage 2: sword locale file)
Line 83: Line 83:
 
# Check again for XML validity.<ref>See [[OSIS_Bibles#Valid_OSIS_test|OSIS Bible validation]] for further instructions on OSIS validation.</ref>
 
# Check again for XML validity.<ref>See [[OSIS_Bibles#Valid_OSIS_test|OSIS Bible validation]] for further instructions on OSIS validation.</ref>
 
# Run the OSIS  file through osis2mod<ref>Instructions for running osis2mod are available at [[osis2mod#Usage|osis2mod usage]].</ref>, create a [[DevTools:conf Files|conf file]], and check the resultant module for problems in a variety of front-ends.<ref>Fixes should be made in the USFM files at the very start and then cascaded down into the module following the overall process again.</ref>
 
# Run the OSIS  file through osis2mod<ref>Instructions for running osis2mod are available at [[osis2mod#Usage|osis2mod usage]].</ref>, create a [[DevTools:conf Files|conf file]], and check the resultant module for problems in a variety of front-ends.<ref>Fixes should be made in the USFM files at the very start and then cascaded down into the module following the overall process again.</ref>
# Create a sword locale file and store in my /usr/share/sword/locales.d/ (or the equivalent directory on your system)  
+
# Create a [[DevTools:SWORD#Locale_file_layout|sword locale file]] and store in my /usr/share/sword/locales.d/ (or the equivalent directory on your system)  
 
# If cross references are part of the USFM files fix these with the help of xreffix.pl (also in sword-tools).<ref>This requires a sword locale in the local installation at least.</ref>
 
# If cross references are part of the USFM files fix these with the help of xreffix.pl (also in sword-tools).<ref>This requires a sword locale in the local installation at least.</ref>
 
# Run again through osis2mod and check again.
 
# Run again through osis2mod and check again.

Revision as of 10:26, 11 December 2010

Introduction

Standard Format Markers (SFM) and its more standardized derivative USFM have been used for decades to store Bibles for printing and display in programs like UBS Paratext. The format is popular among Bible translation agencies and Bible societies. The basic format of SFM is simply plaintext with backslash(\) codes. For example, a new Bible verse is signaled by \v followed by the number of the verse.

Older texts in various dialects of SFM can still be found. It was common for various agencies, Bible societies, and even regional offices of such groups to have their own SFM standards. Unified Standard Format Markers (USFM) was developed to standardize SFM and encourage interoperability so that Bibles from one agency could be reasonably expected to operate with the software and stylesheets employed by another. The current version of USFM is 2.2, defined at http://confluence.ubs-icap.org/display/USFM/Home.

Preparing (U)SFM files for conversion

The simplicity of writing SFM also makes it easy to write poor SFM that fails to correspond to any kind of standard. The first task in preparing to convert SFM files to OSIS is to clean the text. The more regular your source files are, the more likely the conversion process will operate correctly.

One method of cleaning up your files is to import them into an SFM editor such as Bibledit (which runs on Linux, Mac OS X, and Windows) or SIL FieldWorks Translation Editor (which runs on Windows). The editors will frequently perform some basic corrections to the SFM syntax, but Bibledit in particular can perform a number of checks to correct specific errors common to SFM.

Checking USFM files for versification issues

Rather than waiting until you have the end result, a SWORD module, and then running the general utility emptyvss, it is possible to use another Windows based utility called GoBibleCreator USFM Preprocessor. Despite its name, its use is not limited to conversion of documents for use towards making Go Bible applications. Although this was originally developed for supporting the Go Bible project, it does have some useful more general features. This is one of them, and is found under the "Check for Consistency" tab. Another is the ability to export the USFM Bible into BQ/DigiStudy format. The Search for Versification Issues is particularly helpful for Bibles structured primarily as "verse per line", rather than as paragraphs containing a verse range. Another useful feature is the identification of non-standard markers.

Converting USFM files to OSIS

There exist two publicly distributed programs capable of converting USFM files to OSIS: usfm2osis.pl and SFMToOSIS. If you have the time, ability, and inclination, you may want to try both programs and see which one works best for you.

Using usfm2osis.pl

It is usually advisable to use the most recent version of usfm2osis.pl – The version in SVN may be more recent than the copy in our ftpmirror.

usfm2osis.pl is a simple Perl script intended only for converting USFM files to OSIS. usfm2osis.pl was written by CrossWire, so its OSIS output is geared towards the use of OSIS documents in modules for The SWORD Project. usfm2osis.pl is actively maintained by CrossWire, and bug reports and feature requests are welcomed at sword-support.

usfm2osis.pl requires a Perl interpreter in the system path. Then you can run:

perl usfm2osis.pl <osisWork> [-o OSIS-file] [-e USFM encoding] <USFM filenames|wildcard>

osisWork should be a value such as Bible.en.WEB.2007.

If you include an OSIS-file value, the output will be written there. Otherwise, it will be written to a file name based on your osisWork.

The USFM encoding argument should indicate the character encoding found in the source files. If none is give, UTF-8 is the default. The list of available encodings depends on your system. Executing the script with no arguments will print the list (as will executing it with an invalid encoding value).

The final argument is a list of filenames or a wildcard value such as *.sfm containing the SFM data.

Using SFMToOSIS

SFMToOSIS is a robust, but somewhat difficult to setup and use, program produced by Snowfall Software. The program requires that you install a Python interpreter and that the interpreter be within the system path. The program can also convert OSIS files back to SFM. SFMToOSIS more robust than usfm2osis.pl and more likely to produce valid OSIS files automatically. The program has been renamed as OSIS Conversion Utility but comes under the heading Scripture Preservation Utility.

The program also requires a Paratext .ssf file. If you do not have such a file, you can use the following sample and adjust it to the specifics of your own text:

<ScriptureText>
<BooksPresent>111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000</BooksPresent>
<Encoding>UTF-8</Encoding>
<ChapterMarker>c</ChapterMarker>
<Copyright></Copyright>
<FileNameForm>41MAT</FileNameForm>
<FileNamePostPart>.SFM</FileNamePostPart>
<FileNamePrePart></FileNamePrePart>
<FullName>The Bible in English</FullName>
<Language>ENGLISH</Language>
<LeftToRight>T</LeftToRight>
<Name>EN</Name>
<VerseMarker>v</VerseMarker>
<Versification>4</Versification>
</ScriptureText>

Next, update the run.bat file that came with SFMToOSIS to point to your SFM files and SSF file. Then run run.bat.

Creation of publication ready modules from USFM and submission to CrossWire

Before you import your OSIS files to SWORD format, you should check that it is valid OSIS.
Before you submit any files to modules@crosswire.org, you must ensure that your files are valid OSIS. Invalid OSIS files will not be accepted.

Our process to create publication ready modules from USFM looks like this:

Stage 1

  • Iterate usfm2osis.pl over each single USFM file to produce a OSIS file per USFM file
for biblebook in `ls *usfm`; do usfm2osis.pl $biblebook $biblebook; done
  • Check each OSIS file for XML validity - this will throw up a lot of not obvious USFM encoding problems
for biblebook in `ls *osis.xml`; do checkbible $biblebook; done
  • Correct USFM files as per mistakes found

Rerun above until you have clean and validating OSIS files.

Stage 2

  1. Check the OSIS files for not transformed USFM markers.[1]
  2. Fix usfm2osis.pl and add the missing tags for correct OSIS transformation.
  3. Rerun above until you have a clean validating collection of OSIS files with no left over USFM tags.[2]
  4. Send the updates to usfm2osis.pl to CrossWire's repository.
  5. Run usfm2osis.pl over all the USFM files and create a single large OSIS file,
  6. Check again for XML validity.[3]
  7. Run the OSIS file through osis2mod[4], create a conf file, and check the resultant module for problems in a variety of front-ends.[5]
  8. Create a sword locale file and store in my /usr/share/sword/locales.d/ (or the equivalent directory on your system)
  9. If cross references are part of the USFM files fix these with the help of xreffix.pl (also in sword-tools).[6]
  10. Run again through osis2mod and check again.
  11. Submit the final OSIS file and the conf file to CrossWire together with the locale file
  12. Send any corrections on the USFM files back to the translation team. Chances are these are all valid and necessary corrections which help to improve the USFM.[7]

Notes:

  1. Not many common ones are left unsupported, but you may encounter usually one or two new ones if you get files from a different new source.
  2. A lot of the repetitive aspects can be done with the help of some shell scripts, so do not worry that you have to run each time multiples of usfm2osis.pl by hand.
  3. See OSIS Bible validation for further instructions on OSIS validation.
  4. Instructions for running osis2mod are available at osis2mod usage.
  5. Fixes should be made in the USFM files at the very start and then cascaded down into the module following the overall process again.
  6. This requires a sword locale in the local installation at least.
  7. Both Paratext and Bibledit are a bit more forgiving than our tools, but the problems I've found could sometimes have affected the final paper print.