/// <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); }
internal static List<QuandlStockResponse> GetData(string source, string code, DateTime? start, Frequencies freq) { List<QuandlStockResponse> result = new List<QuandlStockResponse>(); if (!start.HasValue) { start = DateTime.Parse("1800-01-01"); } var resRaw = GetSingleData(source, code, freq == Frequencies.Daily ? start.Value.AddDays(1) : start.Value, freq, Transformations.None); dynamic resParsedRaw = JValue.Parse(resRaw); for (int i = 0; i < resParsedRaw.data.Count; i++) { var elRaw = resParsedRaw.data[i]; if ((elRaw[1] != null && elRaw[2] != null && elRaw[3] != null && elRaw[4] != null && elRaw[5] != null) && (elRaw[1] != 0 && elRaw[2] != 0 && elRaw[3] != 0 && elRaw[4] != 0)) { QuandlStockResponse r = new QuandlStockResponse(); r.Date = elRaw[0]; r.Open = elRaw[1]; r.High = elRaw[2]; r.Low = elRaw[3]; r.Close = elRaw[4]; r.Volume = elRaw[5]; result.Add(r); } } return result; }
/// <summary> /// returns the key AA based on the key position /// if WildTYpePeptide is set, it returns the aa of wildtype corresponding to that position /// Otherwise it brings the most frequenet amino acid in the positive columns or frequencies /// </summary> /// <param name="keyPosition"></param> /// 0-indexed /// <returns></returns> public char GetKeyChar(int keyPosition) { char keyAA = ' '; if (keyPosition >= 0) { if (string.IsNullOrEmpty(WildTypePeptide)) { if (PositiveColumns != null && keyPosition < PositiveColumns.Count())//OPAL - wieght based motif with no wildtypepeptide { keyAA = PositiveColumns[keyPosition]. OrderByDescending(kv => kv.Value).Select(kv => kv.Key).FirstOrDefault(); } else if (Frequencies != null && keyPosition < Frequencies.Count())//frequency based peptide array, peptide list { keyAA = Frequencies[keyPosition].OrderByDescending(kv => kv.Value).Select(kv => kv.Key).FirstOrDefault(); } } else if (keyPosition < WildTypePeptide.Length) { keyAA = WildTypePeptide[keyPosition]; } } return(keyAA); }
/// <summary> /// return a stream of the statistics found when calculating type classification step. /// </summary> /// <param name="period_final_bigram_frequencies"></param> /// <param name="unigram_freqs"></param> /// <param name="N"></param> /// <param name="cw01"></param> /// <param name="cw1"></param> /// <param name="p"></param> /// <param name="p0"></param> /// <param name="p1"></param> /// <returns></returns> public static IEnumerable<Type_Classification> enumerate_type_based_classification( Frequencies<string> period_final_bigram_frequencies , Frequencies<string> unigram_freqs , double N , double cw1 , double p , double p0 , double p1 ) { foreach (var bigram in period_final_bigram_frequencies.Generate()) { var s = new Type_Classifier_Statistics(); s.c_w1 = cw1; s.p = p; s.p0 = p0; s.p1 = p1; s.w1 = "."; s.w01 = bigram.Key; // split off the ending period s.w0 = bigram.Key.Substring(0, bigram.Key.Length-1); s.c_w01 = bigram.Value; // find the unigram frequency of this term. s.c_w0 = unigram_freqs.Get(s.w0); s.llr = LikelihoodRatio.logLambda(N, s.c_w01, s.c_w0, s.c_w1, s.p, s.p0, s.p1); // Calculate the length penalty s.length_penalty = 1/Math.Exp(s.w0.Length - count_internal_periods(s.w0)); // Calculate the Internal periods penalty s.internal_periods_penalty = count_internal_periods(s.w0) + 1; // Calculate occurrances penalty without final period var len = s.w0.Length - count_internal_periods(s.w0); len = (len == 0) ? 1: len; s.with_final_period_penalty = 1/Math.Pow(len, (s.c_w0 - s.c_w01)); //if (s.with_final_period_penalty == 0) // Console.WriteLine(s.w0); // scaled log likelihood s.scaled_llr = s.llr * s.length_penalty * s.internal_periods_penalty * s.with_final_period_penalty; // calculate the final classifier for each sentence final bigram var c = new Type_Classification(); c.statistics = s; // annotate with the classification if (s.scaled_llr < 0.3) { c.classification = "<S>"; } else { if (s.w0.Length - count_internal_periods(s.w0) == 0) c.classification = "<E>"; else c.classification = "<A>"; } yield return c; } }
public byte[] Save() { var frequencies = Frequencies.ToList(); var frequencyTable = new byte[frequencies.Count * 8]; var count = 0; foreach (var item in frequencies) { Buffer.BlockCopy(BitConverter.GetBytes(item.Frequency), 0, frequencyTable, count * 8, 4); Buffer.BlockCopy(BitConverter.GetBytes((int)item.Character), 0, frequencyTable, count * 8 + 4, 4); count++; } var data = new byte[8 + frequencyTable.Length + Data.Length]; Buffer.BlockCopy(BitConverter.GetBytes(frequencies.Count), 0, data, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(OriginalLength), 0, data, 4, 4); Buffer.BlockCopy(frequencyTable, 0, data, 8, frequencyTable.Length); Buffer.BlockCopy(Data, 0, data, 8 + frequencyTable.Length, Data.Length); return(data); }
protected internal override IEnumerator RespondToCommandInternal(string inputCommand) { if (!inputCommand.Trim().RegexMatch(out Match match, "^(?:tx|trans(?:mit)?|submit|xmit) (?:3.)?(5[0-9][25]|600)( ?mhz)?$") || !int.TryParse(match.Groups[1].Value, out int targetFrequency) || !Frequencies.Contains(targetFrequency)) { yield break; } int initialFrequency = CurrentFrequency; MonoBehaviour buttonToShift = targetFrequency < initialFrequency ? _downButton : _upButton; while (CurrentFrequency != targetFrequency && (CurrentFrequency == initialFrequency || Math.Sign(CurrentFrequency - initialFrequency) != Math.Sign(CurrentFrequency - targetFrequency))) { yield return("change frequency"); yield return("trycancel"); yield return(DoInteractionClick(buttonToShift)); } if (CurrentFrequency == targetFrequency) { yield return("transmit"); yield return(DoInteractionClick(_transmitButton)); } }
/// <summary> /// Convert an Frequency to its string representation /// </summary> /// <param name="value"></param> /// <returns></returns> public static string ToString(Frequencies value) { switch (value) { case Frequencies.MINUTELY: return("MINUTELY"); case Frequencies.HOURLY: return("HOURLY"); case Frequencies.DAILY: return("DAILY"); case Frequencies.WEEKLY: return("WEEKLY"); case Frequencies.MONTHLY: return("MONTHLY"); case Frequencies.YEARLY: return("YEARLY"); case Frequencies.SECONDLY: return("SECONDLY"); default: throw new ArgumentOutOfRangeException(nameof(value), value, null); } }
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); } } }); }
public Bitmap GetFrequencyMotif(int widthImage, int heightImage) { if (Frequencies == null || Frequencies.Count() == 0) { return(null); } return(Render(Frequencies, widthImage, heightImage, defColor: null)); }
public ActionResult DeleteConfirmed(int id) { Frequencies frequencies = db.Frequencies.Find(id); db.Frequencies.Remove(frequencies); db.SaveChanges(); return(RedirectToAction("Index")); }
private static void freqs_from_emma_sample() { var freq = new Frequencies<string>(TextExamples.emma().Split()); foreach (var term in freq.Generate().OrderBy(p => p.Value)) { Console.WriteLine(String.Format(@"{0}: {1}", term.Key, term.Value)); } }
protected override IEnumerator RespondToCommandInternal(string inputCommand) { string[] commandParts = inputCommand.Split(' '); if (commandParts.Length != 2) { yield break; } if (!commandParts[0].Equals("transmit", StringComparison.InvariantCultureIgnoreCase) && !commandParts[0].Equals("trans", StringComparison.InvariantCultureIgnoreCase) && !commandParts[0].Equals("xmit", StringComparison.InvariantCultureIgnoreCase) && !commandParts[0].Equals("tx", StringComparison.InvariantCultureIgnoreCase)) { yield break; } int targetFrequency = 0; if (!int.TryParse(commandParts[1].Substring(commandParts[1].Length - 3), out targetFrequency)) { yield break; } if (!Frequencies.Contains(targetFrequency)) { yield break; } int initialFrequency = CurrentFrequency; MonoBehaviour buttonToShift = targetFrequency < initialFrequency ? _downButton : _upButton; while (CurrentFrequency != targetFrequency && (CurrentFrequency == initialFrequency || Mathf.Sign(CurrentFrequency - initialFrequency) != Mathf.Sign(CurrentFrequency - targetFrequency))) { yield return("change frequency"); if (Canceller.ShouldCancel) { Canceller.ResetCancel(); yield break; } DoInteractionStart(buttonToShift); yield return(new WaitForSeconds(0.1f)); DoInteractionEnd(buttonToShift); } if (CurrentFrequency == targetFrequency) { yield return("transmit"); DoInteractionStart(_transmitButton); yield return(new WaitForSeconds(0.1f)); DoInteractionEnd(_transmitButton); } }
private void HandleFrequencyCommand(params object[] args) { if (args == null || args.Length < 1) { return; } m_LastFrequencies = args[0] as Frequencies; UpdateFrequenciesInStrands(); }
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)); } }
public void Frequency(Frequencies frequencies) { CommandHandler currentHandler; if (m_Commands.TryGetValue(CommandReceiver.FRQ, out currentHandler)) { currentHandler(frequencies); } }
public Frequencies Read(int FrequencyId) { Frequencies result = new Frequencies(); using (IDbConnection conn = GetConnection()) { result = conn.Get <Frequencies>(FrequencyId); } return(result); }
public ActionResult Edit([Bind(Include = "id,trip_id,start_time,end_time,headway_secs,exact_times")] Frequencies frequencies) { if (ModelState.IsValid) { db.Entry(frequencies).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(frequencies)); }
public ProjectTechnology(string name, DateTime firstUse, ProjectTechnologyCategory category = null, DateTime?lastUse = null, Frequencies usageFrequency = Frequencies.Daily, Proficiencies proficiency = Proficiencies.Intermediate) { Id = ++id; Name = name; FirstUse = firstUse; Category = category; LastUse = lastUse; UsageFrequency = usageFrequency; Proficiency = proficiency; }
/// <summary> /// Builds the Huffman tree /// </summary> /// <param name="source">The source to build the Hufftree from</param> /// <exception cref="ArgumentNullException">Thrown when source is null or empty</exception> public void BuildTree(string source) { if (string.IsNullOrEmpty(source)) { throw new ArgumentNullException("source"); } Frequencies.Accept(source); BuildTree(); }
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); }
public MainViewModel() { InitializeCommands(); RadioController.ScanUpdated += (s, e) => Frequencies.Add(e.Frequency); RadioController.ScanCompleted += (s, e) => OnPropertyChanged(nameof(RadioState)); _selectedFrequency = RadioController.Frequency; RadioController.StartScan(); }
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); }
private void HandleFrequency(params object[] args) { if (args == null || args.Length < 1) { return; } LatestFrequencies = args[0] as Frequencies; if (m_Callbacks != null) { m_Callbacks(LatestFrequencies); } }
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> /// Measure the AC output /// </summary> /// <param name="ckt">Circuit</param> /// <returns></returns> public override double Measure(Circuit ckt) { // Initialize Frequencies.Clear(); Results.Clear(); // Simulate Analysis.OnExportSimulationData += StoreResult; ckt.Simulate(Analysis); Analysis.OnExportSimulationData -= StoreResult; // Return result return(extractparam(this)); }
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]++; }
/// <summary> /// Plays the note using the current <see cref="IPlayer"/> for <see cref="Duration"/>ms /// </summary> public void PlayNote() { if (DesiredOctave > Frequencies.Count() - 1) { var error = new ArgumentException($"{DesiredOctave} is too high of an Octave to play {Key}", nameof(DesiredOctave)); Error?.Invoke(this, error); } else { try { string[] desiredChord = null; switch (ChordType) { case ChordType.Note: desiredChord = new string[] { Key }; break; case ChordType.Power: desiredChord = PowerChord; break; case ChordType.MinorThird: desiredChord = MinorChord3; break; case ChordType.MajorThird: desiredChord = MajorChord3; break; case ChordType.MinorSeventh: desiredChord = MinorChord7; break; case ChordType.MajorSeventh: desiredChord = MajorChord7; break; } PlayingNote?.Invoke(this, new EventArgs()); var musicNotes = desiredChord.Select(sn => MusicNote.Create(sn)); var frequencies = musicNotes.Select(mn => new FrequencyDuration(mn.Key, mn.DesiredOctave, mn.Frequencies[DesiredOctave], Duration)); NotePlayer?.Play(frequencies, Instrument); } catch (Exception ex) { Error?.Invoke(this, ex); } } }
// GET: Frequency/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Frequencies frequencies = db.Frequencies.Find(id); if (frequencies == null) { return(HttpNotFound()); } return(View(frequencies)); }
/// <summary> /// Determine whether the set of input options has any valid filters. /// </summary> /// <returns>True if there are valid filters, false otherwise.</returns> public bool HasAnyFilters() { return(!string.IsNullOrEmpty(TargetRepository) || !string.IsNullOrEmpty(TargetBranch) || !string.IsNullOrEmpty(SourceRepository) || !string.IsNullOrEmpty(Channel) || Frequencies.Any() || !string.IsNullOrEmpty(DefaultChannelTarget) || Disabled || Enabled || Batchable || NotBatchable || SubscriptionIds.Any()); }
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()); }
public static DateTime GetNextScheduledRunDate(DateTime startDate, Frequencies frequency) { switch (frequency) { case Frequencies.Week: return startDate.AddDays(7); case Frequencies.TwoWeeks: return startDate.AddDays(14); case Frequencies.Month: return startDate.AddMonths(1); default: break; } return startDate; }
public ActionResult Edit(string id, string title, Frequencies frequency, int recurs, DateTime startAt, FormCollection forms) { var workItem = Scheduler.GetWorker(id); var recurringDaysOfMonth = forms["RecurringDaysOfMonth"]; var recurringDaysOfWeek = forms["RecurringDaysOfWeek"]; var recurringMonths = forms["RecurringMonths"]; if (workItem.Frequency == Frequencies.Weekly) { if (recurringDaysOfWeek != null && recurringDaysOfWeek.Length > 0) { workItem.RecurringDaysOfWeek = recurringDaysOfWeek.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); } } if (workItem.Frequency == Frequencies.Monthly) { if (recurringDaysOfMonth != null && recurringDaysOfMonth.Length > 0) { workItem.RecurringDaysOfMonth = recurringDaysOfMonth.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); } if (recurringMonths != null && recurringMonths.Length > 0) { workItem.RecurringMonths = recurringMonths.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); } } var props = workItem.JobType.GetProperties(); workItem.CommandData = new System.Collections.Generic.Dictionary <string, object>(); foreach (var pro in props) { var key = workItem.JobType.Name + "." + pro.Name; if (forms[key] != null) { workItem.CommandData.Add(pro.Name, Convert.ChangeType(forms[key], pro.PropertyType)); } } workItem.Recurs = recurs; workItem.StartAt = startAt; workItem.NextStart = workItem.GetNextStart(startAt); Scheduler.Update(workItem); return(PartialView()); }
public IActionResult Frequencies(Frequencies freq) { // Deserialize and load frequenceies language from json file var frequencies = freq.DeserializeJson(); int i = 0; foreach (var item in frequencies.frequencies) { for (i = 0; i < 26; i++) { item.Frequency[i] = item.Frequency[i] * 100; } } return(View("Frequencies", frequencies)); }
public void Accept(IFeedVisitor visitor) { Agencies.Accept(visitor); Stops.Accept(visitor); Routes.Accept(visitor); Trips.Accept(visitor); StopTimes.Accept(visitor); Calendars.Accept(visitor); CalendarDates.Accept(visitor); FareAttributes.Accept(visitor); FareRules.Accept(visitor); Shapes.Accept(visitor); Frequencies.Accept(visitor); Transfers.Accept(visitor); FeedInfos.Accept(visitor); }
protected override IEnumerator RespondToCommandInternal(string inputCommand) { string[] commandParts = inputCommand.ToLowerInvariant().Split(' '); if (commandParts.Length != 2) { yield break; } if (!commandParts[0].EqualsAny("transmit", "trans", "xmit", "tx", "submit")) { yield break; } if (!int.TryParse(commandParts[1].Substring(commandParts[1].Length - 3), out int targetFrequency)) { yield break; } if (!Frequencies.Contains(targetFrequency)) { yield break; } int initialFrequency = CurrentFrequency; MonoBehaviour buttonToShift = targetFrequency < initialFrequency ? _downButton : _upButton; while (CurrentFrequency != targetFrequency && (CurrentFrequency == initialFrequency || Mathf.Sign(CurrentFrequency - initialFrequency) != Mathf.Sign(CurrentFrequency - targetFrequency))) { yield return("change frequency"); if (Canceller.ShouldCancel) { Canceller.ResetCancel(); yield break; } yield return(DoInteractionClick(buttonToShift)); } if (CurrentFrequency == targetFrequency) { yield return("transmit"); yield return(DoInteractionClick(_transmitButton)); } }
public void AssignOpcodesByFrequency(IEnumerable <Instruction> instructions) { // TODO: fix this var optimizedInstructionBytes = instructions .Where(i => i.Enabled) .Select(i => i.ToBytes()) .ToList(); var optimizedArgumentsFrequencies = new Frequencies( optimizedInstructionBytes .SelectMany(i => i.Skip(1)) .ToArray() ); var optimizedOpcodesFrequencies = new Frequencies( optimizedInstructionBytes .Where(b => b.Length > 0) .Select(b => b.First()) .ToArray() ); var byteSet = optimizedArgumentsFrequencies.GetMostFrequentBytes().ToList(); var opcodeSet = optimizedOpcodesFrequencies.GetMostFrequentBytes().ToList(); for (byte b = 0; b < 255; b++) { if (byteSet.Count >= opcodeSet.Count) { break; } if (!byteSet.Contains(b)) { byteSet.Add(b); } } for (var i = 0; i < opcodeSet.Count; i++) { var b = opcodeSet[i]; map[(Opcodes)b].Value = byteSet[i]; } }
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 }); }
public void Accept(IFeedVisitor visitor) { Parallel.Invoke( () => Agencies.Accept(visitor), () => Stops.Accept(visitor), () => Routes.Accept(visitor), () => Trips.Accept(visitor), () => StopTimes.Accept(visitor), () => Calendars.Accept(visitor), () => CalendarDates.Accept(visitor), () => FareAttributes.Accept(visitor), () => FareRules.Accept(visitor), () => Shapes.Accept(visitor), () => Frequencies.Accept(visitor), () => Transfers.Accept(visitor), () => FeedInfos.Accept(visitor) ); }
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); } }
public static string FrequencyToString(Frequencies frequency) { switch (frequency) { case Frequencies.Daily: return "daily"; case Frequencies.Weekly: return "weekly"; case Frequencies.Monthly: return "monthly"; case Frequencies.Quarterly: return "quarterly"; case Frequencies.Annualy: return "annual"; default: return "none"; } }
private void Iterate(AdvisorEntities ctx, List<Ticker> tickers, Frequencies? frequencies) { foreach (var ticker in tickers) { var code = ticker.QuandlTicker.Split('/'); var innerTicker = ctx.Ticker.Where(p => p.ID == ticker.ID).FirstOrDefault(); var startDate = new DateTime(innerTicker.LastMonthlyUpdate.Value.Year, innerTicker.LastMonthlyUpdate.Value.Month, innerTicker.LastMonthlyUpdate.Value.Day); switch (frequencies) { case Frequencies.Monthly: { ProceedWithMonthlyData(ctx, ticker, code, innerTicker, startDate); break; } case Frequencies.Weekly: { ProceedWithWeeklyData(ctx, ticker, code, innerTicker, startDate); break; } case Frequencies.Daily: { ProceedWithDailyData(ctx, ticker, code, innerTicker, startDate); break; } case null: { ProceedWithDailyData(ctx, ticker, code, innerTicker, startDate); ProceedWithWeeklyData(ctx, ticker, code, innerTicker, startDate); ProceedWithMonthlyData(ctx, ticker, code, innerTicker, startDate); break; } } ctx.Entry(innerTicker).State = System.Data.EntityState.Modified; ctx.SaveChanges(); } }
public LogFileResults() { LineLengths = new LineLengths(); CharacterFrequencies = new Frequencies<char>(); }
/// <summary> /// Step 1: Type based classification of period final bigrams. In this step, /// we want to guess at a classification of period final bigrams whether they are /// elipses, abbreviations, or sentence endings. This procedure calculates the /// parameters that remain constant over all the enumerations. /// </summary> /// <returns>a list of type classifications</returns> public static IEnumerable<Type_Classification> type_based_classification_stage( Frequencies<string> period_final_bigram_frequencies , Frequencies<string> nonperiod_final_bigram_frequencies , Frequencies<string> unigram_freqs , int period_freq) { // count of periods double cw1 = Convert.ToDouble(period_freq); // number of tokens in the corpus double N = unigram_freqs.Generate().Select(a=>a.Value).Sum() + cw1; // Do Collocation Bond // The paper identifies special values for probabilities on the null hypothesis // and the alternative (p. 5). double p = cw1/N; double p0 = 0.99; double p1 = 1.0 - p0; // The remaining parameters: // bigrams count (this is the same as the period count) double cw01 = cw1; // return the results for each period final bigram return enumerate_type_based_classification(period_final_bigram_frequencies , unigram_freqs, N, cw1, p, p0, p1); }
public ActionResult Edit(string id, string title, Frequencies frequency, int recurs, DateTime startAt, FormCollection forms) { var workItem = Scheduler.GetWorker(id); var recurringDaysOfMonth = forms["RecurringDaysOfMonth"]; var recurringDaysOfWeek = forms["RecurringDaysOfWeek"]; var recurringMonths = forms["RecurringMonths"]; if (workItem.Frequency == Frequencies.Weekly) { if (recurringDaysOfWeek != null && recurringDaysOfWeek.Length > 0) workItem.RecurringDaysOfWeek = recurringDaysOfWeek.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); } if (workItem.Frequency == Frequencies.Monthly) { if (recurringDaysOfMonth != null && recurringDaysOfMonth.Length > 0) workItem.RecurringDaysOfMonth = recurringDaysOfMonth.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); if (recurringMonths != null && recurringMonths.Length > 0) workItem.RecurringMonths = recurringMonths.Split(',').Select(a => Convert.ToInt32(a)).ToArray(); } var props = workItem.JobType.GetProperties(); workItem.CommandData = new System.Collections.Generic.Dictionary<string, object>(); foreach (var pro in props) { var key = workItem.JobType.Name + "." + pro.Name; if (forms[key] != null) workItem.CommandData.Add(pro.Name, Convert.ChangeType(forms[key], pro.PropertyType)); } workItem.Recurs = recurs; workItem.StartAt = startAt; workItem.NextStart = workItem.GetNextStart(startAt); Scheduler.Update(workItem); return PartialView(); }
public void test_add_to_frequencies() { var freq = new Frequencies<string>(); freq.Add("a"); Assert.AreEqual(1, freq.Get("a")); }
private static string GetSingleData(string source, string code, DateTime start, Frequencies freq, Transformations trans) { QuandlDownloadRequest requestRawData = new QuandlDownloadRequest(); requestRawData.APIKey = APIK_KEY; requestRawData.Datacode = new Datacode(source, code); requestRawData.Format = FileFormats.JSON; requestRawData.Frequency = freq; requestRawData.Transformation = trans; requestRawData.StartDate = start; requestRawData.EndDate = DateTime.Now; var urlRawData = requestRawData.ToRequestString(); return GetMessage(urlRawData); }
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)); } }
protected void DeserializeRealWords() { using (Stream stream = File.Open(RealWordsFile, FileMode.Open)) { BinaryFormatter bin = new BinaryFormatter (); realWordFreqs = (Frequencies<string>)bin.Deserialize (stream); } }