Search in sources :

Example 6 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class MorphologyServiceImpl method getDisplayMorphology.

/**
 * @param code the code encountered during the xsl transformation
 * @return the string to be displayed to the user
 */
public String getDisplayMorphology(final String code) {
    final List<EntityDoc> morphologies = getMorphology(code);
    final StringBuilder sb = new StringBuilder(128);
    for (final EntityDoc m : morphologies) {
        sb.append(m.get("inlineHtml"));
        sb.append(NON_BREAKING_SPACE);
    }
    return sb.toString();
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc)

Example 7 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class SearchQuery method setDefinitions.

/**
 * Gives the search query a bunch of definitions that have been found, using it in a "session" fashion.
 *
 * @param definitions the list of definitions.
 */
public void setDefinitions(final EntityDoc[] definitions) {
    final List<EntityDoc> list = new ArrayList<EntityDoc>(definitions.length);
    for (final EntityDoc d : definitions) {
        list.add(d);
    }
    this.definitions = list;
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) ArrayList(java.util.ArrayList)

Example 8 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class OriginalWordSuggestionServiceImpl method getMatchingAllForms.

/**
 * retrieves forms from the lexicon
 *
 * @param greek true to indicate greek, false to indicate hebrew
 * @param form  form in lower case, containing a % if appropriate
 * @return the list of suggestions
 */
private List<LexiconSuggestion> getMatchingAllForms(final boolean greek, final String form) {
    final List<LexiconSuggestion> suggestions = new ArrayList<LexiconSuggestion>();
    final EntityDoc[] results;
    // search by unicode or translit?
    if (isHebrewText(form) || GreekUtils.isGreekText(form)) {
        results = this.specificForms.search(new String[] { "accentedUnicode" }, QueryParser.escape(form) + '*', getFilter(greek), TRANSLITERATION_SORT, true, SearchService.MAX_SUGGESTIONS);
    } else {
        // assume transliteration - at this point suggestionType is not going to be MEANING
        final String simplifiedTransliteration = getSimplifiedTransliterationClause(greek, form, true);
        results = this.specificForms.search(new String[] { "simplifiedStepTransliteration" }, simplifiedTransliteration, getFilter(greek), TRANSLITERATION_SORT, true, simplifiedTransliteration, SearchService.MAX_SUGGESTIONS);
    }
    for (final EntityDoc f : results) {
        final LexiconSuggestion suggestion = convertToSuggestionFromSpecificForm(f);
        if (suggestion != null) {
            suggestions.add(suggestion);
        }
    }
    return suggestions;
}
Also used : LexiconSuggestion(com.tyndalehouse.step.core.models.LexiconSuggestion) ArrayList(java.util.ArrayList) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc)

Example 9 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc 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 10 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class SearchServiceImpl method filterDefinitions.

/**
 * Keep definitions that are of current interest to the user... Remove all others
 *
 * @param sq                 the search criteria
 * @param lexiconDefinitions the definitions
 * @return a list of definitions to be included in the filter
 */
private List<EntityDoc> filterDefinitions(final SearchQuery sq, final List<EntityDoc> lexiconDefinitions) {
    final String[] originalFilter = sq.getCurrentSearch().getOriginalFilter();
    if (originalFilter == null || originalFilter.length == 0) {
        return lexiconDefinitions;
    }
    // bubble intersection, acceptable, because we're only dealing with a handful of definitions
    final List<EntityDoc> keep = new ArrayList<EntityDoc>(lexiconDefinitions.size());
    for (final EntityDoc def : lexiconDefinitions) {
        for (final String filteredValue : originalFilter) {
            if (def.get("strongNumber").equals(filteredValue)) {
                keep.add(def);
                // break out of filterValues loop, and proceed with next definition
                break;
            }
        }
    }
    return keep;
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) ArrayList(java.util.ArrayList)

Aggregations

EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)39 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)5 TranslatedException (com.tyndalehouse.step.core.exceptions.TranslatedException)5 LexiconSuggestion (com.tyndalehouse.step.core.models.LexiconSuggestion)5 ParseException (org.apache.lucene.queryParser.ParseException)5 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)4 IOException (java.io.IOException)4 MultiFieldQueryParser (org.apache.lucene.queryParser.MultiFieldQueryParser)4 Query (org.apache.lucene.search.Query)4 BookAndBibleCount (com.tyndalehouse.step.core.models.search.BookAndBibleCount)3 SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)3 SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)3 QueryParser (org.apache.lucene.queryParser.QueryParser)3 Key (org.crosswire.jsword.passage.Key)3 ExpandableSubjectHeadingEntry (com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)2 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)2 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)2