public void Construct_FromChars_SetsPropertyValues() { Word2 c = new Word2('a', 'b'); Assert.Equal('a', c.L1); Assert.Equal('b', c.L2); }
public void Construct_FromString_SetsPropertyValues() { Word2 c = new Word2("ab"); Assert.Equal('a', c.L1); Assert.Equal('b', c.L2); }
public void CompareTo_ComparesCorrectly() { Word2 one = new Word2("aa"); Word2 two = new Word2("ab"); Word2 three = new Word2("ba"); Word2 four = new Word2("bb"); Assert.True(one.CompareTo(one) == 0); Assert.True(one.CompareTo(two) < 0); Assert.True(one.CompareTo(three) < 0); Assert.True(one.CompareTo(four) < 0); Assert.True(two.CompareTo(one) > 0); Assert.True(two.CompareTo(two) == 0); Assert.True(two.CompareTo(three) < 0); Assert.True(two.CompareTo(four) < 0); Assert.True(three.CompareTo(one) > 0); Assert.True(three.CompareTo(two) > 0); Assert.True(three.CompareTo(three) == 0); Assert.True(three.CompareTo(four) < 0); Assert.True(four.CompareTo(one) > 0); Assert.True(four.CompareTo(two) > 0); Assert.True(four.CompareTo(three) > 0); Assert.True(four.CompareTo(four) == 0); }
public void Construct_WordSequence_AddsToTrie() { Word2 w1 = new Word2("aa"); Word2 w2 = new Word2("zz"); Word2Trie trie = new Word2Trie(new Word2[] { w1, w2 }); Assert.True(trie.Contains(w1)); Assert.True(trie.Contains(w2)); }
public void Transpose_CreatesRowAndColumnSwappedGrid() { Word2[] rows = new Word2[] { new Word2("ab"), new Word2("ef") }; Word2Grid grid = new Word2Grid(rows[0], rows[1]); Word2Grid gridT = grid.Transpose(); Assert.Equal(new Word2("ae"), gridT.Row1); Assert.Equal(new Word2("bf"), gridT.Row2); }
public void Equals_ComparesCorrectly() { Word2[] rows = new Word2[] { new Word2("ab"), new Word2("ef") }; Word2Grid grid1a = new Word2Grid(rows[0], rows[1]); Word2Grid grid1b = new Word2Grid(rows[0], rows[1]); Word2Grid grid2 = new Word2Grid(rows[1], rows[1]); Assert.True(grid1a.Equals(grid1b)); Assert.True(grid1b.Equals(grid1a)); Assert.False(grid1b.Equals(grid2)); Assert.False(grid2.Equals(grid1a)); }
public void Construct_FromRows_SetsPropertyValues() { Word2[] rows = new Word2[] { new Word2("ab"), new Word2("ef") }; Word2Grid grid = new Word2Grid(rows[0], rows[1]); Assert.Equal('a', grid.A00); Assert.Equal('b', grid.A01); Assert.Equal('e', grid.A10); Assert.Equal('f', grid.A11); Assert.Equal(rows[0], grid.Row1); Assert.Equal(rows[1], grid.Row2); Assert.Equal(new Word2("ae"), grid.Column1); Assert.Equal(new Word2("bf"), grid.Column2); }
public void GetHashCode_UniqueUnlessValuesAreEqual() { Word2 one = new Word2("on"); Word2 oneA = new Word2("on"); Word2 two = new Word2("to"); Word2 twoA = new Word2("to"); int c1 = one.GetHashCode(); int c2 = two.GetHashCode(); int c1a = oneA.GetHashCode(); int c2a = twoA.GetHashCode(); Assert.Equal(c1, c1a); Assert.Equal(c2, c2a); Assert.NotEqual(c1, c2); }
public void Equals_ComparesCorrectly() { Word2 one = new Word2("on"); Word2 oneA = new Word2("on"); Word2 two = new Word2("to"); Word2 twoA = new Word2("to"); object twoO = two; Assert.True(one.Equals(oneA)); Assert.True(oneA.Equals(one)); Assert.True(two.Equals(twoA)); Assert.True(twoA.Equals(two)); Assert.True(two.Equals(twoO)); Assert.False(one.Equals(two)); Assert.False(two.Equals(one)); Assert.False(two.Equals(null)); }
void RandomWord() { //ReChoices unSelectChoices = words.ToList <Word2>(); //ReWord if (unSelectWords == null || unSelectWords.Count == 0) { unSelectWords = words.ToList <Word2>(); } //RandomIndex int randomWordIndex = Random.Range(0, unSelectWords.Count); currentWord = unSelectWords [randomWordIndex]; //SetText WordText.text = currentWord.wordEng; //SetCurrentIndex currentIndexWord = randomWordIndex; }
void Store(Dictionary <Word2, int> dict, SolarixGrammarEngineNET.SyntaxTreeNode t1, SolarixGrammarEngineNET.SyntaxTreeNode t2) { Word2 k = new Word2(); k.id_entry1 = t1.GetEntryID(); k.id_entry2 = t2.GetEntryID(); int n; if (dict.TryGetValue(k, out n)) { dict[k] = n + 1; } else { dict.Add(k, 1); } return; }
protected override void Execute(CodeActivityContext context) { string word1 = Word1.Get(context); string word2 = Word2.Get(context); string apiKey = APIKey.Get(context); string seKey = SecretKey.Get(context); try { var client = new Baidu.Aip.Nlp.Nlp(apiKey, seKey); //修改超时时间 client.Timeout = 60000; //带参数调用词义相似度 string result = client.WordSimEmbedding(word1, word2).ToString(); Result.Set(context, result); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message); } }
void Skip() { //ReChoices soundManager.PlaySoundSkip(); unSelectWords = words.ToList <Word2>(); unSelectChoices = words.ToList <Word2>(); //RandomWord With Not Same int randomWordIndex = Random.Range(0, unSelectWords.Count); while (currentWord.wordTrue == unSelectWords[randomWordIndex].wordTrue) { randomWordIndex = Random.Range(0, unSelectWords.Count); } currentWord = unSelectWords [randomWordIndex]; WordText.text = currentWord.wordEng; currentIndexWord = randomWordIndex; //SetChoice SetChoiceList(); //SetDmg enemy.enemyDmg = Mathf.RoundToInt(enemy.enemyDmg * 0.7f); enemy.attack(); }
public string MergeWord() { int Lngt1 = Word1.Length, Lngt2 = Word2.Length; //Get the length of both words if (Lngt1 == Lngt2) //When both words have the same length { for (int x = 0; x < Lngt1; x++) { NewWord = NewWord + Word1.Substring(x, 1) + Word2.Substring(x, 1); } } else if (Lngt1 > Lngt2) //When the first word is bigger than the second one { for (int x = 0; x < Lngt2; x++) { NewWord = NewWord + Word1.Substring(x, 1) + Word2.Substring(x, 1); } for (int x = Lngt2; x < Lngt1; x++) { NewWord = NewWord + Word1.Substring(x, 1); } } else //When the second word is bigger than the first one { for (int x = 0; x < Lngt1; x++) { NewWord = NewWord + Word1.Substring(x, 1) + Word2.Substring(x, 1); } for (int x = Lngt1; x < Lngt2; x++) { NewWord = NewWord + Word2.Substring(x, 1); } } return(NewWord); }
public void ToString_ReturnsWord() { Word2 word = new Word2("ab"); Assert.Equal("ab", word.ToString()); }
public bool IsKeyValuePair(string key, string value, StringComparison comparisonType = StringComparison.Ordinal) { return((TokenType == Type.KeyValuePair) && Word1.Equals(key, comparisonType) && Word2.Equals(value, comparisonType)); }
public override bool Equals(object obj) { Word2 y = (Word2)obj; return(y.id_entry1 == id_entry1 && y.id_entry2 == id_entry2); }