private void append(Map <string, float> userId2Score, string userId, float score) { if (userId2Score.size() <= 5) { userId2Score.put(userId, score); return; } userId2Score.put(userId, score); Iterator iterator = userId2Score.entrySet().iterator(); string min = ""; float minVal = 0; while (iterator.hasNext()) { Map.Entry <string, float> entry = (Map.Entry <string, float>)iterator.next(); if (TextUtils.isEmpty(min)) { min = entry.getKey(); minVal = entry.getValue(); continue; } float scoreTmp = entry.getValue(); if (scoreTmp < minVal) { min = entry.getKey(); minVal = entry.getValue(); } } userId2Score.remove(min); }
public virtual void connect() { GrammarArc[] successors = this.getSuccessors(); int num = successors.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = successors[i]; FlatLinguist.GState gstate = this.this_0.getGState(grammarArc.getGrammarNode()); if (gstate.getNode().isEmpty() || !String.instancehelper_equals(gstate.getNode().getWord().getSpelling(), "<s>")) { float num2 = grammarArc.getProbability(); if (FlatLinguist.access_800(this.this_0) && !gstate.getNode().isEmpty()) { int num3 = gstate.getNode().getWord().getPronunciations().Length; num2 -= this.this_0.logMath.linearToLog((double)num3); } float num4 = num2; Iterator iterator = this.exitPoints.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); List list = gstate.getEntryPoints((ContextPair)entry.getKey()); if (list != null) { List list2 = (List)entry.getValue(); this.connect(list2, list, num4); } } } } }
private static ConstArrayValue toUnicodeArray(Env env, ArrayValue array) { ArrayValueImpl copy = new ArrayValueImpl(); Iterator <Map.Entry <Value, Value> > iter = array.getIterator(env); while (iter.hasNext()) { Map.Entry <Value, Value> entry = iter.next(); Value key = entry.getKey(); Value value = entry.getValue(); if (key.isString()) { key = key.toUnicodeValue(env); } if (value.isString()) { value = value.toUnicodeValue(env); } copy.put(key, value); } return(new ConstArrayValue(copy)); }
public static void dumpPropStructure(ConfigurationManager cm) { Map map = ConfigurationManagerUtils.listAllsPropNames(cm); [email protected](new StringBuilder().append("Property-structure of '").append(cm.getConfigURL()).append("':").toString()); [email protected]("\nUnambiguous properties = "); Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); if (((List)entry.getValue()).size() == 1) { [email protected](new StringBuilder().append((string)entry.getKey()).append(", ").toString()); } } [email protected]("\n\nAmbiguous properties: "); iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); if (((List)entry.getValue()).size() != 1) { [email protected](new StringBuilder().append((string)entry.getKey()).append('=').toString()); Iterator iterator2 = ((List)entry.getValue()).iterator(); while (iterator2.hasNext()) { PropertySheet propertySheet = (PropertySheet)iterator2.next(); [email protected](new StringBuilder().append(propertySheet.getInstanceName()).append(", ").toString()); } [email protected](); } } }
internal virtual void setConfigurableClass(Class @class) { this.ownerClass = @class; if (this.isInstanciated()) { string text = "class is already instantiated"; throw new RuntimeException(text); } HashSet hashSet = new HashSet(); Map map = PropertySheet.parseClass(this.ownerClass); Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); try { string text2 = (string)((Field)entry.getKey()).get(null, PropertySheet.__GetCallerID()); if (!PropertySheet.assertionsDisabled && hashSet.contains(text2)) { object obj = new StringBuilder().append("duplicate property-name for different properties: ").append(text2).append(" for the class ").append(@class).toString(); throw new AssertionError(obj); } this.registerProperty(text2, new S4PropWrapper((java.lang.annotation.Annotation)entry.getValue())); hashSet.add(text2); } catch (IllegalAccessException ex) { Throwable.instancehelper_printStackTrace(ex); } continue; } }
public static string toXML(ConfigurationManager cm) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); stringBuilder.append("\n<!-- Sphinx-4 Configuration file--> \n\n"); stringBuilder.append("<config>"); Pattern pattern = Pattern.compile("\\_\\{(\\w+)\\}"); Map globalProperties = cm.getGlobalProperties(); Iterator iterator = globalProperties.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); string text = (string)entry.getKey(); Pattern pattern2 = pattern; object _ref = text; CharSequence charSequence = CharSequence.Cast(_ref); Matcher matcher = pattern2.matcher(charSequence); text = ((!matcher.matches()) ? text : matcher.group(1)); stringBuilder.append("\n\t<property name=\"").append(text).append("\" value=\"").append((string)entry.getValue()).append("\"/>"); } iterator = cm.getComponentNames().iterator(); while (iterator.hasNext()) { string text2 = (string)iterator.next(); stringBuilder.append("\n\n").append(ConfigurationManagerUtils.propSheet2XML(text2, cm.getPropertySheet(text2))); } stringBuilder.append("\n</config>"); return(stringBuilder.toString()); }
public override void putAll(Map t) { for (Iterator it = t.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry)it.next(); setAttribute(entry.getKey().ToString(), entry.getValue()); } }
public virtual void dump() { Iterator iterator = this.map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); [email protected](new StringBuilder().append(entry.getKey()).append(" ").append(entry.getValue()).toString()); } }
private void dumpCommands() { Iterator iterator = new TreeMap(this.commandList).entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); this.putResponse(new StringBuilder().append((string)entry.getKey()).append(" - ").append(((CommandInterface)entry.getValue()).getHelp()).toString()); } }
private void scheduleNextAlignment(List list, Map map, Queue queue, Queue queue2, Queue queue3, long num) { int num2 = 0; long num3 = 0L; Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); if (((Integer)entry.getKey()).intValue() - num2 > 1) { this.checkedOffer(list, queue2, queue3, queue, num2, ((Integer)entry.getKey()).intValue() + 1, num3, ((WordResult)entry.getValue()).getTimeFrame().getEnd()); } num2 = ((Integer)entry.getKey()).intValue(); num3 = ((WordResult)entry.getValue()).getTimeFrame().getStart(); } if (list.size() - num2 > 1) { this.checkedOffer(list, queue2, queue3, queue, num2, list.size(), num3, num); } }
/// <summary> /// /// </summary> /// <typeparam name="K"></typeparam> /// <typeparam name="V"></typeparam> /// <param name="javaMap"></param> /// <returns></returns> public static IDictionary <K, V> ConvertFromJavaMap <K, V>(Map javaMap) { IDictionary <K, V> result = new Dictionary <K, V>(); Iterator iterator = javaMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); result.Add((K)entry.getKey(), (V)entry.getValue()); } return(result); }
public virtual void purge() { int num = this.maxEdges - 1; Iterator iterator = this.viterbiLoserMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); List list = (List)entry.getValue(); Collections.sort(list, Scoreable.COMPARATOR); List list2 = list.subList(0, (list.size() <= num) ? list.size() : num); this.viterbiLoserMap.put(entry.getKey(), list2); } }
public override string toString() { TreeMap treeMap = new TreeMap(this.dictionary); StringBuilder stringBuilder = new StringBuilder(); Iterator iterator = treeMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); stringBuilder.append((string)entry.getKey()); stringBuilder.append(" ").append((string)entry.getValue()).append('\n'); } return(stringBuilder.toString()); }
public virtual void expand() { Iterator iterator = this.leftContexts.iterator(); while (iterator.hasNext()) { UnitContext unitContext = (UnitContext)iterator.next(); Iterator iterator2 = this.getStartingContexts().iterator(); while (iterator2.hasNext()) { UnitContext unitContext2 = (UnitContext)iterator2.next(); ContextPair contextPair = ContextPair.get(unitContext, unitContext2); this.entryPoints.put(contextPair, new ArrayList()); } } if (this.node.isFinalNode()) { GrammarState grammarState = new GrammarState(this.node); Iterator iterator3 = this.entryPoints.values().iterator(); while (iterator3.hasNext()) { List list = (List)iterator3.next(); list.add(grammarState); } } else if (!this.node.isEmpty()) { iterator = this.leftContexts.iterator(); while (iterator.hasNext()) { UnitContext unitContext = (UnitContext)iterator.next(); this.expandWord(unitContext); } } else { iterator = this.entryPoints.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); ContextPair contextPair2 = (ContextPair)entry.getKey(); List list2 = (List)entry.getValue(); BranchState branchState = new BranchState(contextPair2.getLeftContext().toString(), contextPair2.getRightContext().toString(), this.node.getID()); list2.add(branchState); this.addExitPoint(contextPair2, branchState); } } this.addEmptyEntryPoints(); }
/** * <p> * We assume here that the passed-in inner LinkedHashMaps are already sorted * in order of "Best Possible Correction". * </p> * * @param suggestions */ public PossibilityIterator(Map /*<Token, LinkedHashMap<String, Integer>>*/ suggestions) { for (var iter = suggestions.entrySet().iterator(); iter.hasNext();) { Map.Entry /*<Token, LinkedHashMap<String, Integer>>*/ entry = (Map.Entry)iter.next(); Token token = (Token)entry.getKey(); List /*<SpellCheckCorrection>*/ possibleCorrections = new ArrayList/*<SpellCheckCorrection>*/ (); for (var iter1 = ((LinkedHashMap)entry.getValue()).entrySet().iterator(); iter1.hasNext();) { Map.Entry /*<String, Integer>*/ entry1 = (Map.Entry)iter1.next(); SpellCheckCorrection correction = new SpellCheckCorrection(); correction.setOriginal(token); correction.setCorrection((string)entry1.getKey()); correction.setNumberOfOccurences((int)entry1.getValue()); possibleCorrections.add(correction); } possibilityList.add(possibleCorrections); } int wrapSize = possibilityList.size(); if (wrapSize == 0) { done = true; } else { correctionIndex = new int[wrapSize]; for (int i = 0; i < wrapSize; i++) { int suggestSize = ((List)possibilityList.get(i)).size(); if (suggestSize == 0) { done = true; break; } correctionIndex[i] = 0; } } while (internalHasNext()) { rankedPossibilityList.add(internalNext()); } Collections.sort(rankedPossibilityList); rankedPossibilityIterator = rankedPossibilityList.iterator(); }
private static PropertySheet getPropSheetInstanceFromClass(Class @class, Map map, string name, ConfigurationManager cm) { RawPropertyData rawPropertyData = new RawPropertyData(name, @class.getName()); Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); object obj = entry.getValue(); if (obj is Class) { obj = ((Class)obj).getName(); } rawPropertyData.getProperties().put(entry.getKey(), obj); } return(new PropertySheet(@class, name, cm, rawPropertyData)); }
public new virtual ConfigurationManager clone() { ConfigurationManager configurationManager = (ConfigurationManager)base.clone(); configurationManager.changeListeners = new ArrayList(); configurationManager.symbolTable = new LinkedHashMap(); Iterator iterator = this.symbolTable.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); configurationManager.symbolTable.put(entry.getKey(), ((PropertySheet)entry.getValue()).clone()); } configurationManager.globalProperties = new HashMap(this.globalProperties); configurationManager.rawPropertyMap = new HashMap(this.rawPropertyMap); return(configurationManager); }
public virtual RawPropertyData flatten(ConfigurationManager cm) { RawPropertyData rawPropertyData = new RawPropertyData(this.name, this.className); Iterator iterator = this.properties.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); object obj = entry.getValue(); if (obj is string && String.instancehelper_startsWith((string)obj, "_{")) { obj = cm.getGloPropReference(ConfigurationManagerUtils.stripGlobalSymbol((string)obj)); } rawPropertyData.properties.put(entry.getKey(), obj); } return(rawPropertyData); }
public override bool contains(Object o) { if (!(o is Map.Entry)) { return(false); } Map.Entry entry = (Map.Entry)o; Object key = entry.getKey(); Object value = entry.getValue(); if (key == null || value == null) { return(false); } return(value.Equals(_owner.get(key))); }
public override bool contains(object o) { if (!(o is Map.Entry)) { return(false); } Map.Entry e = (Map.Entry)o; object key = e.getKey(); if (key == null) { return(false); // we don't support null keys } object val = e.getValue(); object v = _map.get(key); return(v == null ? val == null : v.Equals(val)); }
public override string toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("#JSGF V1.0;").append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(this.formatComment(this.grammarDocComment)); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append("grammar ").append(this.name).append(';').append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); Set set = this.importDocComments.keySet(); for (int i = 0; i < this.__imports.size(); i++) { string text = new StringBuilder().append('<').append(((JSGFRuleName)this.__imports.get(i)).getRuleName()).append('>').toString(); if (set.contains(text)) { stringBuilder.append(this.formatComment((string)this.importDocComments.get(text))); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append("import ").append(new StringBuilder().append(text).append(';').toString()).append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); } } set = this.ruleDocComments.keySet(); Iterator iterator = this.__rules.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); object key = entry.getKey(); if (set.size() > 0 && set.contains(key)) { stringBuilder.append(this.formatComment((string)this.ruleDocComments.get(key))).append(JSGFRuleGrammar.LINE_SEPARATOR); } JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState)entry.getValue(); if (jsgfruleState.isPublic) { stringBuilder.append("public "); } stringBuilder.append('<').append(key).append("> = ").append(jsgfruleState.rule).append(';').append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); } return(stringBuilder.toString()); }
public override bool remove(Object o) { if (!(o is Map.Entry)) { return(false); } Map.Entry entry = (Map.Entry)o; Object key = entry.getKey(); Object value = entry.getValue(); if (key == null || value == null || !value.Equals(_owner.get(key))) { return(false); } return(_owner.remove(((Map.Entry)o).getKey()) != null); }
public object GetPermission(Path path) { Acl acl = path.attributes().getAcl(); if (!Acl.EMPTY.equals(acl)) { StringBuilder s = new StringBuilder(); Iterator iterator = acl.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); s.Append(String.Format("{0}{1}:{2}", s.Length == 0 ? "" : ", ", ((Acl.User)entry.getKey()).getDisplayName(), entry.getValue())); } return(s.ToString()); } Permission permission = path.attributes().getPermission(); return(permission.toString()); }
public Map <string, float> sortMapByValue(Map <string, float> oriMap, string userId, int score) { if (oriMap == null || oriMap.isEmpty()) { return(null); } Map <string, float> sortedMap = new LinkedHashMap <string, float>(); List <Map.Entry <string, float> > entryList = new ArrayList <Map.Entry <string, float> >(oriMap.entrySet()); Collections.sort(entryList, new MapValueComparator()); Iterator <Map.Entry <string, float> > iter = entryList.iterator(); Map.Entry <string, float> tmpEntry = null; while (iter.hasNext()) { tmpEntry = iter.next(); sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue()); } return(sortedMap); }
public MultipartBody(Env env, Value body) { _boundary = createBoundary(); _boundaryBytes = _boundary.getBytes(); Iterator <Map.Entry <Value, Value> > iter = body.getIterator(env); while (iter.hasNext()) { Map.Entry <Value, Value> entry = iter.next(); StringValue key = entry.getKey().ToString(env); StringValue value = entry.getValue().ToString(env); if (value.length() > 0 && value[0] == '@') { StringValue fileName = value.substring(1); string path = env.lookup(fileName); if (path == null || !path.canRead()) { env.warning(L.l("cannot read file '{0}'", fileName)); setValid(false); return; } _postItems.add(new PathEntry(env, key.ToString(), path)); } else { _postItems.add(new UrlEncodedEntry(env, key.ToString(), value)); } } _length = getContentLength(_postItems, _boundary); }
public override void commitChanges() { try { if (this.loadGrammar) { if (this.manager == null) { this.getGrammarManager(); } this.loadXML(); this.loadGrammar = false; } this.__ruleStack = new JSGFGrammar.RuleStack(this); this.newGrammar(); this.firstNode = this.createGrammarNode("<sil>"); GrammarNode grammarNode = this.createGrammarNode("<sil>"); grammarNode.setFinalNode(true); Iterator iterator = this.rules.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); JSGFGrammar.GrammarGraph grammarGraph = new JSGFGrammar.GrammarGraph(this); this.__ruleStack.push((string)entry.getKey(), grammarGraph); JSGFGrammar.GrammarGraph grammarGraph2 = this.processRule((JSGFRule)entry.getValue()); this.__ruleStack.pop(); this.firstNode.add(grammarGraph.getStartNode(), 0f); grammarGraph.getEndNode().add(grammarNode, 0f); grammarGraph.getStartNode().add(grammarGraph2.getStartNode(), 0f); grammarGraph2.getEndNode().add(grammarGraph.getEndNode(), 0f); } this.postProcessGrammar(); } catch (MalformedURLException ex) { throw new IOException(new StringBuilder().append("bad base grammar URL ").append(this.baseURL).append(' ').append(ex).toString()); } }
private void addEmptyEntryPoints() { HashMap hashMap = new HashMap(); Iterator iterator = this.entryPoints.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); ContextPair contextPair = (ContextPair)entry.getKey(); if (this.needsEmptyVersion(contextPair)) { ContextPair contextPair2 = ContextPair.get(contextPair.getLeftContext(), UnitContext.EMPTY); object obj = (List)hashMap.get(contextPair2); if ((List)obj == null) { obj = new ArrayList(); hashMap.put(contextPair2, (ArrayList)obj); } object obj2 = obj; Collection collection = (Collection)entry.getValue(); List list; if (obj2 != null) { if ((list = (obj2 as List)) == null) { throw new IncompatibleClassChangeError(); } } else { list = null; } list.addAll(collection); } } this.entryPoints.putAll(hashMap); }
internal static void renameComponent(ConfigurationManager configurationManager, string text, string text2) { if (!ConfigurationManagerUtils.assertionsDisabled && configurationManager == null) { throw new AssertionError(); } if (!ConfigurationManagerUtils.assertionsDisabled && (text == null || text2 == null)) { throw new AssertionError(); } if (configurationManager.getPropertySheet(text) == null) { string text3 = new StringBuilder().append("no configurable (to be renamed) named ").append(text).append(" is contained in the CM").toString(); throw new RuntimeException(text3); } Iterator iterator = configurationManager.getComponentNames().iterator(); while (iterator.hasNext()) { string instanceName = (string)iterator.next(); PropertySheet propertySheet = configurationManager.getPropertySheet(instanceName); Iterator iterator2 = propertySheet.getRegisteredProperties().iterator(); while (iterator2.hasNext()) { string text4 = (string)iterator2.next(); if (propertySheet.getRawNoReplacement(text4) != null) { int num = ConfigurationManagerUtils_1._SwitchMap_edu_cmu_sphinx_util_props_PropertyType[propertySheet.getType(text4).ordinal()]; if (num == 1) { List list = ConfigurationManagerUtils.toStringList(propertySheet.getRawNoReplacement(text4)); for (int i = 0; i < list.size(); i++) { string text5 = (string)list.get(i); if (String.instancehelper_equals(text5, text)) { list.set(i, text2); } } } else if (num == 2) { if (Object.instancehelper_equals(propertySheet.getRawNoReplacement(text4), text)) { propertySheet.setRaw(text4, text2); } } } } } PropertySheet propertySheet2 = configurationManager.getPropertySheet(text); propertySheet2.setInstanceName(text2); Iterator iterator3 = configurationManager.getGlobalProperties().entrySet().iterator(); while (iterator3.hasNext()) { Map.Entry entry = (Map.Entry)iterator3.next(); if (String.instancehelper_equals((string)entry.getValue(), text)) { configurationManager.setGlobalProperty((string)entry.getKey(), text2); } } }
public override void allocate() { this.vocabulary.clear(); this.logProbs.clear(); this.logBackoffs.clear(); HashMap hashMap = new HashMap(); HashMap hashMap2 = new HashMap(); HashMap hashMap3 = new HashMap(); int num = 0; Iterator iterator = this.sentences.iterator(); while (iterator.hasNext()) { string text = (string)iterator.next(); string[] array = String.instancehelper_split(text, "\\s+"); ArrayList arrayList = new ArrayList(); arrayList.add(this.dictionary.getSentenceStartWord()); string[] array2 = array; int num2 = array2.Length; for (int i = 0; i < num2; i++) { string text2 = array2[i]; if (String.instancehelper_length(text2) != 0) { this.vocabulary.add(text2); Word word = this.dictionary.getWord(text2); if (word == null) { arrayList.add(Word.__UNKNOWN); } else { arrayList.add(word); } } } arrayList.add(this.dictionary.getSentenceEndWord()); if (arrayList.size() > 0) { HashMap hashMap4 = hashMap; this.addSequence(hashMap4, new WordSequence(new Word[] { (Word)arrayList.get(0) })); num++; } if (arrayList.size() > 1) { num++; HashMap hashMap5 = hashMap; this.addSequence(hashMap5, new WordSequence(new Word[] { (Word)arrayList.get(1) })); HashMap hashMap6 = hashMap2; this.addSequence(hashMap6, new WordSequence(new Word[] { (Word)arrayList.get(0), (Word)arrayList.get(1) })); } for (int j = 2; j < arrayList.size(); j++) { num++; HashMap hashMap7 = hashMap; this.addSequence(hashMap7, new WordSequence(new Word[] { (Word)arrayList.get(j) })); HashMap hashMap8 = hashMap2; this.addSequence(hashMap8, new WordSequence(new Word[] { (Word)arrayList.get(j - 1), (Word)arrayList.get(j) })); HashMap hashMap9 = hashMap3; this.addSequence(hashMap9, new WordSequence(new Word[] { (Word)arrayList.get(j - 2), (Word)arrayList.get(j - 1), (Word)arrayList.get(j) })); } } float num3 = 0.5f; float num4 = 1f - num3; HashMap hashMap10 = new HashMap(); Iterator iterator2 = hashMap.entrySet().iterator(); while (iterator2.hasNext()) { Map.Entry entry = (Map.Entry)iterator2.next(); hashMap10.put(entry.getKey(), Float.valueOf((float)((Integer)entry.getValue()).intValue() * num4 / (float)num)); } LogMath logMath = LogMath.getLogMath(); float num5 = logMath.linearToLog((double)this.unigramWeight); float num6 = logMath.linearToLog((double)(1f - this.unigramWeight)); float num7 = -logMath.linearToLog((double)hashMap10.size()); TreeSet treeSet = new TreeSet(hashMap.keySet()); Iterator iterator3 = new TreeSet(hashMap2.keySet()).iterator(); WordSequence wordSequence = (!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next()); Iterator iterator4 = treeSet.iterator(); while (iterator4.hasNext()) { WordSequence wordSequence2 = (WordSequence)iterator4.next(); float num8 = logMath.linearToLog((double)((Float)hashMap10.get(wordSequence2)).floatValue()); num8 += num5; num8 = logMath.addAsLinear(num8, num7 + num6); this.logProbs.put(wordSequence2, Float.valueOf(num8)); float num9 = 0f; while (wordSequence != null) { int num10 = wordSequence.getOldest().compareTo(wordSequence2); if (num10 > 0) { break; } if (num10 == 0) { num9 += ((Float)hashMap10.get(wordSequence.getNewest())).floatValue(); } wordSequence = ((!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next())); } this.logBackoffs.put(wordSequence2, Float.valueOf(logMath.linearToLog((double)(num3 / (1f - num9))))); } HashMap hashMap11 = new HashMap(); Iterator iterator5 = hashMap2.entrySet().iterator(); while (iterator5.hasNext()) { Map.Entry entry2 = (Map.Entry)iterator5.next(); int num11 = ((Integer)hashMap.get(((WordSequence)entry2.getKey()).getOldest())).intValue(); hashMap11.put(entry2.getKey(), Float.valueOf((float)((Integer)entry2.getValue()).intValue() * num4 / (float)num11)); } TreeSet treeSet2 = new TreeSet(hashMap2.keySet()); iterator3 = new TreeSet(hashMap3.keySet()).iterator(); wordSequence = ((!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next())); Iterator iterator6 = treeSet2.iterator(); while (iterator6.hasNext()) { WordSequence wordSequence3 = (WordSequence)iterator6.next(); this.logProbs.put(wordSequence3, Float.valueOf(logMath.linearToLog((double)((Float)hashMap11.get(wordSequence3)).floatValue()))); float num12 = 0f; while (wordSequence != null) { int num13 = wordSequence.getOldest().compareTo(wordSequence3); if (num13 > 0) { break; } if (num13 == 0) { num12 += ((Float)hashMap11.get(wordSequence.getNewest())).floatValue(); } wordSequence = ((!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next())); } this.logBackoffs.put(wordSequence3, Float.valueOf(logMath.linearToLog((double)(num3 / (1f - num12))))); } iterator6 = hashMap3.entrySet().iterator(); while (iterator6.hasNext()) { Map.Entry entry3 = (Map.Entry)iterator6.next(); float num12 = (float)((Integer)entry3.getValue()).intValue() * num4; num12 /= (float)((Integer)hashMap2.get(((WordSequence)entry3.getKey()).getOldest())).intValue(); this.logProbs.put(entry3.getKey(), Float.valueOf(logMath.linearToLog((double)num12))); } }
private void checkClasses() { HashMap hashMap = new HashMap(); Iterator iterator = this.wordToClassProbabilities.values().iterator(); while (iterator.hasNext()) { ClassProbability classProbability = (ClassProbability)iterator.next(); Float @float = (Float)hashMap.get(classProbability.getClassName()); if (@float == null) { hashMap.put(classProbability.getClassName(), Float.valueOf(0f)); } else { hashMap.put(classProbability.getClassName(), Float.valueOf((float)this.logMath.logToLinear(classProbability.getLogProbability()) + @float.floatValue())); } } iterator = hashMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); if (Math.abs((double)1f - (double)((Float)entry.getValue()).floatValue()) > 0.001) { this.logger.warning(new StringBuilder().append("Word probabilities for class ").append((string)entry.getKey()).append(" sum to ").append(entry.getValue()).toString()); } } }