/** * Check the helpers currently stored in the helper cache to see if any of them can handle the * sequence we've just been given. This avoids pinging the belief network context to get a helper * list. */ public static Class find_helper_class1( Vector seq, String helper_type, int[] max_class_score, int[] max_count_score) throws ClassNotFoundException { int[] class_score1 = new int[1], count_score1 = new int[1]; max_class_score[0] = -1; max_count_score[0] = -1; Class cmax_score = null; for (Enumeration e = helper_cache.keys(); e.hasMoreElements(); ) { try { HelperCacheKey key = (HelperCacheKey) e.nextElement(); if (!key.helper_type.equals(helper_type)) continue; Class c = (Class) helper_cache.get(key); SeqTriple[] sm = (SeqTriple[]) invoke_description(c); if (sm == null) continue; // apparently not a helper class if (MatchClassPattern.matches(sm, seq, class_score1, count_score1)) { if (class_score1[0] > max_class_score[0] || (class_score1[0] == max_class_score[0] && count_score1[0] > max_count_score[0])) { cmax_score = c; max_class_score[0] = class_score1[0]; max_count_score[0] = count_score1[0]; } } } catch (Exception e2) { } // eat it; stagger forward } if (Global.debug > 1) System.err.println( "PiHelperLoader.find_helper_class1: helper " + (cmax_score == null ? "is NOT" : "is") + " in cache."); if (cmax_score == null) // no luck; try to get a helper list from the bnc & plunge ahead return find_helper_class0(seq, helper_type, max_class_score, max_count_score); else // success! return cmax_score; }