예제 #1
0
        static void Main(string[] args)
        {
            Logit.useConsole = true;
            RecoverOsisData oz;

            if (args.Length < 2)
            {
                Console.WriteLine(@"Syntax:
imposis2xml.exe infile xmlfile [logname]
  infile = file written by mod2imp.exe or an OSIS file like the KJV2006 example
  xmlfile = xml file for further parsing
  logname = name of log text file");

                oz = new RecoverOsisData();
                oz.readImpOsis(@"C:\Users\Kahunapule\Documents\tmp\Wycliffe.imp", @"C:\Users\Kahunapule\Documents\tmp\Wycliffe.usfx");
                Logit.CloseFile();
            }
            else
            {
                if (args.Length >= 3)
                {
                    Logit.OpenFile(args[2]);
                }
                Console.WriteLine("imposis2xml " + args[0] + " " + args[1]);
                oz = new RecoverOsisData();
                oz.readImpOsis(args[0], args[1]);
                Logit.CloseFile();
            }
        }
예제 #2
0
        private void convertButton_Click(object sender, System.EventArgs e)
        {
            Logit.OpenFile("WordSendLog.txt");
            Logit.GUIWriteString = new StringDelegate(WriteToStatusListBox);

            Logit.WriteLine("Sorry, this program is still under construction.");

            Logit.CloseFile();
        }
예제 #3
0
        static void Main(string[] args)
        {
            int    i;
            bool   showBanner = true;
            string logName    = "usfm2usfxlog.txt";
            string outName    = "";

            ArrayList fileSpecs = new ArrayList(127);

            Logit.useConsole = true;
            for (i = 0; i < args.Length; i++)
            {                   // Scan the command line
                string s = args[i];
                if ((s != null) && (s.Length > 0))
                {
                    if (((s[0] == '-') || (s[0] == '/')) && (s.Length > 1))
                    {                           // command line switch: take action
                        switch (Char.ToLower(s[1]))
                        {
                        case 'n':                                       // No banner display
                            showBanner = false;
                            break;

                        case 'o':                                       // Set output file name
                            outName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'l':                                       // Set log name
                            logName = SFConverter.GetOption(ref i, args);
                            break;

                        case '-':
                        case 'h':
                        case '?':
                            showBanner = true;
                            break;

                        default:
                            Logit.WriteLine("Unrecognized command line switch: " + args[i]);
                            showBanner = true;
                            break;
                        }
                    }
                    else
                    {
                        fileSpecs.Add(args[i]);
                    }
                }
            }
            Logit.OpenFile(logName);
            if (showBanner)
            {
                Logit.WriteLine("This is part of Haiola open source software.");
                Logit.WriteLine("Please see http://haiola.org for copyright information.");
                Logit.WriteLine(@"
Syntax:
usfm2usfx [-o Output] [-n] [-l logname] [-?] filespec(s)
 Output = output USFX file name
 -n = don't display copyright and banner information.
 logname = log file name (default is usfm2usfxlog.txt)
 -? = cancel previous /n and show this information.
 filespec = SFM file specification(s) to read. Wild cards are OK.
You may use / instead of - to introduce switches. Do not use
either of those two characters as the first character of a file name.

");
            }

            if (outName == "")
            {
                outName = "output.usfx.xml";
            }
            if (fileSpecs.Count < 1)
            {
                Logit.WriteLine("Nothing to do. No input files specified.");
            }
            else
            {
                // Instantiate the object that does most of the work.
                SFConverter.scripture = new Scriptures();

                // Read the input USFM files into internal data structures.
                for (i = 0; i < fileSpecs.Count; i++)
                {
                    SFConverter.ProcessFilespec((string)fileSpecs[i]);
                }

                // Write out the USFX file.
                SFConverter.scripture.WriteUSFX(outName);
            }
        }
예제 #4
0
파일: global.cs 프로젝트: mwatts/haiola
        public void PreprocessUsfmFiles(string SourceDir)
        {
            // First, copy BookNames.xml for ready reference. We will update it later.
            string bookNamesCopy   = Path.Combine(outputProjectDirectory, "BookNames.xml");
            string bookNamesSource = Path.Combine(SourceDir, "BookNames.xml");

            if (File.Exists(bookNamesCopy))
            {
                File.Delete(bookNamesCopy);
            }
            if (File.Exists(bookNamesSource))
            {
                File.Copy(bookNamesSource, bookNamesCopy, true);
            }

            // Now, get on with preprocessing the USFM files.
            Logit.GUIWriteString = GUIWriteString;
            Logit.OpenFile(Path.Combine(outputProjectDirectory, "preprocesslog.txt"));
            // string SourceDir = Path.Combine(globe.inputProjectDirectory, "Source");

            /*
             * StreamReader sr = new StreamReader(orderFile);
             * string allowedBookList = sr.ReadToEnd();
             * sr.Close();
             */
            string bookId;
            string UsfmDir = Path.Combine(outputProjectDirectory, "extendedusfm");

            if (!Directory.Exists(SourceDir))
            {
                WriteLine("ERROR: " + SourceDir + " not found!");
                return;
            }
            // Start with an EMPTY USFM directory to avoid problems with old files
            Utils.DeleteDirectory(UsfmDir);
            fileHelper.EnsureDirectory(UsfmDir);
            string[] inputFileNames = Directory.GetFiles(SourceDir);
            if (inputFileNames.Length == 0)
            {
                WriteLine("ERROR: No files found in " + SourceDir);
                return;
            }

            foreach (string inputFile in inputFileNames)
            {
                string filename  = Path.GetFileName(inputFile);
                string lowerName = filename.ToLower();
                string fileType  = Path.GetExtension(filename).ToUpper();
                if ((fileType != ".BAK") && (fileType != ".LDS") &&
                    (fileType != ".SSF") && (fileType != ".DBG") &&
                    (fileType != ".WDL") && (fileType != ".STY") &&
                    (fileType != ".XML") && (fileType != ".HTM") &&
                    (fileType != ".KB2") && (fileType != ".HTML") &&
                    (fileType != ".CSS") && (fileType != ".SWP") &&
                    (fileType != ".ID") && (fileType != ".DIC") &&
                    (fileType != ".LDML") && (fileType != ".JSON") &&
                    (fileType != ".VRS") && (fileType != ".INI") && (fileType != ".CSV") && (fileType != ".TSV") &&
                    (fileType != ".CCT") && (!inputFile.EndsWith("~")) &&
                    (lowerName != "autocorrect.txt") &&
                    (lowerName != "tmp.txt") &&
                    (lowerName != "changes.txt") &&
                    (lowerName != "hyphenatedWords.txt") &&
                    (lowerName != "wordboundariesoutput.txt") &&
                    (lowerName != "printdraftchanges.txt"))
                {
                    ShowStatus("preprocessing " + filename);
                    Application.DoEvents();
                    if (!fileHelper.fAllRunning)
                    {
                        break;
                    }
                    string outputFileName = MakeUpUsfmFileName(inputFile, out bookId) + ".usfm";
                    if (outputFileName.Length < 8)
                    {
                        if (fileType != ".TXT")
                        {
                            Logit.WriteLine("No proper \\id line found in " + inputFile);
                        }
                    }
                    else
                    {
                        if (projectOptions.allowedBookList.Contains(bookId))
                        {
                            string outputFilePath = Path.Combine(UsfmDir, outputFileName);
                            PreprocessOneFile(inputFile, projectOptions.preprocessingTables, outputFilePath);
                        }

                        /*
                         * else
                         * {
                         *  Logit.WriteLine("Skipping book " + bookId + " (not in " + orderFile + ")");
                         * }
                         */
                    }
                }
            }
        }
예제 #5
0
파일: usfx2usfm.cs 프로젝트: mwatts/haiola
        static void Main(string[] args)
        {
            int    i;
            bool   showBanner = false;
            string logName    = "WordSendLog.txt";
            string inName     = "";
            string outName    = ".sfm";

            // string jobOptionsName = Environment.GetEnvironmentVariable("APPDATA")+
            //  "\\SIL\\WordSend\\joboptions.xml";
            Logit.useConsole = true;
            for (i = 0; i < args.Length; i++)
            {                   // Scan the command line
                string s = args[i];
                if ((s != null) && (s.Length > 0))
                {
                    if ((s[0] == '-') && (s.Length > 1))
                    {                           // command line switch: take action
                        switch (Char.ToLower(s[1]))
                        {
                        case 'o':                                       // Set output file name
                            outName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'i':                                       // Set input file name
                            inName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'l':                                       // Set log name
                            logName = SFConverter.GetOption(ref i, args);
                            break;

                        case '-':
                        case 'h':
                        case '?':
                            showBanner = true;
                            break;

                        default:
                            Logit.WriteLine("Unrecognized command line switch: " + args[i]);
                            showBanner = true;
                            break;
                        }
                    }
                    else if (inName == "")
                    {
                        inName = args[i];
                    }
                }
            }
            Logit.OpenFile(logName);
            Logit.WriteLine("\nWordSend project usfx2usfm compiled " + Version.date);

            if (inName == "")
            {
                showBanner = true;
            }
            else
            {
                Logit.WriteLine("Input file name is " + inName + "; output suffx is " + outName);
                // Something to refactor: make this line not required.
                // SFConverter.jobIni = new XMLini(jobOptionsName);

                // Here we instantiate the object that does most of the work.
                SFConverter.scripture = new Scriptures();

                // Write out the USFM file
                SFConverter.scripture.USFXtoUSFM(inName, Path.GetDirectoryName(outName), Path.GetFileName(outName));
            }
            if (showBanner)
            {
                Logit.WriteLine("");
                Logit.WriteLine(Version.copyright);
                Logit.WriteLine("");
                Logit.WriteLine(Version.contact);
                Logit.WriteLine(@"
Syntax:
usfx2usfm [-o Output] [-?] [-l logname] [-i] inputfile
 Output = output USFM path and file name suffix
      default is .sfm
      book code will be added, i. e. pdg.sfm -> MATpdg.sfm
      and subdir\eng.sfm -> subdir\MATeng.sfm
 logname is name of log file to write, default is WordSendLog.txt
 -h or -? = show this information.
 inputfile = name of USFX file to convert to USFM
File names with embedded spaces must be surrounded by quotes.
Do not use - as the first character of a path or file name.

");
                Logit.CloseFile();
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            int    i;
            bool   showBanner     = false;
            string logName        = "usfx2mosislog.txt";
            string inName         = "usfx.xml";
            string outName        = "mosis.xml";
            string ethnologueCode = String.Empty;
            string translationId  = String.Empty;

            Logit.useConsole = true;
            for (i = 0; i < args.Length; i++)
            {                   // Scan the command line
                string s = args[i];
                if ((s != null) && (s.Length > 0))
                {
                    if ((s[0] == '-') && (s.Length > 1))
                    {                           // command line switch: take action
                        switch (Char.ToLower(s[1]))
                        {
                        case 'o':                                       // Set output file name
                            outName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'i':                                       // Set input file name
                            inName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'l':                                       // Set log name
                            logName = SFConverter.GetOption(ref i, args);
                            break;

                        case 't':
                            translationId = SFConverter.GetOption(ref i, args);
                            break;

                        case '-':
                        case 'h':
                        case '?':
                        case '/':
                            showBanner = true;
                            break;

                        default:
                            Logit.WriteLine("Unrecognized command line switch: " + args[i]);
                            showBanner = true;
                            break;
                        }
                    }
                    else if (inName == "")
                    {
                        inName = args[i];
                    }
                }
            }
            Logit.OpenFile(logName);

            if (showBanner)
            {
                Logit.WriteLine("");
                Logit.WriteLine("This is part of Haiola open source software.");
                Logit.WriteLine("Please see http://haiola.org for copyright information.");
                Logit.WriteLine(@"
Syntax:
usfx2usfm [-t translationId] [-o Output] [-?] [-l logname] [-i] [inputfile]
 translationId = unique translation identifier
      default is Ethnologue language code specified in usfx file
 Output = output USFM path and file name suffix
      default is mosis.xml
 logname is name of log file to write, default is usfx2mosislog.txt
 -h or -? = show this information.
 inputfile = name of USFX file to convert to USFM
      default is usfx.xml
File names with embedded spaces must be surrounded by quotes.
Do not use - as the first character of a path or file name.

");
            }
            else
            {
                Logit.WriteLine(DateTime.Now.ToString());
                Logit.WriteLine("Input USFX: " + inName + "; output MOSIS: " + outName);

                usfxToMosisConverter toMosis = new usfxToMosisConverter();

                toMosis.translationId    = translationId;
                toMosis.revisionDateTime = DateTime.Now;

                toMosis.languageCode           = String.Empty;
                toMosis.vernacularTitle        = toMosis.contentCreator = toMosis.contentContributor = String.Empty;
                toMosis.englishDescription     = toMosis.lwcDescription = toMosis.printPublisher = String.Empty;
                toMosis.ePublisher             = toMosis.languageName = toMosis.dialect = String.Empty;
                toMosis.vernacularLanguageName = toMosis.copyrightNotice = String.Empty;
                toMosis.rightsNotice           = String.Empty;
                toMosis.langCodes = new LanguageCodeInfo();
                toMosis.ConvertUsfxToMosis(inName, outName);
            }
            Logit.CloseFile();
        }
예제 #7
0
        static void Main(string[] args)
        {
            bool   showBanner = true;
            bool   showHelp   = false;
            string logName    = "WordSendLog.txt";
            string inName     = "";
            string outName    = "";
            int    i;
            string jobOptionsName = Environment.GetEnvironmentVariable("APPDATA") +
                                    "\\SIL\\WordSend\\joboptions.xml";

            SFConverter.jobIni = new XMLini(jobOptionsName);
            Logit.useConsole   = true;
            for (i = 0; i < args.Length; i++)
            {                   // Scan the command line
                string s = args[i];
                if ((s != null) && (s.Length > 0))
                {
                    if (((s[0] == '-') || (s[0] == '/')) && (s.Length > 1))
                    {                           // command line switch: take action
                        switch (Char.ToLower(s[1]))
                        {
                        case 'n':                                       // No banner display
                            showBanner = false;
                            break;

                        case 'o':                                       // Set output file name
                            outName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'i':                                       // Set input file name
                            inName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'l':                                       // Set log name
                            logName = SFConverter.GetOption(ref i, args);
                            break;

                        case '?':
                        case 'h':
                        case '-':
                            showBanner = true;
                            showHelp   = true;
                            break;

                        default:
                            Logit.WriteLine("Unrecognized command line switch: " + args[i]);
                            break;
                        }
                    }
                    else
                    {
                        if (inName == "")
                        {
                            inName = s;
                        }
                        else
                        {
                            if (outName == "")
                            {
                                outName = s;
                            }
                            else
                            {
                                showBanner = true;
                                showHelp   = true;
                            }
                        }
                    }
                }
            }
            SFConverter.scripture = new Scriptures();
            Logit.OpenFile(logName);
            if (showBanner)
            {
                Logit.WriteLine("\nWordSend project extract_usfx compiled " + Version.date);
                Logit.WriteLine("");
                Logit.WriteLine(Version.copyright);
                Logit.WriteLine("");
                Logit.WriteLine(Version.contact);
            }
            if ((outName.Length < 1) || (inName.Length < 1))
            {
                showHelp = true;
            }
            if (showHelp)
            {
                Logit.WriteLine(@"
Syntax:
sf2word [-l logname] [-h] [-n] [-i] inputfile [-o] outputfile
 logname = log file name (default is WordSendLog.txt)
 -h = show this information then exit
 -n = supress banner
 inputfile = Microsoft Word XML file that has embedded USFX
 outputfile = name of USFX file to write

");
                Logit.CloseFile();
                return;
            }
            Logit.WriteLine("Auxilliary files read.");
            SFConverter.scripture.ExtractUSFX(inName, outName);
            Logit.WriteLine("Done.");
            Logit.CloseFile();
        }
예제 #8
0
파일: sf2word.cs 프로젝트: mwatts/haiola
        static void Main(string[] args)
        {
            int    i;
            bool   showBanner     = true;
            string outName        = "";
            string logName        = "WordSendLog.txt";
            string jobOptionsName = Environment.GetEnvironmentVariable("APPDATA") +
                                    "\\SIL\\WordSend\\joboptions.xml";
            string    templateName = "";
            ArrayList fileSpecs    = new ArrayList(127);

            Logit.useConsole = true;
            for (i = 0; i < args.Length; i++)
            {                   // Scan the command line
                string s = args[i];
                if ((s != null) && (s.Length > 0))
                {
                    if (((s[0] == '-') || (s[0] == '/')) && (s.Length > 1))
                    {                           // command line switch: take action
                        switch (Char.ToLower(s[1]))
                        {
                        case 'j':                                       // Job options file name
                            jobOptionsName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'n':                                       // No banner display
                            showBanner = false;
                            break;

                        case 'o':                                       // Set output file name
                            outName = SFConverter.GetOption(ref i, args);
                            break;

                        case 't':                                       // Set template file name
                            templateName = SFConverter.GetOption(ref i, args);
                            break;

                        case 'l':                                       // Set log name
                            logName = SFConverter.GetOption(ref i, args);
                            break;

                        case '?':
                        case 'h':
                        case '-':
                            showBanner = true;
                            break;

                        default:
                            Logit.WriteLine("Unrecognized command line switch: " + args[i]);
                            break;
                        }
                    }
                    else
                    {
                        fileSpecs.Add(args[i]);
                    }
                }
            }
            Logit.OpenFile(logName);
            Logit.WriteLine("\nWordSend project sf2word compiled " + Version.date);
            if (showBanner)
            {
                Logit.WriteLine("");
                Logit.WriteLine(Version.copyright);
                Logit.WriteLine("");
                Logit.WriteLine(Version.contact);
                Logit.WriteLine(@"
Syntax:
sf2word [-o Output] [-j Job] [-t Template] [-n] [-?] [-l logname] filespec(s)
 Output = output WordML file name
 Job = name of XML job options file created with usfm2word.exe.
 Template = example WordML document with the required style definitions
 -n = don't display copyright and banner information.
 -? = cancel previous /n and show this information.
 -l = set log file name (default is WordSendLog.txt in the current directory)
 filespec = SFM file specification to read
If a JobOptions file is specified, and that file contains the input
file specifications, then filespec(s) need not be specified on the
command line. If filespec(s) or output files are specified on the
command line, then the command line overrides those specifications
in the job options file.
You may use / instead of - to introduce switches. Do not use / or
- as the first character of a file name.

");
            }

            // Read XML job options file. Note that this file is only read
            // from in the command line program, but may be
            // written to from the Windows UI version. It is reasonable to
            // set up the options the way you want them in the Windows UI
            // version of the program, then read them with this command line
            // version. We convert some command line arguments to entries
            // in this class for consistency in the handling of options
            // between the command line and Windows UI versions.
            SFConverter.jobIni = new XMLini(jobOptionsName);
            SFConverter.jobIni.WriteString("TemplateName", templateName);

            if (outName == "")
            {
                outName = SFConverter.jobIni.ReadString("outputFileName", "Output.xml");
            }
            if (templateName != "")
            {
                SFConverter.jobIni.WriteString("templateName", templateName);
            }
            if (fileSpecs.Count < 1)
            {
                int numSfmFiles = SFConverter.jobIni.ReadInt("numSfmFiles", 0);
                for (i = 0; i < numSfmFiles; i++)
                {
                    fileSpecs.Add(
                        (object)SFConverter.jobIni.ReadString("sfmFile" + i.ToString(), "*.sfm"));
                }
            }
            if (fileSpecs.Count < 1)
            {
                Logit.WriteLine("Nothing to do. No input files specified.");
            }
            else
            {
                // We don't really have a need for application options in the
                // command line program, but if we did, they would go in the
                // following place:
                // SFConverter.appIni = new XMLini(Environment.GetEnvironmentVariable("APPDATA")+"\\SIL\\WordSend\\sf2word.xml");

                // Here we instantiate the object that does most of the work.
                SFConverter.scripture = new Scriptures();

                Logit.WriteLine("Job options: " + jobOptionsName);
                Logit.WriteLine("Output file: " + outName);

                // Read the input USFM files into internal data structures.
                for (i = 0; i < fileSpecs.Count; i++)
                {
                    SFConverter.ProcessFilespec((string)fileSpecs[i]);
                }

                // Write out the WordML file.
                SFConverter.scripture.WriteToWordML(outName);
            }
            Logit.CloseFile();
        }