[sword-svn] r301 - trunk/modules/crossreferences
refdoc at crosswire.org
refdoc at crosswire.org
Tue Aug 24 01:24:22 MST 2010
Author: refdoc
Date: 2010-08-24 01:24:22 -0700 (Tue, 24 Aug 2010)
New Revision: 301
Modified:
trunk/modules/crossreferences/xreffix.pl
Log:
using now perl bindings successfully. Speed gone up from 1hr to <1 sec for average whole OSIS Bible on my laptop
Many thanks Greg!
Modified: trunk/modules/crossreferences/xreffix.pl
===================================================================
--- trunk/modules/crossreferences/xreffix.pl 2010-08-18 21:22:27 UTC (rev 300)
+++ trunk/modules/crossreferences/xreffix.pl 2010-08-24 08:24:22 UTC (rev 301)
@@ -37,21 +37,19 @@
## sword-support at crosswire.org
#########################################################################
-sub vs2osis {
+use Sword;
- my $return = `vs2osisref "$_[0]" "$_[1]" $_[2]`;
- $return =~ s/\n$//;
- $return;
-}
-$version = "1.0";
+
+$version = "1.1";
$osisVersion = "2.1.1";
$date = '$Date: 2010-08-04 05:46:26 +0000 (Tue, 04 Aug 2009) $';
$rev = '$Rev: 231 $';
+$mgr = new Sword::SWMgr();
+$module = $mgr->getModule('KJV');
-
if (scalar(@ARGV) < 2) {
print "xreffix.pl -- fixes crossreferences in OSIS files where usfm2osis.pl has failed. version $version\nRevision $rev ($date)\nSyntax: xreffix.pl <input filename> [-o <output-file>] [-l <xreflocale>].\n";
exit (-1);
@@ -72,6 +70,9 @@
else {
$locale = "en";
}
+
+Sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName($locale);
+
open (OUTF, ">", "$outputFilename") or die "Could not open file $outputFilename for writing.";
open (INF, "<", $ARGV[0]);
@@ -79,25 +80,29 @@
close (INF);
$c_book = "Gen";
-$c_chapter="1"
+$c_chapter="1";
foreach (@data) {
if (/xml:lang\=\"(.+?)\"/) {
- $locale=$1;
- print "This document is in the locale of ".$locale."\n";
- }
+ if ($locale ne $1) {
+ print "This document is in the locale of ".$1."\n";
+ Sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName($1);
+ }
+
+ }
if (/<div\ type\=\"book\"\ osisID=\"(.+?)\">/) {
$c_book=$1;
print "\n"."Now working on ".$c_book."\n";
- }
+ }
if (/<chapter\ sID\=\".*?\.([0-9]+)\"/) {
$c_chapter=$1;
print ".";
- }
-
- s/<reference>(.*?)<\/reference>/&vs2osis($1,$c_book.$c_chapter,$locale)/eg;
}
+ my $scope= new Sword::VerseKey;
+ $scope->setText($c_book.$c_chapter);
+ s/<reference>(.*?)<\/reference>/Sword::VerseKey::convertToOSIS($1, $scope)/eg;
+ }
print (OUTF @data);
close OUTF;
\ No newline at end of file
More information about the sword-cvs
mailing list