예제 #1
0
        public void test_terms()
        {
            // add some values to the freq
              var freq = new Frequencies<string>();
              freq.Add("a");
              freq.Add("b");

              // check for equality
              IEnumerable<string> check = new List<string>() { "a", "b" };

              Assert.AreEqual(check, freq.Terms());
        }
        /// <summary>
        /// Add a new frequency.
        /// </summary>
        /// <param name="newFrequency">The frequency to be added.</param>
        public void AddFrequency(ISDBSatelliteFrequency newFrequency)
        {
            foreach (ISDBSatelliteFrequency oldFrequency in Frequencies)
            {
                if (oldFrequency.Frequency == newFrequency.Frequency)
                {
                    if (oldFrequency.Polarization == newFrequency.Polarization)
                    {
                        return;
                    }
                    else
                    {
                        if (oldFrequency.Polarization.PolarizationAbbreviation.CompareTo(newFrequency.Polarization.PolarizationAbbreviation) > 0)
                        {
                            Frequencies.Insert(Frequencies.IndexOf(oldFrequency), newFrequency);
                            return;
                        }
                    }
                }

                if (oldFrequency.Frequency > newFrequency.Frequency)
                {
                    Frequencies.Insert(Frequencies.IndexOf(oldFrequency), newFrequency);
                    return;
                }
            }

            Frequencies.Add(newFrequency);
        }
        private void SubscribeFrequencyMessages()
        {
            MessagingCenter.Unsubscribe <OrdonnanceFrequence2ViewModel, Frequency>(this, Events.UpdateFrequencies);
            MessagingCenter.Subscribe <OrdonnanceFrequence2ViewModel, Frequency>(this, Events.UpdateFrequencies, async(sender, args) =>
            {
                if (args != null)
                {
                    var frequency = args as Frequency;

                    if (Ordonnance.Frequencies != null)
                    {
                        if (Ordonnance.Frequencies.Contains(frequency))
                        {
                        }
                        else
                        {
                            Ordonnance.Frequencies.Add(frequency);
                        }
                    }

                    if (Frequencies.Contains(frequency))
                    {
                    }
                    else
                    {
                        Frequencies.Add(frequency);
                        await ToastService.Show("Fréquence ajoutée avec succès");
                        MessagingCenter.Send(this, Events.UpdateFrequenciesViewCellHeight, Frequencies);
                    }
                }
            });
        }
예제 #4
0
 public void test_create_frequency_object_from_ngrams()
 {
     var text = TextExamples.emma();
       var freq = new Frequencies<string>();
       foreach (var token in Regex.Split(text, @"(\W+)").NGram(2))
       {
     freq.Add(token.Aggregate((a,b)=>a+" "+b));
       }
 }
예제 #5
0
        internal async Task <bool> Create(MainViewModel vm, IList frqs, IList deps, IList pols, IList stats)
        {
            VectorDic = new Dictionary <int, BDataVector>();

            Vectors = new List <BDataVector>();

            await Task.Run(() =>
            {
                //Create a vector
                foreach (string p in pols)
                {
                    int pKey = p.ToPolKey();

                    if (!POLs.Contains(p))
                    {
                        POLs.Add(p);
                    }


                    //        BDataObject child = new BDataObject(p);


                    foreach (double d in deps)
                    {
                        if (!Depressions.Contains(d))
                        {
                            Depressions.Add(d);
                        }

                        foreach (double f in frqs)
                        {
                            if (!Frequencies.Contains(f))
                            {
                                Frequencies.Add(f);
                            }

                            vm.VectorCurrent++;

                            BDataVector vector = new BDataVector(d, f, p, pKey);
                            vector.Create360DegData(vm, stats);
                            vector.FinalizePOLKey(pKey);


                            VectorDic.Add(vector.KeyFreqDepPol, vector);

                            Vectors.Add(vector);
                        }
                    }
                }
            });



            return(true);
        }
예제 #6
0
        public MainViewModel()
        {
            InitializeCommands();

            RadioController.ScanUpdated += (s, e) => Frequencies.Add(e.Frequency);

            RadioController.ScanCompleted += (s, e) => OnPropertyChanged(nameof(RadioState));

            _selectedFrequency = RadioController.Frequency;

            RadioController.StartScan();
        }
예제 #7
0
 public void test_create_frequency_object_from_text()
 {
     var text = TextExamples.emma();
       var freq = new Frequencies<string>();
       foreach (var token in Regex.Split(text, @"(\W+)"))
       {
     freq.Add(token);
       }
       Assert.AreEqual(freq.Count(), 2227);
       Assert.AreEqual(freq.Get("and"), 47.0);
       Assert.AreEqual(freq.Terms().Count(), 479);
 }
예제 #8
0
            public void add(int age)
            {
                int category = age / TStep;

                while (Frequencies.Count < category + 1)
                {
                    Frequencies.Add(0);
                    if (Frequencies.Count > maxcat)
                    {
                        maxcat = Frequencies.Count;
                    }
                }
                Frequencies[category]++;
            }
예제 #9
0
 private static void frequencies_of_ngrams_in_emma_sample()
 {
     var text = TextExamples.emma();
       var freq = new Frequencies<string>();
       foreach (var token in Regex.Split(text, @"(\W+)").Where((x) => x != ", " && TextTools.not_whitespace.IsMatch(x)).NGram(3))
       {
     freq.Add(token.Aggregate((a, b) => a + " " + b));
       }
       foreach (var term in freq.Generate().OrderBy(p => p.Value).Reverse().Take(10))
       {
     Console.WriteLine(String.Format(@"{0}: {1}", term.Key, term.Value));
       }
       Console.WriteLine(freq.Count());
       Console.WriteLine(freq.Terms().Count());
 }
예제 #10
0
 public TransactionFrequencyEntryVM()
 {
     // every X days/weeks/months
     //  starts on
     //  ends on
     Frequencies.Add(new TransactionFrequencyVM()
     {
         Id = Guid.NewGuid(), Description = "Day (Every X Days)", IsDaily = true, BeginDate = DateTime.Now.Date
     });
     Frequencies.Add(new TransactionFrequencyVM()
     {
         Id = Guid.NewGuid(), Description = "Week (Every X Weeks)", IsWeekly = true, BeginDate = DateTime.Now.Date
     });
     Frequencies.Add(new TransactionFrequencyVM()
     {
         Id = Guid.NewGuid(), Description = "Month (Every X Months)", IsMonthly = true, BeginDate = DateTime.Now.Date
     });
 }
예제 #11
0
 private static void get_instances_of_Mr_from_austen()
 {
     var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Data\Austen");
       var austen = new TextCorpusReader(path);
       var freq = new Frequencies<string>();
       var i = 0;
       foreach (var w in austen.words().NGram(2))
       {
     var term = w.First().Trim().Append(w.Last()).Trim();
     //if (term.Length > 1 && term.Substring(0, 2) == "Mr" && term.Substring(2, 1) != "." && term.Substring(2, 1) != "s")
     if (term.Length > 1 && term.Substring(0, 2) == "Mr")
     {
       freq.Add(term);
     }
       }
       foreach (var t in freq.Generate())
       {
     Console.WriteLine("{0} => {1}", t.Key, t.Value);
       }
 }
예제 #12
0
 private static void read_trigram_frequencies_from_inaugural_addresses()
 {
     var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Data\inaugural");
       var inaugural = new TextCorpusReader(path);
       var f = new Frequencies<string>();
       foreach (var address in inaugural.words().Where((x) => x != ", ").NGram(3))
       {
     f.Add(address.DefaultIfEmpty("").Aggregate((a, b) => a + " " + b));
       }
       foreach (var term in f.Generate().OrderBy(p => p.Value).Reverse().Take(10))
       {
     Console.WriteLine(String.Format(@"{0}: {1}", term.Key, term.Value));
       }
 }
예제 #13
0
 /// <summary>
 /// Store the result of the AC simulation
 /// </summary>
 /// <param name="sender">Simulation invoking the event</param>
 /// <param name="data">Simulation data</param>
 private void StoreResult(object sender, SimulationData data)
 {
     Frequencies.Add(data.GetFrequency());
     Results.Add(extractsim(data));
 }
예제 #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            var s = new Stopwatch();

            s.Start();
            var wc = new WordCloudGen(1000, 600);

            if (resultPictureBox.Image != null)
            {
                resultPictureBox.Image.Dispose();
            }
            Words.Clear();
            Frequencies.Clear();

            List <string> AllWords       = new List <string>();
            List <int>    AllFrequencies = new List <int>();
            var           file_words     = File.ReadAllText(@"D:\c#\图云词频计算\words.txt");
            var           words          = file_words.Split('\n');

            foreach (var word in words)
            {
                if (AllWords.Contains(word))
                {
                    //如果已经存在就+1
                    AllFrequencies[AllWords.IndexOf(word)]++;
                }
                else
                {
                    bool result = false;
                    for (int j = 0; j < word.Length; j++)
                    {
                        if (Char.IsNumber(word, j))
                        {
                            result = true;
                        }
                    }
                    if (!result)
                    {
                        //如果不存在 且不为数字就添加
                        AllWords.Add(word);
                        AllFrequencies.Add(1);
                    }
                }
            }
            int index = 0;

            foreach (var temp in AllFrequencies)
            {
                if (temp > 200)
                {
                    Words.Add(AllWords[index]);
                    Frequencies.Add(temp);
                }
                index++;
            }

            Image i = wc.Draw(Words, Frequencies);

            s.Stop();
            elapsedLabel.Text      = s.Elapsed.TotalMilliseconds.ToString();
            resultPictureBox.Image = i;
        }
 /**<summary>Add a frequency to the frequency enumerator que.</summary>
  * <param name="cell">The cell that uses the pitch.</param>
  * <param name="symbol">The pitch symbol. ex. A4</param>
  */
 public void SetFrequency(string symbol, BeatCell cell)
 {
     Frequencies.Add(cell, ConvertFromSymbol(symbol));
     freqEnum = Frequencies.Values.GetEnumerator();
 }
예제 #16
0
 public void test_add_to_frequencies()
 {
     var freq = new Frequencies<string>();
       freq.Add("a");
       Assert.AreEqual(1, freq.Get("a"));
 }