Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Book Names #14

Merged
merged 8 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.crosswire</groupId>
<artifactId>jsword</artifactId>
<packaging>jar</packaging>
<version>1.6.6-SNAPSHOT</version>
<version>1.6.7-SNAPSHOT</version>
<name>jsword</name>
<url>http://maven.apache.org</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ public enum BibleBook {
// Other books
ADD_DAN("AddDan"),
ADD_PS("AddPs"),
ESTH_GR("EsthGr");
ESTH_GR("EsthGr"),
// SM - Added based on Dr, David's input
MEQ1("1Meq"),
MEQ2("2Meq"),
MEQ3("3Meq"),
BAR3("3Bar");

BibleBook(String osis, boolean shortBook) {
this(osis);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/crosswire/jsword/versification/BibleNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ private NameList getBibleNamesForLocale(Locale locale) {
return bibleNames;
}

public String getShortBibleNameForLocale(Locale locale, String bName) {
String name = bName;
BibleBook bBk = getBook(bName);
if (bBk != null) {
NameList names = getBibleNamesForLocale(locale);
BookName bookName = names.books.get(bBk);
if (bookName != null) {
name = bookName.getShortName();
}
}

return name;
}

/**
* This is simply a convenience function to wrap Character.isLetter()
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class VersificationToKJVMapper {
* @param mapping the mappings from one versification to another
*/
public VersificationToKJVMapper(Versification nonKjv, final FileVersificationMapping mapping) {
absentVerses = createEmptyPassage(KJV);
absentVerses = createEmptyPassage(KJVAPlus);
toKJVMappings = new HashMap<VerseKey, List<QualifiedKey>>();
fromKJVMappings = new HashMap<QualifiedKey, Passage>();
this.nonKjv = nonKjv;
Expand Down Expand Up @@ -182,7 +182,7 @@ private void processEntry(final KeyValuePair entry) throws NoSuchKeyException {

// The right hand side can start with ? which means that the left maps to nothing in the KJV.
// The ? leads a section name
QualifiedKey kjv = getRange(KJV, kjvHand, left.getKey());
QualifiedKey kjv = getRange(KJVAPlus, kjvHand, left.getKey());
addMappings(left, kjv);
}

Expand Down Expand Up @@ -540,7 +540,7 @@ public List<QualifiedKey> map(QualifiedKey qualifiedKey) {
//then we found no mapping, so we're essentially going to return the same key back...
//unless it's a verse 0 and then we'll check the global flag.
kjvKeys = new ArrayList<QualifiedKey>();
kjvKeys.add(qualifiedKey.reversify(KJV));
kjvKeys.add(qualifiedKey.reversify(KJVAPlus));
return kjvKeys;
}
return kjvKeys;
Expand Down Expand Up @@ -568,7 +568,7 @@ public VerseKey unmap(final QualifiedKey kjvVerse) {
if (left == null) {
VerseKey vk = kjvVerse.getKey();
if (vk != null && this.absentVerses.contains(vk)) {
return createEmptyPassage(KJV);
return createEmptyPassage(KJVAPlus);
}
return kjvVerse.reversify(this.nonKjv).getKey();
}
Expand Down Expand Up @@ -611,7 +611,7 @@ public void dump(PrintStream out) {
List<QualifiedKey> kjvVerses = entry.getValue();
String osisRef = entry.getKey().getOsisRef();
for (QualifiedKey q : kjvVerses) {
out.println(String.format("\t(%s) %s => (KJV) %s",
out.println(String.format("\t(%s) %s => (Mapper) %s",
nonKjvName,
osisRef,
q.toString()));
Expand All @@ -625,7 +625,7 @@ public void dump(PrintStream out) {
out.println(" Backwards mappings from KJV");
out.println(" ******************************");
for (Map.Entry<QualifiedKey, Passage> entry : this.fromKJVMappings.entrySet()) {
out.println(String.format("\t(KJV): %s => (%s) %s",
out.println(String.format("\t(Mapper): %s => (%s) %s",
entry.getKey().toString(),
nonKjvName,
entry.getValue().getOsisRef()));
Expand Down Expand Up @@ -659,6 +659,6 @@ private Passage createEmptyPassage(Versification versification) {

private OsisParser osisParser = new OsisParser();

private static final Versification KJV = Versifications.instance().getVersification(Versifications.DEFAULT_V11N);
private static final Versification KJVAPlus = Versifications.instance().getVersification(Versifications.KJVAPLUS_V11N);
private static final Logger LOGGER = LoggerFactory.getLogger(VersificationToKJVMapper.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public final class VersificationsMapper {
private VersificationsMapper() {
// we have no mapper for the KJV, since everything maps map to the KJV, so we'll simply add an entry
// in there to avoid ever trying to load it
MAPPERS.put(KJV, null);
MAPPERS.put(KJVAPlus, null);
}

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ public VerseKey mapVerse(Verse v, Versification targetVersification) {
// and assume that it maps directly on to the KJV,
// and thereby continue with the process
kjvVerses = new ArrayList<QualifiedKey>();
final Verse reversifiedVerse = v.reversify(KJV);
final Verse reversifiedVerse = v.reversify(KJVAPlus);
//check that the key actually exists
if(reversifiedVerse != null) {
kjvVerses.add(new QualifiedKey(reversifiedVerse));
Expand All @@ -145,9 +145,9 @@ public VerseKey mapVerse(Verse v, Versification targetVersification) {
kjvVerses = mapper.map(new QualifiedKey(v));
}

if (KJV.equals(targetVersification)) {
if (KJVAPlus.equals(targetVersification)) {
// we're done, so simply return the key we have so far.
return getKeyFromQualifiedKeys(KJV, kjvVerses);
return getKeyFromQualifiedKeys(KJVAPlus, kjvVerses);
}

// we're continuing, so we need to unmap from the KJV qualified key onto
Expand Down Expand Up @@ -256,7 +256,7 @@ private void ensure(final Versification versification) {
}

private static volatile VersificationsMapper instance;
private static final Versification KJV = Versifications.instance().getVersification(Versifications.DEFAULT_V11N);
private static final Versification KJVAPlus = Versifications.instance().getVersification(Versifications.KJVAPLUS_V11N);
private static final Map<Versification, VersificationToKJVMapper> MAPPERS = new HashMap<Versification, VersificationToKJVMapper>();
private static final Logger LOGGER = LoggerFactory.getLogger(VersificationsMapper.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.crosswire.common.util.CWProject;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.JSMsg;
import org.crosswire.jsword.JSOtherMsg;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
Expand Down Expand Up @@ -49,7 +52,14 @@ public void loadFromJSON(final byte[] jsonData ) throws NoSuchKeyException, Book
SystemCustomVersification.BOOKS_OT = new BibleBook[v11n.otbooks.length - 1];
SystemCustomVersification.LAST_VERSE_OT = new int[v11n.otbooks.length - 1][];
for(int i = 0; i < v11n.otbooks.length - 1; i++){
SystemCustomVersification.BOOKS_OT[i] = BibleBook.fromOSIS(v11n.otbooks[i].osis);
BibleBook bb = BibleBook.fromOSIS(v11n.otbooks[i].osis);
if(bb == null)
{
Reporter.informUser(this, new BookException(JSMsg.gettext("Invalid OSIS name: {0}", v11n.otbooks[i].osis)));
return;
}
SystemCustomVersification.BOOKS_OT[i] = bb;
//SystemCustomVersification.BOOKS_OT[i] = BibleBook.fromOSIS(v11n.otbooks[i].osis);
SystemCustomVersification.LAST_VERSE_OT[i] = new int[v11n.otbooks[i].chapmax];
System.arraycopy( v11n.vm, vmIndex, SystemCustomVersification.LAST_VERSE_OT[i], 0, v11n.otbooks[i].chapmax);
vmIndex += v11n.otbooks[i].chapmax;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ public class SystemDefault extends Versification {
BibleBook.PR_MAN,
BibleBook.MACC1,
BibleBook.MACC2,
BibleBook.ESTH_GR,
BibleBook.PSALM_SOL,
BibleBook.MACC3,
BibleBook.MACC4,
BibleBook.ADD_PS,
BibleBook.EN1,
BibleBook.ODES,
BibleBook.MEQ1,
BibleBook.MEQ2,
BibleBook.MEQ3,
BibleBook.T12PATR,
BibleBook.JUBS,
BibleBook.BAR2,
BibleBook.BAR3,
BibleBook.BAR4,
BibleBook.EP_LAO,
};

/* protected */ static final BibleBook[] BOOKS_OT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SystemKJV extends Versification {

public static final String V11N_NAME = "KJV";

/* protected */ static final BibleBook[] BOOKS_OT = SystemDefault.BOOKS_OTA;
/* protected */ static final BibleBook[] BOOKS_OT = SystemDefault.BOOKS_OT;

/* protected */ static final BibleBook[] BOOKS_NT = SystemDefault.BOOKS_NT;

Expand Down Expand Up @@ -278,74 +278,6 @@ public class SystemKJV extends Versification {
{
14, 17, 18, 6,
},
// I Esdras
{
58, 30, 24, 63, 73, 34, 15, 96, 55,
},
// II Esdras
{
40, 48, 36, 52, 56, 59, 70, 63, 47, 59,
46, 51, 58, 48, 63, 78,
},
// Tobit
{
22, 14, 17, 21, 22, 17, 18, 21, 6, 12,
19, 22, 18, 15,
},
// Judith
{
16, 28, 10, 15, 24, 21, 32, 36, 14, 23,
23, 20, 20, 19, 13, 25,
},
// Additions to Esther
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 13,
12, 6, 18, 19, 16, 24,
},
// Wisdom
{
16, 24, 19, 20, 23, 25, 30, 21, 18, 21,
26, 27, 19, 31, 19, 29, 21, 25, 22,
},
// Sirach
{
30, 18, 31, 31, 15, 37, 36, 19, 18, 31,
34, 18, 26, 27, 20, 30, 32, 33, 30, 32,
28, 27, 28, 34, 26, 29, 30, 26, 28, 25,
31, 24, 31, 26, 20, 26, 31, 34, 35, 30,
24, 25, 33, 22, 26, 20, 25, 25, 16, 29,
30,
},
// Baruch
{
22, 35, 37, 37, 9, 73,
},
// Prayer of Azariah
{
68,
},
// Susanna
{
64,
},
// Bel and the Dragon
{
42,
},
// Prayer of Manasses
{
1,
},
// I Maccabees
{
64, 70, 60, 61, 68, 63, 50, 32, 73, 89,
74, 53, 53, 49, 41, 24,
},
// II Maccabees
{
36, 32, 40, 50, 27, 31, 42, 36, 29, 38,
38, 45, 26, 46, 39,
},
};


Expand Down
Loading