Esempio n. 1
0
        private void AddFeaturesToLabeledData(int newDataIndex)
        {
            TweetData currTweet = tweetDatas[currentTweetIndex];
            User      currUser  = currTweet.users[userIndex];
            string    newLabel  = chcLstLabels.Items[newDataIndex].ToString();

            List <string> newLabels = (currUser.labels == null) ? new List <string>() : new List <string>(currUser.labels);

            newLabels.Add(newLabel);
            currTweet.labeled = true;
            currUser.labels   = newLabels.ToArray();
        }
Esempio n. 2
0
        public Analyser(TweetData[] tweets, string[] labels, int _percentage = 10, bool _isRandom = false)
        {
            this.tweets     = tweets;
            this.tweetCount = tweets.Length;
            this.labels     = labels;
            this.labelCount = labels.Length;
            this.wordDict   = new Dictionary <string, Word>();
            this.labelDict  = new Dictionary <string, int>();
            this.labelFreq  = new Dictionary <string, int>();

            percentage = _percentage;
            isRandom   = _isRandom;

            testingCount  = (tweets.Length * percentage) / 100;
            trainingCount = tweets.Length - testingCount;

            TrainingTweets = new TweetData[trainingCount];
            TestingTweets  = new TweetData[testingCount];

            SeperateTweets();
        }
Esempio n. 3
0
        private void DeleteFeaturesFromLabeledData(int newDataIndex)
        {
            TweetData currTweet = tweetDatas[currentTweetIndex];
            User      currUser  = currTweet.users[userIndex];

            string        newLabel  = chcLstLabels.Items[newDataIndex].ToString();
            List <string> newLabels = new List <string>(currUser.labels);

            if (currUser.labels != null || currUser.labels.Length != 0)
            {
                newLabels.Remove(newLabel);

                if (newLabels.Count == 0)
                {
                    currTweet.labeled = false;
                }
                else
                {
                    currTweet.labeled = true;
                }
            }

            currUser.labels = newLabels.ToArray();
        }
Esempio n. 4
0
        //this shows the labeled tweet on appropriate label object
        //increment takes values -1 0 1
        private void UpdateShownData(int increment)
        {
            int tweetDatasLength = tweetDatas.Length;

            currentTweetIndex += increment;

            ////we need to check if we are under 0.
            currentTweetIndex = currentTweetIndex < 0 ?
                                tweetDatas.Length - 1 : currentTweetIndex;

            currentTweetIndex = currentTweetIndex % tweetDatasLength;

            tweetIndex.Text = (currentTweetIndex + 1) + "/" + tweetDatasLength;

            TweetData currTweet = tweetDatas[currentTweetIndex];
            User      currUser  = currTweet.users[userIndex];

            string rawTweet = "";
            string tweet    = "";
            string labels   = "";

            int wordsLength = currTweet.words.Length;

            for (int i = 0; i < wordsLength; i++)
            {
                tweet += currTweet.words[i] + " ";
            }

            rawTweet = currTweet.tweet;

            ClearCheckedDataFromCheckedListBox(chcLstLabels);

            // we already have this labels so we dont have to make changes on data thats why we unregister this event
            UnregisterItemCheckEvent(chcLstLabels_ItemCheck);
            if (currUser.labels != null)
            {
                int labelsLength = currUser.labels.Length;
                for (int i = 0; i < labelsLength; i++)
                {
                    string currentLabel = currUser.labels[i];

                    for (int j = 0; j < chcLstLabels.Items.Count; j++)
                    {
                        if (chcLstLabels.Items[j].ToString() == currentLabel)
                        {
                            chcLstLabels.SetItemCheckState(j, CheckState.Checked);
                            break;
                        }
                    }
                    labels += currentLabel + ", ";
                }
            }

            RegisterItemCheckEvent(chcLstLabels_ItemCheck);
            labels = labels.TrimEnd(',', ' ');

            cmbUserName.Text = currUser.name;

            if (tweetDatas.Length > 0)
            {
                //we can write asked tweet data. currentTweetIndex % tweetDatas.Length --> we can go over tweets so
                //we can start from 0
                lblTweetText.Text = "Raw tweet: " + rawTweet +
                                    "\n\nTweet: " + tweet +
                                    "\n\nLabel: " + labels +
                                    "\n\nUser: "******"No parsed Tweet data in the file";
            }
        }