public int getCardinality() { int cardinality = 1; // count this node for (Key child : children) { cardinality += child.getCardinality(); } return cardinality; }
public int getCardinality() { return keys.getCardinality(); }
public Key search(Book bible, String searchText) throws BookException { // example of fetching Strongs ref - only works with downloaded indexes! // Book book = getDocumentByInitials("KJV"); // Key key1 = book.find("strong:h3068"); // System.out.println("h3068 result count:"+key1.getCardinality()); Log.d(TAG, "Searching:"+bible+" Search term:" + searchText); // This does a standard operator search. See the search // documentation for more examples of how to search Key key = bible.find(searchText); //$NON-NLS-1$ Log.d(TAG, "There are "+key.getCardinality()+" verses containing " + searchText); return key; }
/** ensure a book is indexed and the index contains typical Greek or Hebrew Strongs Numbers */ private boolean checkStrongs(Book bible) { try { return bible.getIndexStatus().equals(IndexStatus.DONE) && (bible.find("+[Gen 1:1] strong:h7225").getCardinality()>0 || bible.find("+[John 1:1] strong:g746").getCardinality()>0 || bible.find("+[Gen 1:1] strong:g746").getCardinality()>0); } catch (BookException be) { Log.e(TAG, "Error checking strongs numbers", be); return false; } }
/** * Determine the size of this reference. * * @param bookInitials * the book to which the reference applies. * @param reference * the actual reference * @return the number of entries for this reference. * @throws NoSuchKeyException */ public int getCardinality(String bookInitials, String reference) throws NoSuchKeyException { Book book = BookInstaller.getInstalledBook(bookInitials); if (book != null) { Key key = book.getKey(reference); return key.getCardinality(); } return 0; }
@Test public void testSongOfSongsBook() { final Key key = passageReader.getKey("Song"); assertThat(key.getCardinality(), greaterThan(100)); } }
/** * various names were use for Song of Songs - check which is correct. */ @Test public void testSongOfSongsChapter() { final Key key = passageReader.getKey("Song.8"); assertThat(key.getCardinality(), greaterThan(10)); }
@Test public void testSongOfSongsChapters() { final Key key = passageReader.getKey("Song.1-Song.3"); assertThat(key.getCardinality(), greaterThan(30)); }
/** do the search query and prepare results in lists ready for display * */ public SearchResultsDto getSearchResults(String document, String searchText) throws BookException { Log.d(TAG, "Preparing search results"); SearchResultsDto searchResults = new SearchResultsDto(); // search the current book Book book = swordDocumentFacade.getDocumentByInitials(document); Key result = swordContentFacade.search(book, searchText); if (result!=null) { int resNum = result.getCardinality(); Log.d(TAG, "Number of results:"+resNum); //if Bible or commentary then filter out any non Scripture keys, otherwise don't filter boolean isBibleOrCommentary = book instanceof AbstractPassageBook; for (int i=0; i<Math.min(resNum, MAX_SEARCH_RESULTS+1); i++) { Key key = result.get(i); boolean isMain = (!isBibleOrCommentary || Scripture.isScripture(((Verse)key).getBook())); searchResults.add(key, isMain); } } return searchResults; }
/** * This is a heuristic that tries out the key. * * @return true if there were no exceptions in reading the enciphered * module. */ private boolean isUnlockKeyValid() { try { Key key = getGlobalKeyList(); if (key == null) { // weird key == null, assume it is valid return true; } if (key.getCardinality() > 0) { key = key.get(0); } getOsis(key, new NoOpRawTextProcessor()); return true; } catch (BookException ex) { return false; } }
public void testFindAllStrongsRef() { List<Book> bibles = Books.installed().getBooks(BookFilters.getBibles()); for (Book book : bibles) { try { if (book.hasFeature(FeatureType.STRONGS_NUMBERS)) { if (!book.getIndexStatus().equals(IndexStatus.DONE)) { System.out.println("Unindexed:"+book); } else { Key resultsH = book.find("+[Gen 1:1] strong:h7225"); //beginning Key resultsG = book.find("+[John 1:1] strong:g746"); //beginning Key resultsGOT = book.find("+[Gen 1:1] strong:g746"); //beginning if (resultsH.getCardinality()==0 && resultsG.getCardinality()==0 && resultsGOT.getCardinality()==0) { System.out.println("No refs returned in"+book.getInitials()); } else { System.out.println("Ok:"+book.getInitials()+" "+resultsH.getCardinality()+"/"+resultsG.getCardinality()+ "/" + resultsGOT.getCardinality()); } // assertTrue("No refs returned in"+book.getInitials(), resultsH.getCardinality()>0 || resultsG.getCardinality()>0); } } } catch (Exception e) { System.out.println("Error:"+book.getInitials()+":"+e.getMessage()); } } }
int total = results.getCardinality(); int partial = total;
Field morphologyField = new Field(FIELD_MORPHOLOGY , "", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO); int size = key.getCardinality(); int subCount = count; log.debug("Number of keys = {}", Integer.toString(size));
if (start > 0 || key.getCardinality() > count) { key = book.createEmptyKeyList(); int i = 0;