Пример #1
0
        public SentiText(SentimentIntensityAnalyzer az, string text)
        {
            Az   = az;
            Text = text;


            // convert emoji to word equivalents

            // are there any ?
            var match = Az.SubsubstituteEmoji.Match(text);

            if (match.Success)
            {
                var itr = StringInfo.GetTextElementEnumerator(text);
                var sb  = new StringBuilder();

                while (itr.MoveNext())
                {
                    var el = itr.GetTextElement();

                    // just skip if can't find
                    if (az.Emojicon.TryGetValue(el, out var desc))
                    {
                        sb.Append(' ');
                        sb.Append(desc);
                        sb.Append(' ');
                    }
                    else
                    {
                        sb.Append(el);
                    }
                }

                ExpandedText = sb.ToString();
            }
            else
            {
                ExpandedText = text;
            }

            StripWrapingPunctuation();
        }
 public SentimentIntensityAnalyzer(SentimentIntensityAnalyzer src)
 {
     Lexicon  = src.Lexicon;
     Emojicon = src.Emojicon;
 }