예제 #1
0
    public LocaleParameters Resolve(string textId, string localeName = null)
    {
        Dictionary <string, LocaleParameters> dictionary = (!(localeName == "en-EN")) ? this.activeTranslations : this.englishTranslations;

        if (!dictionary.ContainsKey(textId) || dictionary[textId].translation == string.Empty)
        {
            LocaleParameters localeParameters = new LocaleParameters();
            localeParameters.translation = textId;
            return(localeParameters);
        }
        return(dictionary[textId]);
    }
예제 #2
0
    private LocaleParameters FormulateTranslation(XElement xn)
    {
        LocaleParameters localeParameters = new LocaleParameters();

        localeParameters.translation = xn.Value;
        XAttribute xattribute  = xn.Attribute("character_size");
        XAttribute xattribute2 = xn.Attribute("line_spacing");

        if (xattribute != null)
        {
            localeParameters.characterSizeFactor = float.Parse(xattribute.Value, CultureInfo.InvariantCulture);
        }
        if (xattribute2 != null)
        {
            localeParameters.lineSpacingFactor = float.Parse(xattribute2.Value, CultureInfo.InvariantCulture);
        }
        return(localeParameters);
    }
예제 #3
0
        private IEnumerable <LocaleParameters> EnumerateParametersReport(
            IReportsService reportsService,
            DatabaseContext databaseContext,
            GetParametersReportQuery query)
        {
            for (int neighbours = query.MinNeighbours; neighbours <= query.MaxNeighbours; neighbours += query.NeighboursStep)
            {
                for (double wifiWeight = query.MinWifiWeight; wifiWeight <= query.MaxWifiWeight; wifiWeight += query.WifiWeightStep)
                {
                    for (double bleWeight = query.MinBleWeight; bleWeight <= query.MaxBleWeight; bleWeight += query.BleWeightStep)
                    {
                        for (double magnetometerWeight = query.MinMagnetometerWeight; magnetometerWeight <= query.MaxMagnetometerWeight; magnetometerWeight += query.MagnetometerWeightStep)
                        {
                            for (double unmatchedSignalsWeight = query.MinUnmatchedSignalsWeight; unmatchedSignalsWeight <= query.MaxUnmatchedSignalsWeight; unmatchedSignalsWeight += query.UnmatchedSignalsWeightStep)
                            {
                                for (double standardDeviationFactor = query.MinStandardDeviationFactor; standardDeviationFactor <= query.MaxStandardDeviationFactor; standardDeviationFactor += query.StandardDeviationFactorStep)
                                {
                                    var command = new GetPrecisionReportQuery();
                                    command.LocaleId = query.LocaleId;
                                    command.UnmatchedSignalsWeight = unmatchedSignalsWeight;
                                    command.BleWeight               = bleWeight;
                                    command.WifiWeight              = wifiWeight;
                                    command.Neighbours              = neighbours;
                                    command.MagnetometerWeight      = magnetometerWeight;
                                    command.UseDistance             = query.UseDistance;
                                    command.StandardDeviationFactor = standardDeviationFactor;
                                    var data     = reportsService.GetPrecisionReport(command);
                                    var error    = 0.0;
                                    var n        = 0;
                                    var missings = 0;
                                    foreach (var estimation in data)
                                    {
                                        if (estimation.CalculatedX != 0 && estimation.CalculatedY != 0)
                                        {
                                            error += estimation.Error;
                                            n++;
                                        }
                                        else
                                        {
                                            missings++;
                                        }
                                    }

                                    var parametersAnalysis = new LocaleParameters()
                                    {
                                        LocaleId                = command.LocaleId,
                                        BleWeight               = command.BleWeight,
                                        WifiWeight              = command.WifiWeight,
                                        MagnetometerWeight      = command.MagnetometerWeight,
                                        MeanError               = error / n,
                                        Neighbours              = command.Neighbours,
                                        UnmatchedSignalsWeight  = command.UnmatchedSignalsWeight,
                                        StandardDeviationFactor = command.StandardDeviationFactor,
                                        Missings                = missings,
                                        UseDistance             = command.UseDistance
                                    };

                                    databaseContext.Add(parametersAnalysis);
                                    Console.WriteLine(JsonSerializer.Serialize(parametersAnalysis));

                                    yield return(parametersAnalysis);
                                }
                            }
                        }
                    }
                }

                databaseContext.SaveChanges();
            }
        }