Example #1
0
        void TestString(Testcase tc, string expected, NormalizationForm f)
        {
            string input  = tc.Source;
            string actual = null;

            switch (f)
            {
            default:
                actual = Normalization.Normalize(input, 0); break;

            case NormalizationForm.FormD:
                actual = Normalization.Normalize(input, 1); break;

            case NormalizationForm.FormKC:
                actual = Normalization.Normalize(input, 2); break;

            case NormalizationForm.FormKD:
                actual = Normalization.Normalize(input, 3); break;
            }

            if (actual != expected)
            {
                Console.WriteLine("Error: expected {0} but was {1} (for {2},type{3} form {4})",
                                  expected, actual, tc.Source, tc.TestType, f);
            }
        }
Example #2
0
 public String Normalize(NormalizationForm normalizationForm)
 {
     if (this.IsAscii())
     {
         // If its FastSort && one of the 4 main forms, then its already normalized
         if (normalizationForm == NormalizationForm.FormC ||
             normalizationForm == NormalizationForm.FormKC ||
             normalizationForm == NormalizationForm.FormD ||
             normalizationForm == NormalizationForm.FormKD)
         {
             return(this);
         }
     }
     return(Normalization.Normalize(this, normalizationForm));
 }
Example #3
0
    /// <summary>
    /// Resets the timer to the seconds passed in
    /// </summary>
    /// <param name="secondsToWait"> The amount of seconds to wait</param>
    public void ResetTimer(float secondsToWait)
    {
        // We execute this if the timer is stopped, to make it run for the first time
        // We update the TimeToCompare so that we can compare it with the actual time
        TimeToCompare = Time.time + secondsToWait;

        // We set the min and max for the normalization
        MinToNormalize = Time.time;
        MaxToNormalize = TimeToCompare;

        // We calculate the actual normalized time left
        NormalizedTimer = Normalization.Normalize(Time.time, MinToNormalize, MaxToNormalize);

        // We reset the offset as well to avoid having any weird values
        m_OffsetToAddWhenTimerResumes = 0f;
    }
Example #4
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public String Normalize(NormalizationForm normalizationForm)
        {
#if !FEATURE_NORM_IDNA_ONLY
            if (this.IsAscii())
            {
                // If its FastSort && one of the 4 main forms, then its already normalized
                if (normalizationForm == NormalizationForm.FormC ||
                    normalizationForm == NormalizationForm.FormKC ||
                    normalizationForm == NormalizationForm.FormD ||
                    normalizationForm == NormalizationForm.FormKD)
                {
                    return(this);
                }
            }
#endif // !FEATURE_NORM_IDNA_ONLY
            return(Normalization.Normalize(this, normalizationForm));
        }
Example #5
0
        public static string Normalize(this string src, NormalizationForm normalizationForm)
        {
            switch (normalizationForm)
            {
            default:
                return(Normalization.Normalize(src, 0));

            case NormalizationForm.FormD:
                return(Normalization.Normalize(src, 1));

            case NormalizationForm.FormKC:
                return(Normalization.Normalize(src, 2));

            case NormalizationForm.FormKD:
                return(Normalization.Normalize(src, 3));
            }
        }
Example #6
0
    /// <summary>
    /// The Generic Countdown to be used. True if the countdown finishes. False while not
    /// </summary>
    /// <param name="secondsToWait"> The number of seconds to wait to get true (float) </param>
    /// <returns> True if the countdown finishes. False while not </returns>
    public bool GenericCountDown(float secondsToWait)
    {
        // We check the state of the timer
        switch (TimerState)
        {
        case TimerStateEnum.Started:
            // If it is already running, we check the time

            // We calculate the actual normalized time left
            NormalizedTimer = Normalization.Normalize(Time.time, MinToNormalize, MaxToNormalize);

            // We calculate the seconds left
            m_SecondsLeft = TimeToCompare - Time.time;

            // If the actual time is bigger than the time + secondsToWait, then the countdown is over
            if (Time.time > TimeToCompare)
            {
                // We stop the timer
                StopTimer();
                // Countdown finished!
                return(true);
            }

            // The countdown is still going on, the timer keeps running
            return(false);

        case TimerStateEnum.Paused:
            // Gather offset to apply when we resume
            m_OffsetToAddWhenTimerResumes += 1f * Time.deltaTime;

            // The timer is paused, return false
            return(false);

        case TimerStateEnum.Stopped:
            // We execute this if the timer is stopped, to make it run for the first time
            ResetTimer(secondsToWait);

            // We start the timer
            StartTimer();
            return(false);

        default:
            return(false);
        }
    }
Example #7
0
            public static Normalization BuildNormalization(NeuralTyresEntry[] tyres, string key, double valuePadding, out double[] normalizedValues,
                                                           double minValue, double maxValue)
            {
                var result = new Normalization();

                normalizedValues = new double[tyres.Length];
                for (var i = normalizedValues.Length - 1; i >= 0; i--)
                {
                    var value = GetValue(tyres[i], key);
                    normalizedValues[i] = value;
                    result.Extend(value);
                }
                result.Seal(valuePadding, minValue, maxValue);
                for (var i = normalizedValues.Length - 1; i >= 0; i--)
                {
                    normalizedValues[i] = result.Normalize(normalizedValues[i]);
                }
                return(result);
            }
Example #8
0
        public static void PickedACS()
        {
            Console.WriteLine("Pick product and an user for new predicted rating");
            Console.WriteLine("Pick the userID");
            UserChoice.choiceUserId = int.Parse(Console.ReadLine());


            List<int> ratedProduct = FileReader.DictionaryData[UserChoice.choiceUserId].Select(x => x.Item1).ToList();
            ratedProduct.Sort();
            foreach (var productId in FileReader.GetItemList())
            {
                if (!ratedProduct.Contains((int)productId))
                {
                    Cosinus.ACS((int)productId);
                    if (Normalization.NormalizedDictionary.Count() == 0)
                    {
                        Normalization.Normalize(UserChoice.choiceUserId);
                    }
                    Console.WriteLine("Predicted result for productId: " + productId + " predicted rating is " + Prediction.CalculatePrediction(UserChoice.choiceUserId, (int)productId));
                }
            }
            Console.ReadLine();

        }
Example #9
0
        private static void Main(string[] args)
        {
            Console.WriteLine("R128Normalization  Copyright (C) 2020  Xuan525");
            Console.WriteLine("This program is under GPLv3 license;");
            Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.");
            Console.WriteLine("This is free software, and you are welcome to redistribute it");
            Console.WriteLine("under certain conditions; type `show c' for details.");
            Console.WriteLine();
            Console.WriteLine("Type a Path to start the process.");
            Console.WriteLine("Or you can use any of the commands below:");
            Console.WriteLine("    Type     'loudness [value]' or  'l [value]' for query or set Target integrated loudness (LUFS).");
            Console.WriteLine("    Type         'peak [value]' or  'p [value]' for query or set Maximum true peak (dB).");
            Console.WriteLine("    Type       'attack [value]' or  'a [value]' for query or set Attack duration for Limiter (s).");
            Console.WriteLine("    Type      'release [value]' or  'r [value]' for query or set Release duration for Limiter (s).");
            Console.WriteLine("    Type  'attackCurve [value]' or 'ac [value]' for query or set Attack curve tension for Limiter (1.0 - 8.0).");
            Console.WriteLine("    Type 'releaseCurve [value]' or 'rc [value]' for query or set Release curve tension for Limiter (1.0 - 8.0).");
            Console.WriteLine("    Type   'loopVerify [value]' or 'lv [value]' for query or set LUFS Loop Verification (true, false).");
            Console.WriteLine("    Type 'check' or 'c' to check the current parameters.");
            Console.WriteLine("    Type 'exit' or 'quit' to exit.");
            Console.WriteLine();

            while (true)
            {
                Console.Write("File/Directory/Command> ");
                string input = string.Empty;
                while (string.IsNullOrEmpty(input))
                {
                    input = Console.ReadLine().Trim().Trim('"');
                }

                if (Directory.Exists(input))
                {
                    Console.WriteLine();
                    DirectoryInfo directoryInfo   = new DirectoryInfo(input);
                    string        outputDirectory = Path.Combine(directoryInfo.Parent.FullName, $"{directoryInfo.Name}_norm");
                    Directory.CreateDirectory(outputDirectory);

                    FileInfo[] fileInfos = directoryInfo.GetFiles();
                    for (int i = 0; i < fileInfos.Length; i++)
                    {
                        Console.WriteLine("{0}/{1}", i + 1, fileInfos.Length);
                        FileInfo fileInfo = fileInfos[i];
                        Normalization.Normalize(fileInfo.FullName, Path.Combine(outputDirectory, $"{Path.GetFileNameWithoutExtension(fileInfo.Name)}.wav"));
                        Console.WriteLine();
                    }
                    Console.WriteLine("Finnished!");
                }
                else if (File.Exists(input))
                {
                    Console.WriteLine();
                    Normalization.Normalize(input, Path.Combine(Path.GetDirectoryName(input), $"{Path.GetFileNameWithoutExtension(input)}_norm.wav"));
                    Console.WriteLine();
                    Console.WriteLine("Finnished!");
                }
                else
                {
                    if (!ProcessCommand(input))
                    {
                        Console.WriteLine("Unknow command");
                    }
                }
                Console.WriteLine();
            }
        }
Example #10
0
 public String Normalize(NormalizationForm normalizationForm)
 {
     return(Normalization.Normalize(this, normalizationForm));
 }
Example #11
0
			public Unit(Point point, Normalization norm) {
				this.point = point;
				this.norm = norm.Normalize (point);
			}
Example #12
0
 public static string Normalize(this string src)
 {
     return(Normalization.Normalize(src, 0));
 }
Example #13
0
        internal static Dictionary <DateTime, double> AnalyzeFinancialStatements(List <Catalog.FinancialStatement> statement, char[] analysis)
        {
            List <long> sale = new List <long>(), oper = new List <long>(), netincome = new List <long>(), flow = new List <long>();
            var         financial_statement = new Dictionary <DateTime, Tuple <long, long, long, long> >();
            var         dictionary          = new Dictionary <DateTime, double>();
            var         list                = new List <long>[] { sale, oper, netincome, flow };
            var         count               = 0;
            var         now = DateTime.Now;

            foreach (var fs in statement)
            {
                long sales = 0, operation = 0, net = 0, cash = 0;
                var  date = fs.Date.Substring(0, 5).Split('.');

                for (int i = 0; i < analysis.Length; i++)
                {
                    if (analysis[i].Equals('T'))
                    {
                        switch (i)
                        {
                        case 0:
                            sales = long.TryParse(fs.Revenues, out long revenues) ? revenues : long.MinValue;
                            break;

                        case 1:
                            operation = long.TryParse(fs.IncomeFromOperations, out long operations) ? operations : long.MinValue;
                            break;

                        case 2:
                            net = long.TryParse(fs.NetIncome, out long income) ? income : long.MinValue;
                            break;

                        case 3:
                            cash = long.TryParse(fs.OperatingActivities, out long activities) ? activities : long.MinValue;
                            break;

                        default:
                            continue;
                        }
                    }
                }
                if (int.TryParse(date[0], out int year) && int.TryParse(date[1], out int month))
                {
                    financial_statement[Base.IsTheSecondThursday(new DateTime(0x7D0 + year, month, DateTime.DaysInMonth(year + 0x7D0, month), 0xF, 0x1E, 0))]
                        = new Tuple <long, long, long, long>(sales, operation, net, cash);
                }
            }
            if (financial_statement.Count > 0)
            {
                foreach (var kv in financial_statement.OrderBy(o => o.Key))
                {
                    if (analysis[0].Equals('T'))
                    {
                        sale.Add(kv.Value.Item1);
                    }

                    if (analysis[1].Equals('T'))
                    {
                        oper.Add(kv.Value.Item2);
                    }

                    if (analysis[2].Equals('T'))
                    {
                        netincome.Add(kv.Value.Item3);
                    }

                    if (analysis[3].Equals('T'))
                    {
                        flow.Add(kv.Value.Item4);
                    }
                }
                for (int i = 0; i < analysis.Length; i++)
                {
                    if (analysis[i].Equals('T') && list[i].Count > 0)
                    {
                        count++;
                    }
                }

                foreach (var item in list)
                {
                    if (item.Count > 0 && item.TrueForAll(o => o == 0 || o == long.MinValue) == false)
                    {
                        var normal = new Normalization(item);
                        var index  = 0;

                        foreach (var kv in financial_statement.OrderBy(o => o.Key))
                        {
                            if (item[index] > long.MinValue)
                            {
                                if (dictionary.TryGetValue(kv.Key, out double normalize))
                                {
                                    dictionary[kv.Key] = normalize + normal.Normalize(item[index]) / count;
                                }

                                else
                                {
                                    dictionary[kv.Key] = normal.Normalize(item[index]) / count;
                                }
                            }
                            index++;
                        }
                    }
                }
                if (dictionary.Count > 4 && dictionary.Any(o => o.Key.Year == now.AddYears(now.Month > 3 ? 2 : 1).Year) == false)
                {
                    var temp   = EstimateThePrice(dictionary, now.AddYears(3).Year);
                    var normal = new Normalization(temp);
                    dictionary.Clear();

                    foreach (var kv in temp.OrderBy(o => o.Key))
                    {
                        if (kv.Value > normal.Min && kv.Value < normal.Max)
                        {
                            dictionary[kv.Key] = normal.Normalize(kv.Value);
                        }
                    }
                }
                if (dictionary.Count > 4 && dictionary.Any(o => o.Key.Year == now.AddYears(now.Month > 3 ? 2 : 1).Year))
                {
                    try
                    {
                        return(EstimateThePrice(dictionary, now));
                    }
                    catch (Exception ex)
                    {
                        Base.SendMessage(ex.StackTrace, typeof(Strategics));
                    }
                }
            }
            return(null);
        }