public void ContainsReturnsFalseIfTheKeyIsMissing() { var lex = new Lexicon { { ScalarDoubleValue.MinValue(), new StringValue("bar") } }; Assert.IsFalse(lex.ContainsKey(ScalarDoubleValue.MaxValue())); }
public void ContainsReturnsFalseIfTheKeyIsMissing() { var lex = new Lexicon <double, object> { { double.MinValue, "bar" } }; Assert.IsFalse(lex.ContainsKey(double.MaxValue)); }
public void ContainsReturnsTrueIfTheKeyIsPresent() { var lex = new Lexicon { { ScalarDoubleValue.MinValue(), new StringValue("bar") } }; Assert.IsTrue(lex.ContainsKey(ScalarDoubleValue.MinValue())); }
public void ContainsReturnsTrueIfTheKeyIsPresent() { var lex = new Lexicon <double, object> { { double.MinValue, "bar" } }; Assert.IsTrue(lex.ContainsKey(double.MinValue)); }
private IList <double> SentimentValence(double valence, SentiText sentiText, string item, int i, IList <double> sentiments) { string itemLowerCase = item.ToLower(); if (!Lexicon.ContainsKey(itemLowerCase)) { sentiments.Add(valence); return(sentiments); } bool isCapDiff = sentiText.IsCapDifferential; IList <string> wordsAndEmoticons = sentiText.WordsAndEmoticons; valence = Lexicon[itemLowerCase]; if (item.IsUpper() && isCapDiff) { if (valence > 0) { valence += SentimentUtils.CIncr; } else { valence -= SentimentUtils.CIncr; } } for (int startI = 0; startI < 3; startI++) { if (i > startI && !Lexicon.ContainsKey(wordsAndEmoticons[i - (startI + 1)].ToLower())) { double s = SentimentUtils.ScalarIncDec(wordsAndEmoticons[i - (startI + 1)], valence, isCapDiff); if (startI == 1 && s != 0) { s = s * 0.95; } if (startI == 2 && s != 0) { s = s * 0.9; } valence = valence + s; valence = NeverCheck(valence, wordsAndEmoticons, startI, i); if (startI == 2) { valence = IdiomsCheck(valence, wordsAndEmoticons, i); } } } valence = LeastCheck(valence, wordsAndEmoticons, i); sentiments.Add(valence); return(sentiments); }
private IList <double> SentimentValence(double valence, Sentence sentiText, string item, int i, IList <double> sentiments) { string itemLowerCase = item.ToLower(); if (!Lexicon.ContainsKey(itemLowerCase)) { sentiments.Add(valence); return(sentiments); } bool isCapDiff = sentiText.AreSomeWordsInAllCapitals; IEnumerable <string> wordsAndEmoticons = sentiText.WordsAndEmoticons; valence = Lexicon[itemLowerCase]; if (isCapDiff && item.IsAllCapitals()) { if (valence > 0) { valence += SentimentUtils.CIncr; } else { valence -= SentimentUtils.CIncr; } } for (int startI = 0; startI < 3; startI++) { if (i > startI && !Lexicon.ContainsKey(wordsAndEmoticons.ElementAt(i - (startI + 1)).ToLower())) { double s = SentimentUtils.ScalarIncDec(wordsAndEmoticons.ElementAt(i - (startI + 1)), valence, isCapDiff); if (startI == 1 && s != 0) { s = s * 0.95; } if (startI == 2 && s != 0) { s = s * 0.9; } valence = valence + s; valence = NeverCheck(valence, wordsAndEmoticons, startI, i); if (startI == 2) { valence = IdiomsCheck(valence, wordsAndEmoticons, i); } } } valence = LeastCheck(valence, wordsAndEmoticons, i); sentiments.Add(valence); return(sentiments); }
private void UpdateLocalLexicon() { foreach (var m in Text.Lexicon.Keys) { // this is problematic as it will re-add existing text lexicon // result is that the lexicon sums will be multiplied. //Lexicon.Add(m.Graph.ToLower(), Text.Lexicon[m]); if (!Lexicon.ContainsKey(m)) { Lexicon.Add(m, Text.Lexicon[m]); } } }
private double LeastCheck(double valence, IList <string> wordsAndEmoticons, int i) { if (i > 1 && !Lexicon.ContainsKey(wordsAndEmoticons[i - 1].ToLower()) && wordsAndEmoticons[i - 1].ToLower() == "least") { if (wordsAndEmoticons[i - 2].ToLower() != "at" && wordsAndEmoticons[i - 2].ToLower() != "very") { valence = valence * SentimentUtils.NScalar; } } else if (i > 0 && !Lexicon.ContainsKey(wordsAndEmoticons[i - 1].ToLower()) && wordsAndEmoticons[i - 1].ToLower() == "least") { valence = valence * SentimentUtils.NScalar; } return(valence); }
private double LeastCheck(double valence, List <string> lowerCaseWordsAndEmoticons, int i) { if (i > 1 && !Lexicon.ContainsKey(lowerCaseWordsAndEmoticons[i - 1]) && lowerCaseWordsAndEmoticons[i - 1] == "least") { if (lowerCaseWordsAndEmoticons[i - 2] != "at" && lowerCaseWordsAndEmoticons[i - 2] != "very") { valence = valence * SentimentUtils.NScalar; } } else if (i > 0 && !Lexicon.ContainsKey(lowerCaseWordsAndEmoticons[i - 1]) && lowerCaseWordsAndEmoticons[i - 1] == "least") { valence = valence * SentimentUtils.NScalar; } return(valence); }
private void DrawTextList() { EditorGUIUtil.DrawSeparator(); if (!locked && Selection.gameObjects.IsNotEmpty() && (roots == null || !Enumerable.SequenceEqual(roots, Selection.gameObjects))) { Clear(); // search labels roots = Selection.gameObjects; foreach (GameObject o in roots) { tabs.Clear(); foreach (UITabHandler t in o.GetComponentsInChildren <UITabHandler>(true)) { tabs.Add(new UITabHandlerInspectorImpl(t)); } } foreach (GameObject o in roots) { // remove number labels HashSet <UIText> ignore = new HashSet <UIText>(); foreach (DropDown dropdown in o.GetComponentsInChildren <DropDown>(true)) { foreach (UIText l in dropdown.GetComponentsInChildren <UIText>(true)) { ignore.Add(l); } } foreach (UIText l in o.GetComponentsInChildren <UIText>(true)) { if (l.text.IsEmpty()) { continue; } if (ignore.Contains(l)) { continue; } if (visibleOnly && (!l.gameObject.activeInHierarchy || !l.enabled)) { continue; } foreach (char c in l.text) { if (char.IsLetter(c) && !char.IsWhiteSpace(c) && !char.IsPunctuation(c)) { labels.Add(l); break; } } } } } foreach (UITabHandlerInspectorImpl inspector in tabs) { if (inspector.OnInspectorGUI()) { Save(); roots = null; } } // draw trigger list EditorGUILayout.BeginVertical(); foreach (UIText l in labels) { if (!mod.ContainsKey(l)) { FindKey(l); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(l, typeof(UIText), true); Color oldColor = GUI.backgroundColor; string srcKey = mod.Get(l); if (srcKey == null) { srcKey = l.textKey; } if (!Lexicon.ContainsKey(srcKey)) { GUI.backgroundColor = Color.red; } string dstKey = EditorGUILayout.TextField(srcKey); GUI.backgroundColor = oldColor; string text = EditorGUILayout.TextField(l.text); if (srcKey != dstKey) { mod[l] = dstKey; } if (text != l.text) { l.SetText(text); CompatibilityEditor.SetDirty(l); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Save")) { Save(); } }
public void ContainsReturnsTrueIfTheKeyIsPresent() { var lex = new Lexicon {{ScalarDoubleValue.MinValue(), new StringValue("bar")}}; Assert.IsTrue(lex.ContainsKey(ScalarDoubleValue.MinValue())); }
public void ContainsReturnsFalseIfTheKeyIsMissing() { var lex = new Lexicon {{ScalarDoubleValue.MinValue(), new StringValue("bar")}}; Assert.IsFalse(lex.ContainsKey(ScalarDoubleValue.MaxValue())); }
private List <double> SentimentValence(double valence, SentiText sentiText, string word, string lowerCaseWord, int i, List <double> sentiments) { if (!Lexicon.ContainsKey(lowerCaseWord)) { sentiments.Add(valence); return(sentiments); } var isCapDiff = sentiText.IsCapDifferential; // adjust if shouting valence = Lexicon[lowerCaseWord]; if (isCapDiff && word.IsUpper()) { if (valence > 0) { valence += SentimentUtils.CIncr; } else { valence -= SentimentUtils.CIncr; } } for (var startI = 0; startI < 3 && i > startI; startI++) { var offset = i - (startI + 1); var lcWord = sentiText.WordsAndEmoticonsLowerCase[offset]; if (Lexicon.ContainsKey(lcWord)) { continue; } var s = SentimentUtils.ScalarIncDec(lcWord, sentiText.WordsAndEmoticons[offset], valence, isCapDiff); if (startI == 1 && !s.Equals(0)) { s = s * 0.95; } if (startI == 2 && !s.Equals(0)) { s = s * 0.9; } valence = valence + s; valence = NeverCheck(valence, sentiText.WordsAndEmoticonsLowerCase, startI, i); if (startI == 2) { valence = IdiomsCheck(valence, sentiText.WordsAndEmoticonsLowerCase, i); } } valence = LeastCheck(valence, sentiText.WordsAndEmoticonsLowerCase, i); sentiments.Add(valence); return(sentiments); }
public void testAddEntry() { l.addEntry("EXAMPLE", "word", (float)0.10); Assert.IsTrue(l.ContainsKey("EXAMPLE")); Assert.AreEqual(l.Get("EXAMPLE").Size(), 1); }
public void ContainsReturnsFalseIfTheKeyIsMissing() { var lex = new Lexicon<double, object> {{double.MinValue, "bar"}}; Assert.IsFalse(lex.ContainsKey(double.MaxValue)); }
public void ContainsReturnsTrueIfTheKeyIsPresent() { var lex = new Lexicon<double, object> {{double.MinValue, "bar"}}; Assert.IsTrue(lex.ContainsKey(double.MinValue)); }