Beispiel #1
0
        private void Calc()
        {
            // 初期化
            foreach (Agent agent in VoteMap.Keys)
            {
                ReceiveVoteCount.Add(agent, 0);
            }

            // 被投票数のカウント
            foreach (Agent agent in VoteMap.Values)
            {
                // 存在しないエージェントに投票宣言することもあるので存在チェックする
                if (agent != null && VoteMap.ContainsKey(agent))
                {
                    ReceiveVoteCount[agent]++;
                    // 被投票数の最大を記憶
                    MaxVoteReceiveCount = Math.Max(MaxVoteReceiveCount, ReceiveVoteCount[agent]);
                }
            }

            // 被投票率のカウント
            foreach (KeyValuePair <Agent, int> keyValue in ReceiveVoteCount)
            {
                ReceiveVoteRate.Add(keyValue.Key, keyValue.Value / (double)VoteMap.Count);
            }

            // 最大得票者の取得
            foreach (KeyValuePair <Agent, int> keyValue in ReceiveVoteCount)
            {
                if (keyValue.Value == MaxVoteReceiveCount)
                {
                    MaxVoteReceivedAgent.Add(keyValue.Key);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="voteList"></param>
        public VoteAnalyzer(List <Vote> voteList)
        {
            foreach (Vote vote in voteList)
            {
                VoteMap.Add(vote.Agent, vote.Target);
            }

            // 各計算を行う
            Calc();
        }
Beispiel #3
0
    /// <summary>Votes for the specified tag on the specified entity.</summary>
    /// <param name="tag">The tag to vote for.</param>
    /// <param name="vote">The vote to apply to the tag.</param>
    /// <param name="entityType">
    /// The type of entity identified by <paramref name="mbid"/>; must be an entity that supports tags.
    /// </param>
    /// <param name="mbid">The MBID of the entity to tag.</param>
    /// <returns>This submission request.</returns>
    public TagSubmission Add(string tag, TagVote vote, EntityType entityType, Guid mbid)
    {
        var map = this.GetMap(entityType);

        if (!map.TryGetValue(mbid, out var tagVote))
        {
            map.Add(mbid, tagVote = new VoteMap());
        }
        tagVote[tag] = vote;
        return(this);
    }
Beispiel #4
0
        /// <summary>Votes for the specified tag on the specified entity.</summary>
        /// <param name="tag">The tag to vote for.</param>
        /// <param name="vote">The vote to apply to the tag.</param>
        /// <param name="entityType">The type of entity identified by <paramref name="mbid"/>; must be an entity that supports tags.</param>
        /// <param name="mbid">The MBID of the entity to tag.</param>
        /// <returns>This submission request.</returns>
        public TagSubmission Add(string tag, TagVote vote, EntityType entityType, Guid mbid)
        {
            if (tag == null)
            {
                throw new ArgumentNullException(nameof(tag));
            }
            var map = this.GetMap(entityType);

            if (!map.TryGetValue(mbid, out var tagvote))
            {
                map.Add(mbid, tagvote = new VoteMap());
            }
            tagvote[tag] = vote;
            return(this);
        }
Beispiel #5
0
        /// <summary>
        /// コンストラクタ(発話リストから投票宣言先を取得)
        /// </summary>
        /// <param name="talkList">発話リスト</param>
        /// <param name="topic">宣言を読み取るTopic(VOTE、ATTACK以外は無効)</param>
        public VoteAnalyzer(List <Agent> agentList, List <ExtTalk> talkList, Topic topic = Topic.VOTE)
        {
            // 投票宣言先の初期化
            foreach (Agent agent in agentList)
            {
                VoteMap.Add(agent, null);
            }

            // 全発話を読む
            foreach (ExtTalk talk in talkList)
            {
                Content content = talk.Content;

                // 投票宣言
                if (content.Operator == Operator.NOP && content.Topic == topic)
                {
                    VoteMap[talk.Agent] = content.Target;
                }
            }

            // 各計算を行う
            Calc();
        }