示例#1
0
        public void makeExcel(String filePath) {
            Database data = new Database(filePath);
            String[] attNames = data.allAttributes.Keys.ToArray<String>();
            int columns = attNames.Length + 1;

            Console.WriteLine("DATASIZE: " + data.Count());
            Console.WriteLine("Atts: " );
            String[][] spreadsheet = new String[data.Count() + 1][];
            for(int i=0; i<spreadsheet.Length; i++){
                spreadsheet[i] = new String[columns];
            }
            //String[,] spreadsheet = new String[data.Count() + 1, columns];

            //fill in first row of attributes
            spreadsheet[0][0] = "index";
            for (int i = 1; i < columns; i++) {
                spreadsheet[0][i] = attNames[i - 1];
            }

            //fill in columns
            for (int i = 1; i < spreadsheet.Length; i++)
            {
                spreadsheet[i][0] = "" + i;
            }

            for (int i=0; i< data.allEntries.Count; i++){
                Entry e = data.allEntries[i];

                foreach (KeyValuePair<String, object> pair in e.attributes) {
                    int index = Array.IndexOf(spreadsheet[0], pair.Key);
                //    if(index > columns || index < 0)
                //    Console.WriteLine(pair.Key + ": " + index);

                        Console.WriteLine(i + "," + index);
                        String noCommas = pair.Value.ToString().Replace(",", " ");
                        spreadsheet[i + 1][index] = noCommas;
                }
            
            }
            //join for string array to be written
            String[] toWrite = new String[spreadsheet.Length];
            for(int i=0; i < spreadsheet.Length; i++){
                toWrite[i] = String.Join(",", spreadsheet[i]);
            }


            System.IO.File.WriteAllLines("C:\\Users\\prairierose\\Downloads\\NLP\\Habilis.csv", toWrite);
            

        }
示例#2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public SurfaceWindow1()
        {
            InitializeComponent();
            ClusterButton.Tag = 1;
            Double ScreenWidth = MyScatterView.Width;
            Console.WriteLine("WIDTH OF SCREEN" + MyScatterView.Width);

            trash = new TrashCan();
            MyScatterView.Items.Add(trash);

            #region make and display the database

            Database dataSet = new Database();
            List<KeyValuePair<string, Type>> myList = dataSet.allAttributes.ToList();

            myList.Sort(
               delegate(KeyValuePair<string, Type> firstPair,
               KeyValuePair<string, Type> nextPair)
               {
                   return firstPair.Key.CompareTo(nextPair.Key);
               });
            #region Make Database Attribute Buttons
            for (int i = 0; i < myList.Count; i++)
            {
                String str = myList.ElementAt(i).Key;


                ScatterViewItem newButton = new ScatterViewItem();
                Double buttonsOnScreen = Math.Floor((MyScatterView.Width - 280) / 180);


                newButton.Orientation = 0;
                newButton.Center = new Point(280 + (180 * (i % buttonsOnScreen)), 40 + 65 * (int)(i / buttonsOnScreen));
                //newButton.Center = new Point(280 + (180 * (i % buttonsOnScreen)), 40 + 75 * (int)(i / buttonsOnScreen));
                newButton.Height = 50;
                newButton.Width = 160;
                //newButton.Background = Brushes.DarkSlateGray;
                newButton.MinHeight = 0;
                newButton.CanMove = false;
                newButton.CanRotate = false;

                SurfaceButton myButton = new SurfaceButton();
                myButton.FontSize = 15;
                myButton.Content = "Add " + str + " label";
                myButton.Height = 50;
                myButton.Width = 160;
                myButton.Foreground = Brushes.White;

                newButton.Content = myButton;
                MyScatterView.Items.Add(newButton);
                myButton.Tag = str;

                if (dataSet.allAttributes[str].Equals(typeof(System.String)))
                {
                    myButton.Background = Brushes.DarkSlateGray;
                    myButton.Click += new RoutedEventHandler(AddStringFilter_Click);

                }
                else if (dataSet.allAttributes[str].Equals(typeof(List<String>)))
                {
                    myButton.Background = Brushes.SlateGray;
                    myButton.Click += new RoutedEventHandler(AddStringListFilter_Click);
                }
                else if (dataSet.allAttributes[str].Equals(typeof(DateTime)))
                {
                    myButton.Background = Brushes.LightGray;
                    myButton.Foreground = Brushes.Black;
                    myButton.Click += new RoutedEventHandler(AddDateFilter_Click);
                }
                else if (dataSet.allAttributes[str].Equals(typeof(int)))
                {
                    myButton.Background = Brushes.LightGray;
                    myButton.Foreground = Brushes.Black;
                    myButton.Click += new RoutedEventHandler(AddIntFilter_Click);
                }
                else if (dataSet.allAttributes[str].Equals(typeof(List<int>)))
                {
                    myButton.Background = Brushes.Gray;
                    myButton.Click += new RoutedEventHandler(AddIntListFilter_Click);
                }


                //Console.WriteLine("ALL ATTRIBUTES: " + str + ", " + dataSet.allAttributes[str].ToString());
            }

            #endregion

            #region make entries and display to screen

            //List<Entry> listy = dataSet.allEntries.ToList();
           // Console.WriteLine("NUMBER OF PAPERS: " + listy.Count());
            //For every paper in the database, make a scatterview that shows the details
            foreach (Entry e in dataSet.allEntries)
            {
                AddToScreen(e);
                //            EventSubscriber.SubscribeAll(e);
            }

            #endregion

            #endregion


            #region Autosave
            System.Timers.Timer timer = new System.Timers.Timer(60000);
            timer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object delSender, System.Timers.ElapsedEventArgs delE)
            {
                this.autoSave("autoSave.txt");
                timer.Enabled = true;
            });

            timer.Enabled = true;



            #endregion

            // Add handlers for window availability events
            AddWindowAvailabilityHandlers();
        }
示例#3
0
        public MainWindow()
        {
            InitializeComponent();

#if histogram
            getHistogram("C:\\Users\\PrairieRose\\Documents\\GitHub\\HabilisX\\Infer.NET 2.5\\Samples\\C#\\LDA\\TestLDA\\890.bib");
            return;
#endif

#if excel
            makeExcel("C:\\Users\\prairierose\\Documents\\GitHub\\HabilisX\\HabilisX\\HabilisX\\Resources\\bibtexUnrelated.txt");
            return;

#endif


            String Path = "C:\\Users\\prairierose\\Documents\\GitHub\\HabilisX\\HabilisX\\AnalyzeResults\\Results\\";


            String[] files = {
            "ThomasRelatedMendeley.bib",
            "ThomasRelatedHabilis.bib",
            "AdamRelatedMendeley.bib",
            "AdamRelatedHabilis.bib",
            "MikeRelatedMendeley.bib",
            "MikeRelatedHabilis.bib",
            "StephenRelatedMendeley.bib",
            "StephenRelatedHabilis.bib",
            "TonyRelatedMendeley.bib",
            "TonyRelatedHabilis.bib",
            "WillRelatedMendeley.bib",
            "WillRelatedHabilis.bib",
            "JimRelatedMendeley.bib",
            "JimRelatedHabilis.bib",
            "ChrisRelatedMendeley.bib",
            "ChrisRelatedHabilis.bib",

                             };
            Database sources = new Database(0);
            Database distractors = new Database(1);
            Database dataset1 = new Database(2);
            Database dataset2 = new Database(3);

            String TabDeliniatedOutput = "MTP\tMFP\tMTN\tMFN\tHTP\tHFP\tHTN\tHFN\n";



            for (int i = 0; i < files.Length; i++)
            {
                String FileName = files[i];
                int end = FileName.LastIndexOf("Related");
                int period = FileName.LastIndexOf(".");
                String Name = FileName.Substring(0, end);
                Console.WriteLine(Name + "'s " + FileName.Substring(end + 7, (period - (end + 7))) + " Results");

                Database cur;
                Database results = new Database(Path + FileName);
                if (dataset1.Contains(results.allEntries[0]))
                {
                    cur = dataset1;
                    Console.WriteLine("Dataset 1");
                }
                else
                {
                    cur = dataset2;
                    Console.WriteLine("Dataset 2");
                }

                Console.WriteLine("Related Size: " + results.Count());


                int truePositive = 0;
                int trueNegative = 0;
                int falsePositive = 0;
                int falseNegative = 0;

                foreach(Entry e in cur.allEntries){
                    if (results.Contains(e) && sources.Contains(e)) {
                        truePositive++;
                    } else if(results.Contains(e) && distractors.Contains(e)){
                        falsePositive++;
                    }
                    else if (sources.Contains(e) && !results.Contains(e)) {
                        falseNegative++;
                    }
                    else if (distractors.Contains(e) && !results.Contains(e))
                    {
                        trueNegative++;
                    }
                    else {
                        Console.WriteLine("found something uncategorizable: " + e.printAttribute("title"));
                    }
                }




                Console.WriteLine("     TRUE || FALSE");
                if (truePositive > 9)
                {
                    Console.WriteLine("POS:   " + truePositive + " || " + falsePositive);
                }
                else
                {
                    Console.WriteLine("POS:    " + truePositive + " || " + falsePositive);
                }

                if (trueNegative > 9)
                {
                    Console.WriteLine("NEG:   " + trueNegative + " || " + falseNegative);
                }
                else
                {
                    Console.WriteLine("NEG:    " + trueNegative + " || " + falseNegative);
                }

                if (trueNegative + truePositive + falseNegative + falsePositive != 37)
                {
                    Console.WriteLine("There may be a problem here: " + (trueNegative + truePositive + falseNegative + falsePositive));
                    if (truePositive + falsePositive != results.allEntries.Count) Console.WriteLine("problem with positive");
                }


                TabDeliniatedOutput += Name + "\t" + truePositive + "\t" + falsePositive + "\t" + trueNegative + "\t" + falseNegative + "\t";

                if (i % 2 != 0) {
                    TabDeliniatedOutput += "\n";
                    Console.WriteLine("_________________________");
                }
                Console.WriteLine();

            }

            Console.WriteLine(TabDeliniatedOutput);

        }
示例#4
0
        private void LoadFromFile(String filePath)
        {
            foreach (Entry entry in this.entries)
            {
                MyScatterView.Items.Remove(entry);
            }
            this.entries = new List<Entry>();

            String str = System.IO.Directory.GetCurrentDirectory();
            str = str.Substring(0, str.LastIndexOf("\\"));
            str = str.Substring(0, str.LastIndexOf("\\"));
            str = str + filePath;

            Database loadedData = new Database(str);
            Database originalData = new Database();

            foreach (Entry data in originalData.allEntries)
            {
                if (!loadedData.Contains(data))
                {

                    loadedData.addEntry(data);
                }
            }


            Console.WriteLine("Number of cards in saved data: " + loadedData.allEntries.Count);
            foreach (Entry entry in loadedData.allEntries)
            {

                if (entry.attributes.ContainsKey("x") && entry.attributes.ContainsKey("y") && entry.attributes.ContainsKey("orientation"))
                {
                    Double x = Double.Parse(entry.attributes["x"].ToString());
                    Double y = Double.Parse(entry.attributes["y"].ToString()); ;

                    if (x > 1800)
                    {
                        x = 500;
                    }

                    if (y > 900)
                    {
                        y = 500;

                    }
                    entry.Center = new Point(x, y);
                    entry.Orientation = Double.Parse(entry.attributes["orientation"].ToString());
                    AddToScreen(entry);
                }
                else
                {
                    AddToScreen(entry);
                }
            }
        }