Beispiel #1
0
        internal SentenceAspect(string sentiment, AspectConfidenceScoreLabel confidenceScores, int offset, int length, string text, IEnumerable <AspectRelation> relations)
        {
            if (sentiment == null)
            {
                throw new ArgumentNullException(nameof(sentiment));
            }
            if (confidenceScores == null)
            {
                throw new ArgumentNullException(nameof(confidenceScores));
            }
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (relations == null)
            {
                throw new ArgumentNullException(nameof(relations));
            }

            Sentiment        = sentiment;
            ConfidenceScores = confidenceScores;
            Offset           = offset;
            Length           = length;
            Text             = text;
            Relations        = relations.ToList();
        }
Beispiel #2
0
 internal SentenceAspect(string sentiment, AspectConfidenceScoreLabel confidenceScores, int offset, int length, string text, IReadOnlyList <AspectRelation> relations)
 {
     Sentiment        = sentiment;
     ConfidenceScores = confidenceScores;
     Offset           = offset;
     Length           = length;
     Text             = text;
     Relations        = relations;
 }
Beispiel #3
0
        internal static SentenceAspect DeserializeSentenceAspect(JsonElement element)
        {
            SentenceAspectSentiment    sentiment        = default;
            AspectConfidenceScoreLabel confidenceScores = default;
            int    offset = default;
            int    length = default;
            string text   = default;
            IReadOnlyList <AspectRelation> relations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sentiment"))
                {
                    sentiment = new SentenceAspectSentiment(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("confidenceScores"))
                {
                    confidenceScores = AspectConfidenceScoreLabel.DeserializeAspectConfidenceScoreLabel(property.Value);
                    continue;
                }
                if (property.NameEquals("offset"))
                {
                    offset = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("length"))
                {
                    length = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("text"))
                {
                    text = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("relations"))
                {
                    List <AspectRelation> array = new List <AspectRelation>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AspectRelation.DeserializeAspectRelation(item));
                    }
                    relations = array;
                    continue;
                }
            }
            return(new SentenceAspect(sentiment, confidenceScores, offset, length, text, relations));
        }
Beispiel #4
0
        internal SentenceOpinion(SentenceOpinionSentiment sentiment, AspectConfidenceScoreLabel confidenceScores, int offset, int length, string text, bool isNegated)
        {
            if (confidenceScores == null)
            {
                throw new ArgumentNullException(nameof(confidenceScores));
            }
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            Sentiment        = sentiment;
            ConfidenceScores = confidenceScores;
            Offset           = offset;
            Length           = length;
            Text             = text;
            IsNegated        = isNegated;
        }
Beispiel #5
0
        internal static SentenceOpinion DeserializeSentenceOpinion(JsonElement element)
        {
            string sentiment = default;
            AspectConfidenceScoreLabel confidenceScores = default;
            int    offset    = default;
            int    length    = default;
            string text      = default;
            bool   isNegated = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sentiment"))
                {
                    sentiment = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("confidenceScores"))
                {
                    confidenceScores = AspectConfidenceScoreLabel.DeserializeAspectConfidenceScoreLabel(property.Value);
                    continue;
                }
                if (property.NameEquals("offset"))
                {
                    offset = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("length"))
                {
                    length = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("text"))
                {
                    text = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("isNegated"))
                {
                    isNegated = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new SentenceOpinion(sentiment, confidenceScores, offset, length, text, isNegated));
        }