Search in sources :

Example 1 with SearchEntry

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;
}
Also used : PassageStat(com.tyndalehouse.step.core.models.stats.PassageStat) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) ExpandableSubjectHeadingEntry(com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)

Example 2 with SearchEntry

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);
}
Also used : VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper)

Example 3 with SearchEntry

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;
}
Also used : TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) ArrayList(java.util.ArrayList) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) KeyedSearchResultSearchEntry(com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry) TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) LexicalSearchEntry(com.tyndalehouse.step.core.models.search.LexicalSearchEntry)

Example 4 with SearchEntry

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());
}
Also used : SearchQuery(com.tyndalehouse.step.core.service.impl.SearchQuery) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) Test(org.junit.Test)

Example 5 with SearchEntry

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());
}
Also used : SearchQuery(com.tyndalehouse.step.core.service.impl.SearchQuery) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) Test(org.junit.Test)

Aggregations

SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)8 SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)5 VerseSearchEntry (com.tyndalehouse.step.core.models.search.VerseSearchEntry)5 EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)3 ExpandableSubjectHeadingEntry (com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)3 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)3 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 TimelineEventSearchEntry (com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry)2 OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)1 KeyedSearchResultSearchEntry (com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry)1 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)1 PassageStat (com.tyndalehouse.step.core.models.stats.PassageStat)1