use of com.tyndalehouse.step.core.models.search.SearchEntry in project step by STEPBible.
the class AnalysisServiceImpl method getSubjectStats.
/**
* Subject stats.
*
* @param version the version
* @param reference the reference
* @param scopeType
* @return the passage stat
*/
private PassageStat getSubjectStats(final String version, final String reference, final ScopeType scopeType) {
final SearchResult subjectResults = this.subjects.searchByReference(getReferenceSyntax(reference, version, scopeType));
final PassageStat stat = new PassageStat();
// we duplicate the set here because we'd like to keep the casing...
final List<SearchEntry> results = subjectResults.getResults();
for (final SearchEntry entry : results) {
if (entry instanceof ExpandableSubjectHeadingEntry) {
final ExpandableSubjectHeadingEntry subjectEntry = (ExpandableSubjectHeadingEntry) entry;
// we will first do the subheading because ideally we want that 'case' to be the master case,
// i.e. David rather than DAVID
final String subjectHeading = subjectEntry.getHeading();
if (subjectHeading != null && !stopSubjects.contains(subjectHeading.toUpperCase())) {
stat.addWordTryCases(CLEAN_UP_DIGITS.matcher(subjectHeading).replaceAll(""));
}
final String root = subjectEntry.getRoot();
if (root != null && !stopSubjects.contains(root.toUpperCase())) {
stat.addWordTryCases(CLEAN_UP_DIGITS.matcher(root).replaceAll(root));
}
}
}
return stat;
}
use of com.tyndalehouse.step.core.models.search.SearchEntry in project step by STEPBible.
the class JSwordSearchServiceImpl method getPassagesForResults.
/**
* Looks up all passages represented by the key
*
* @param result the results that we will be returning
* @param versions the bibles under examination
* @param results the list of results
* @param context amount of context to add
* @param options to use to lookup the right parameterization of the text
* @return the list of entries found
*/
private void getPassagesForResults(SearchResult result, String[] versions, final Key results, final int context, final List<LookupOption> options, String interlinearMode) {
final List<SearchEntry> resultPassages = new ArrayList<SearchEntry>();
final Iterator<Key> iterator = ((Passage) results).iterator();
boolean interlinearModeCaptured = false;
int count = 0;
while (iterator.hasNext()) {
final Key verse = iterator.next();
final Key lookupKey;
if (verse instanceof Verse) {
// then we need to make it into a verse range
final Verse verseAsVerse = (Verse) verse;
final VerseRange vr = new VerseRange(verseAsVerse.getVersification(), verseAsVerse);
vr.blur(context, RestrictionType.NONE);
lookupKey = vr;
} else {
// assume blur is supported
verse.blur(context, RestrictionType.NONE);
lookupKey = verse;
}
if (count == 1) {
options.add(LookupOption.HIDE_COMPARE_HEADERS);
}
// TODO this is not very efficient so requires refactoring
final OsisWrapper peakOsisText = this.jsword.peakOsisText(versions, lookupKey, options, interlinearMode);
resultPassages.add(new VerseSearchEntry(peakOsisText.getReference(), peakOsisText.getValue(), peakOsisText.getOsisId()));
if (!interlinearModeCaptured) {
result.setInterlinearMode(peakOsisText.getInterlinearMode());
interlinearModeCaptured = true;
}
count++;
}
result.setResults(resultPassages);
}
use of com.tyndalehouse.step.core.models.search.SearchEntry in project step by STEPBible.
the class SearchServiceImpl method buildTimelineSearchResults.
/**
* Construct the relevant entity structure to represent timeline search results
*
* @param sq the search query
* @param events the list of events retrieved
* @return the search results
*/
private SearchResult buildTimelineSearchResults(final SearchQuery sq, final EntityDoc[] events) {
final List<SearchEntry> results = new ArrayList<SearchEntry>();
final SearchResult r = new SearchResult();
r.setResults(results);
for (final EntityDoc e : events) {
final String refs = e.get("storedReferences");
final String[] references = StringUtils.split(refs);
final List<VerseSearchEntry> verses = new ArrayList<VerseSearchEntry>();
// TODO FIXME: REFACTOR to only make 1 jsword call?
for (final String ref : references) {
// TODO: REFACTOR only supports one version lookup
final VerseSearchEntry verseEntry = new VerseSearchEntry();
verses.add(verseEntry);
}
final TimelineEventSearchEntry entry = new TimelineEventSearchEntry();
entry.setId(e.get("id"));
entry.setDescription(e.get("name"));
entry.setVerses(verses);
results.add(entry);
}
return r;
}
use of com.tyndalehouse.step.core.models.search.SearchEntry in project step by STEPBible.
the class JSwordSearchServiceImplTest method testMorphology.
/**
* Random tests
*/
@Test
public void testMorphology() {
final List<SearchEntry> results = this.search.search(new SearchQuery("+[Mat-Rev] +morph:G2570*A-NSM*", new String[] { "KJV" }, "true", 0, 1, 1000000, null), "ESV_th").getResults();
for (SearchEntry result : results) {
LOGGER.info(((VerseSearchEntry) result).getKey());
}
assertFalse(results.isEmpty());
}
use of com.tyndalehouse.step.core.models.search.SearchEntry in project step by STEPBible.
the class JSwordSearchServiceImplTest method testGood.
/**
* Random tests
*/
@Test
public void testGood() {
final List<SearchEntry> results = this.search.search(new SearchQuery("+[Mat-Rev] good~", new String[] { "ESV_th" }, "true", 0, 1, 1000000, null), "ESV_th").getResults();
for (SearchEntry result : results) {
LOGGER.trace(((VerseSearchEntry) result).getKey());
}
assertFalse(results.isEmpty());
}
Aggregations