/** * Get the top few clauses from this searcher, cutting off at the given minimum probability. * * @param thresholdProbability The threshold under which to stop returning clauses. This should be * between 0 and 1. * @return The resulting {@link edu.stanford.nlp.naturalli.SentenceFragment} objects, representing * the top clauses of the sentence. */ public List<SentenceFragment> topClauses(double thresholdProbability) { List<SentenceFragment> results = new ArrayList<>(); search( triple -> { assert triple.first <= 0.0; double prob = Math.exp(triple.first); assert prob <= 1.0; assert prob >= 0.0; assert !Double.isNaN(prob); if (prob >= thresholdProbability) { SentenceFragment fragment = triple.third.get(); fragment.score = prob; results.add(fragment); return true; } else { return false; } }); return results; }
// Click public void onClick(View view) { // Info populating if (m_info == null) GetInfo(); assert (m_info != null); // Sentence Bundle next_state = new Bundle(); next_state.putInt(SentenceFragment.STATE_WORD_ID, m_info.Id()); Fragment fragment = SentenceFragment.create(next_state); // Fragment FragmentTransaction ft = m_activity.getFragmentManager().beginTransaction(); ft.replace(R.id.container, fragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); }