protected void LinkButton1_Click(object sender, EventArgs e)
        {
            char[] trimmer={' '};

            List<string> keywords = TextBox2.Text.Split(',').ToList();

            List<string> filteredKeywords = new List<string>();

            foreach (string word in keywords)
            {

                string temp = word.ToLower();
                temp = temp.TrimEnd(trimmer);
                temp = temp.TrimStart(trimmer);
                filteredKeywords.Add(temp);

            }
            float CSMatch = Comparator.matchSpringerCS(filteredKeywords.ToArray());
            float ENMatch = Comparator.matchSpringerEngineering(filteredKeywords.ToArray());
            float MAMatch = Comparator.matchSpringerMA(filteredKeywords.ToArray());

            SCS.Text = " Computer Science: " +CSMatch  + "%";
            SEN.Text = " Engineering: " + ENMatch + "%";
            SMA.Text = " Mathematics: " + MAMatch + "%";
            ; ;
        }
        private string GetSeriesString()
        {
            List<Expense> expenses = Expense.GetAmountRandomAmountList();

            List<string> expensesLinePoints = new List<string>();
            StringBuilder seriesString = new StringBuilder();

            foreach (Expense expenseItem in expenses)
            {
                expensesLinePoints.Add(expenseItem.Amount.ToString());

                if (expenseItem.Date.Month == 12)
                {
                    if (seriesString.Length > 0)
                    {
                        seriesString.Append(",");
                    }
                    seriesString.Append("{ ");
                    seriesString.AppendFormat(@"name: {0},
                            data: [{1}]", expenseItem.Date.Year, string.Join(",", expensesLinePoints.ToArray()));
                    seriesString.Append("  }");

                    expensesLinePoints = new List<string>();
                }
            }

            return seriesString.ToString();
        }
            public static string[] PrepareUserKeywords(string SampleKeywordsText)
            {
                List<string> Keywords = new List<string>();
                try
                {
                    int i=0;
                    string[] splitter = { ".", " ", ":", ",", ";", "'", "\"", "(", ")" };
                    string[] UserWords = SampleKeywordsText.Split(splitter, StringSplitOptions.RemoveEmptyEntries);


                    SetWords();

                    foreach (string uWord in UserWords)
                    {

                        foreach (string word in words)
                        {

                        if (word.Contains("-") && i<UserWords.Length-1 )
                        {
                            int k=i+1;
                            if (word.ToLower() == uWord.ToLower()+"-"+UserWords[k].ToLower())
                            {

                                Keywords.Add(word);
                                break;
                            }
                        }
                        else
                        {
                            if (word.ToLower() == uWord.ToLower())
                            {

                                Keywords.Add(word);
                                break;
                            }

                        }

                        }

                        i++;
                    }
                }
                catch (Exception es)
                { }

                List<string> newWords = new List<string>();


                foreach (string temp in Keywords)
                {

                    if (newWords.Contains(temp))
                    {

                    }
                    else
                    {

                        newWords.Add(temp);
                    
                    }
                
                }


                words = new List<string>();
                StreamReader read = new StreamReader(HttpContext.Current.Server.MapPath("~/App_Data/Words.txt"));

                string lineRead = read.ReadLine();

                while (lineRead != null)
                {

                    words.Add(lineRead);
                    try
                    {
                        lineRead = read.ReadLine();
                    }
                    catch (NullReferenceException ec)
                    {
                        break;
                    }
                }
                read.Close();
                read.Dispose();


                foreach (string word in words)
                {

                    if (newWords.Contains(word))
                    {

                        newWords.Remove(word);
                    }
                
                }

                return newWords.ToArray();
            }
            public static string ProcessWords(string text)
            {
                ///////////////////////// Get words list ////////////////////////////////
                StreamReader read = new StreamReader(HttpContext.Current.Server.MapPath("~/App_Data/Words.txt"));

                string lineRead = read.ReadLine();

                while (lineRead != null)
                {

                    words.Add(lineRead);
                    try
                    {
                        lineRead = read.ReadLine();
                    }
                    catch (NullReferenceException ec)
                    {
                        break;
                    }
                }
                read.Close();
                read.Dispose();
                /////////////////////////////////////////////////////////////////////////
                string[] splitter = { "," };
                string[] wordsArray = text.Split(splitter, StringSplitOptions.RemoveEmptyEntries);


                //////////////////// Check if words is /////////////////////////////////
                foreach (string word in words)
                {
                    for (int count = 0; count < wordsArray.Length; count++)
                    {
                        if (wordsArray[count].ToLower() == word.ToLower())
                            wordsArray[count] = "";




                    }


                }
                ///////////////////////////////////////////////////////////////////////



                List<string> listString = wordsArray.ToList();



                listString.RemoveAll(item => item == "");


                List<string> newWords = new List<string>();


                foreach (string word in listString)
                {


                    if (newWords.Contains(word))
                    {

                    }
                    else
                    {
                        newWords.Add(word);

                    }

                }

                text = String.Join(",", newWords.ToArray());
                return text;
            }
示例#5
0
        //Method called to plot the points on a single line graph
        public void PlotSingle(List<int> l1, List<int> l1Year)
        {
            // ChartFormat();
            //One series on one chart
            Series series1 = Chart.Series["Series1"];

            //totals for getting average
            double total1 = 0;

            //growth rate variables
            double growthRate1 = 0;
            double averageGrowthRate1 = 0;

            int[] list1 = l1.ToArray();
            int[] curYear = l1Year.ToArray();
            int yearIncrementer = -1;

            foreach (int plot in l1)
            {
                yearIncrementer++;
                Chart.Series["Series1"]
                    .Points.AddXY(curYear[yearIncrementer], list1[yearIncrementer]);

                total1 += list1[yearIncrementer];

                //check no nulls are taken for the growth rate formula
                if ((yearIncrementer - 1 >= 0))
                {
                    growthRate1 = (double)((list1[yearIncrementer] - list1[yearIncrementer - 1]) / (double)list1[yearIncrementer - 1]);
                }

                //total growth rate variables first
                averageGrowthRate1 += growthRate1;
            }

            //get average and convert to percent
            averageGrowthRate1 = (averageGrowthRate1 / list1.Length) * 100;

            //Average values for each series
            double seriesAverage1 = (double)total1 / (double)list1.Length;

            //Create DataTable to insert all these values into Gridview
            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Series Name");
            dt.Columns.Add("Sample Size");
            dt.Columns.Add("Overall Average");
            dt.Columns.Add("Growth Rate");
            DataRow row1 = dt.NewRow();
            row1["Series Name"] = series1Name;
            row1["Sample Size"] = list1.Length.ToString();
            row1["Overall Average"] = Math.Round(seriesAverage1).ToString();
            row1["Growth Rate"] = Math.Round(averageGrowthRate1, 2).ToString() + "%";
            dt.Rows.Add(row1);

            //Bind these values to the gridview
            GridView1.DataSource = dt;
            GridView1.DataBind();
            ChartFormat();
        }
示例#6
0
        //Method called to plot the points on a 2 line graph
        public void PlotMultiple(List<int> l1, List<int> l2, List<int> l1Year, List<int> l2Year)
        {
            //ChartFormat();
            //Two series on one chart
            Series series1 = Chart.Series["Series1"];
            Series series2 = Chart.Series["Series2"];

            //totals for getting average
            double total1 = 0, total2 = 0;

            //growth rate variables
            double growthRate1 = 0, growthRate2 = 0;
            double averageGrowthRate1 = 0, averageGrowthRate2 = 0;

            int[] list1 = l1.ToArray();
            int[] list2 = l2.ToArray();
            int[] curYear = l1Year.ToArray();
            int[] curYear2 = l2Year.ToArray();
            int yearIncrementer = -1;

            foreach (int plot in l1)
            {
                yearIncrementer++;
                Chart.Series["Series1"]
                    .Points.AddXY(curYear[yearIncrementer], list1[yearIncrementer]);

                total1 += list1[yearIncrementer];

                //check no nulls are taken for the growth rate formula
                if ((yearIncrementer - 1 >= 0))
                {
                    growthRate1 = (double)((list1[yearIncrementer] - list1[yearIncrementer - 1]) / (double)list1[yearIncrementer - 1]);
                }

                //total growth rate variables first
                averageGrowthRate1 += growthRate1;
            }

            yearIncrementer = -1;

            foreach (int plot in l2)
            {
                yearIncrementer++;
                Chart.Series["Series2"].Points.AddXY(curYear2[yearIncrementer], list2[yearIncrementer]);

                total2 += list2[yearIncrementer];

                //check no nulls are taken for the growth rate formula
                if ((yearIncrementer - 1 >= 0))
                {
                    growthRate2 = (double)((list2[yearIncrementer] - list2[yearIncrementer - 1]) / (double)list2[yearIncrementer - 1]);
                }
                averageGrowthRate2 += growthRate2;

            }

            //get average and convert to percent
            averageGrowthRate1 = (averageGrowthRate1 / (double)list1.Length) * 100;
            averageGrowthRate2 = (averageGrowthRate2 / (double)list2.Length) * 100;

            //Average values for each series
            double seriesAverage1 = (double)total1 / (double)list1.Length;
            double seriesAverage2 = (double)total2 / (double)list2.Length;

            //Spearman's Rank correlation for each random set of integers
            double spearmansRankValue = SpearmansCoeff(list1, list2);

            //Calculates the Degrees of Freedom needed to test for significance
            //in the final version, this value will be the number of points - 2
            //i.e. DoF = n - 2;
            double DoF = DegreesOfFreedom(list1, list2);

            string isSignificant;

            if (SignificanceTest(DoF, spearmansRankValue))
            {
                isSignificant = "There is at least a 95% chance that the relationship between these two datasets are significant";
            }
            else
            {
                isSignificant = "It is not certain that the relationship between these two datasets are statistically significant";
            }

            //Create DataTable to insert all these values into Gridview
            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Series Name");
            dt.Columns.Add("Sample Size");
            dt.Columns.Add("Overall Average");
            dt.Columns.Add("Growth Rate");
            dt.Columns.Add("Spearman's Rank Correlation and Significance");
            DataRow row1 = dt.NewRow();
            row1["Series Name"] = series1Name;
            row1["Sample Size"] = list1.Length.ToString();
            row1["Overall Average"] = Math.Round(seriesAverage1).ToString();
            row1["Growth Rate"] = Math.Round(averageGrowthRate1, 2).ToString() + "%";
            row1["Spearman's Rank Correlation and Significance"] = "Correlation: " + Math.Round(spearmansRankValue, 2).ToString() + ".  " + CorrelationTest(spearmansRankValue);
            dt.Rows.Add(row1);
            DataRow row2 = dt.NewRow();
            row2["Series Name"] = series2Name;
            row2["Sample Size"] = list2.Length.ToString();
            row2["Overall Average"] = Math.Round(seriesAverage2).ToString();
            row2["Growth Rate"] = Math.Round(averageGrowthRate2, 2).ToString() + "%";
            row2["Spearman's Rank Correlation and Significance"] = "Significance: " + isSignificant;
            dt.Rows.Add(row2);

            //Bind these values to the gridview
            GridView1.DataSource = dt;
            GridView1.DataBind();
            ChartFormat();
            MultipleYAxis(series2);
        }
        public static string Keywords(string uri, string tagAttribute, string tagValue)
        {





            List<string> keywordsList = new List<string>();
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(new WebClient().DownloadString(uri));


                var rootNode = doc.DocumentNode;

                if (tagAttribute == "Tag")
                {

                    var data = rootNode.Descendants(tagValue);
                    foreach (var dataNode in data)
                    {


                        string dataString = dataNode.InnerText;
                        dataString += " " + dataNode.InnerHtml;
                        keywordsList.Add(dataString);

                    }
                }
                else
                {


                    var data = rootNode.Descendants().Where(n => n.GetAttributeValue(tagAttribute, "").Equals(tagValue));
                    foreach (var dataNode in data)
                    {


                        string dataString = dataNode.InnerText;
                        dataString += " " + dataNode.InnerHtml;
                        keywordsList.Add(dataString);

                    }
                
                }



                

            }
            catch (Exception ex)
            {



            }
            string Keywords = String.Join(", ", keywordsList.ToArray());






            return Keywords;
        
        
        
        
        }
        private static OracleCommand CriarComando(String cmmdText, CommandType cmmdType, List<OracleParameter> listParameter)
        {
            try
            {
                var conn = new OracleConnection();
                conn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionStringOracleDesenv"].ConnectionString;
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = cmmdText;
                cmd.CommandType = cmmdType;

                if (listParameter != null)
                {
                    cmd.BindByName = true;
                    cmd.Parameters.AddRange(listParameter.ToArray());
                }
                // Retorna o comando criado
                return cmd;
            }
            catch (DbException ex)
            {
                throw ex;
            }
        }
        public static Journal[] FromSpringer()
        {

            List<Journal> JournalsFromSpringer = new List<Journal>();

            string source = "https://www.springer.com/gp/adis/products-services";
            var html = new HtmlDocument();

            try
            {
                html.LoadHtml(new WebClient().DownloadString(source)); // load a string web address
                // create a root node
                var root = html.DocumentNode;

                var Links = root.Descendants().Where(n => n.GetAttributeValue("class", "").Equals("flapContent--paragraph"));


                foreach (var Link in Links)
                {


                    Journal JournalObj = new Journal();

                    HtmlAttribute newAttribute = Link.FirstChild.Attributes["href"];
                    JournalObj.Link = newAttribute.Value;
                    JournalObj.Name = Link.InnerText;
                    JournalObj.Website = "Springer";
                    //JournalObj.Keywords = KeywordExtractor.springerKeywords(JournalObj.Link);
                    //JournalObj.Submit = KeywordExtractor.springerLink(JournalObj.Link);
                    if (String.IsNullOrEmpty(JournalObj.Submit))
                    {
                        JournalObj.Submit = "https://www.editorialmanager.com/";
                    
                    }
                    JournalsFromSpringer.Add(JournalObj);


                }
            }
            catch (Exception ex)
            { 
            
            
            }
            return JournalsFromSpringer.ToArray();
        }
示例#10
0
        public static Package[] CollectPackages()
        {
            List<int> viewIds = new List<int>(), editIds = new List<int>(), ownIds = new List<int>();

            // [Hack]: Empty string returns all files.
            foreach (var info in SearchFileInfos(""))
            {
                var id = info.Id;

                if (IsOwnerOf(id))
                {
                    ownIds.Add(id);
                }
                else if (HasEditRights(id))
                {
                    editIds.Add(id);
                }
                else if (HasViewRights(id))
                {
                    viewIds.Add(id);
                }
                else
                {
                    throw new Exception("Leak in SearchPackages. A FileInfo to which the current user has no rights, has been retrieved.");
                }
            }

            var viewable = new Package() { Description = "Contains all viewable files.", Id = -1, Name = "Viewable Files", OwnerEmail = _sessionUser.Email, FileIds = viewIds.ToArray<int>() };
            var editable = new Package() { Description = "Contains all editable files.", Id = -2, Name = "Editable Files", OwnerEmail = _sessionUser.Email, FileIds = editIds.ToArray<int>() };
            var owned    = new Package() { Description = "Contains all owned files.",    Id = -3, Name = "Owned Files",    OwnerEmail = _sessionUser.Email, FileIds = ownIds.ToArray<int>()  };

            // [Hack]: Empty string returns all packages.
            var packs = new List<Package>(SearchPackages(""));

            packs.AddRange(new Package[] {viewable,editable,owned});

            return packs.ToArray<Package>();
        }
        private string GetPieChartSeriesString()
        {
            List<Expense> expenses = Expense.GetAmountRandomAmountList();

            List<string> expensesLinePoints = new List<string>();

            for (int index = 12; index < expenses.Count; index++)
            {
                expensesLinePoints.Add(string.Format("['{0}',{1}]",
                    expenses[index].Date.ToString("MMMM"),
                    expenses[index].Amount));

            }

            return string.Join(",", expensesLinePoints.ToArray());
        }
示例#12
0
 private string[] CheckboxListSelections(System.Web.UI.WebControls.CheckBoxList list)
 {
     List<String> values = new List<String>();
     for (int counter = 0; counter < list.Items.Count; counter++) {
         if (list.Items[counter].Selected) {
             values.Add(list.Items[counter].Value);
         }
     }
     return values.ToArray();
 }