public bool IsAnagram()
        {
            IOrderedEnumerable <char> in1 = Word1.ToLower().ToCharArray().OrderBy(c => c);
            string st1 = string.Join("", in1);
            IOrderedEnumerable <char> in2 = Word2.ToLower().ToCharArray().OrderBy(c => c);
            string st2 = string.Join("", in2);

            return(st1.Equals(st2));
        }
Example #2
0
        public bool IsAnagram()
        {
            char[] word1CharArray = Word1.ToLower().ToCharArray();
            char[] word2CharArray = Word2.ToLower().ToCharArray();

            Array.Sort(word1CharArray);
            Array.Sort(word2CharArray);

            return(new string(word1CharArray) == new string(word2CharArray));
        }
Example #3
0
            public override int GetHashCode()
            {
                int hashcode = 157;

                unchecked {
                    if (__isset.word1)
                    {
                        hashcode = (hashcode * 397) + Word1.GetHashCode();
                    }
                    if (__isset.word2)
                    {
                        hashcode = (hashcode * 397) + Word2.GetHashCode();
                    }
                }
                return(hashcode);
            }
        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);
            }
        }
Example #5
0
        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);
        }
Example #6
0
        public bool AnagrammChecker()
        {
            bool IsItAnagramm = true;

            char[] firstWord  = Word1.ToCharArray().OrderBy(x => x).ToArray();
            char[] secondWord = Word2.ToCharArray().OrderBy(x => x).ToArray();

            if (firstWord.Length == secondWord.Length)
            {
                for (int i = 0; i < firstWord.Length; i++)
                {
                    if (firstWord[i] != secondWord[i])
                    {
                        IsItAnagramm = false;
                        break;
                    }
                }
            }
            else
            {
                IsItAnagramm = false;
            }
            return(IsItAnagramm);
        }
Example #7
0
 public override int GetHashCode()
 {
     return(Word1.GetHashCode() ^ Word2.GetHashCode());
 }
Example #8
0
 public bool IsKeyValuePair(string key, string value, StringComparison comparisonType = StringComparison.Ordinal)
 {
     return((TokenType == Type.KeyValuePair) &&
            Word1.Equals(key, comparisonType) &&
            Word2.Equals(value, comparisonType));
 }
Example #9
0
 public bool IsWord(string word, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
 {
     return((TokenType == Type.Word) &&
            Word1.Equals(word, comparisonType));
 }