Esempio n. 1
0
        public void AddParameter(ConfigEntry configEntry)
        {
            if (parametersMap.ContainsKey(configEntry.paramName))
            {
                parametersMap.Remove(configEntry.paramName);
            }

            parametersMap[configEntry.paramName] = configEntry.paramValue;
        }
Esempio n. 2
0
        public void AddParameterToSegment(ConfigEntry configEntry)
        {
            // Add the parameter to all segments
            if (configEntry.segment == -1)
            {
                for (int i = 0; i < segmentsList.Count; ++i)
                {
                    segmentsList[i].AddParameter(configEntry);
                }
            }

            // Add the parameter only to the specified market
            else
            {
                segmentsList[configEntry.segment].AddParameter(configEntry);
            }
        }
Esempio n. 3
0
        public void AddParameter(ConfigEntry configEntry)
        {
            if (configEntry.segmentGroup == (int)this.segmentGroupType ||
                configEntry.segmentGroup == -1 )
            {
                if (segmentGroupParametersMap.ContainsKey(configEntry.paramName))
                {
                    segmentGroupParametersMap.Remove(configEntry.paramName);
                }

                segmentGroupParametersMap[configEntry.paramName] = configEntry.paramValue;

                AddParameterToSegment(configEntry);
            }
        }
Esempio n. 4
0
        public void setSegmentParam(int segmentGroup, int segment, string paramName, string paramValue)
        {
            ConfigEntry entry = new ConfigEntry(segmentGroup, segment, paramName, paramValue.ToString());

            if (segmentParametersMap.Contains(entry))
            {
                segmentParametersMap.Remove(entry);
            }
            segmentParametersMap.Add(entry);

            segmentGroupMap[segmentGroup].AddParameterToSegment(entry);

            propogateParameters();
            parseParameters();
        }
Esempio n. 5
0
        public void setGlobalParam(string paramName, string paramValue)
        {
            ConfigEntry entry = new ConfigEntry(-1, -1, paramName, paramValue.ToString());
            if (globalParametersMap.Contains(entry))
            {
                globalParametersMap.Remove(entry);
            }

            globalParametersMap.Add(entry);

            propogateParameters();
            parseParameters();
        }
Esempio n. 6
0
        public void Initialize(string fn)
        {
            segmentGroupMap.Add((int)SegmentGroupType.MarketSegType, new SegmentGroup(SegmentGroupType.MarketSegType));
            segmentGroupMap.Add((int)SegmentGroupType.QueryIntentType, new SegmentGroup(SegmentGroupType.QueryIntentType));
            segmentGroupMap.Add((int)SegmentGroupType.FileFormatType, new SegmentGroup(SegmentGroupType.FileFormatType));
            segmentGroupMap.Add((int)SegmentGroupType.PageLayoutType, new SegmentGroup(SegmentGroupType.PageLayoutType));
            segmentGroupMap.Add((int)SegmentGroupType.VisitType, new SegmentGroup(SegmentGroupType.VisitType));

            using (TextReader reader = new HierarchicConfigStreamReader(fn))
            {
                string line;
                string currentSegmentGroup = "";
                string currentSegment = "";

                while ((line = reader.ReadLine()) != null)
                {
                    ConfigEntry entry = new ConfigEntry();

                    if (line.StartsWith("[") && line.EndsWith("]"))
                    {
                        // Global parameters
                        if (line.Equals("[Main]"))
                        {
                            continue;
                        }

                        // Segment Group section, e.g. [Market]
                        else if (!line.Contains(SEGMENT_TYPE_SEPARATOR))
                        {
                            currentSegmentGroup = line.Substring(1, (line.Length - 2));
                            currentSegment = "";
                        }

                        // Segment subsection, e.g. [Market*en_us]
                        else
                        {
                            int SegmentSeparatorCharIndex = line.IndexOf(SEGMENT_TYPE_SEPARATOR);

                            currentSegmentGroup = line.Substring(1, (SegmentSeparatorCharIndex - 1));
                            currentSegment = line.Substring((SegmentSeparatorCharIndex + 2), (line.Length - SegmentSeparatorCharIndex - 3));
                        }
                    }

                    // Line format is: paramName=value
                    else
                    {
                        int pos = line.IndexOf('=');
                        Common.Assert(pos > 0, "Invalid configuration line: \"" + line + "\"");

                        string paramName = line.Substring(0, pos);
                        string paramValue = line.Substring(pos + 1);

                        if (!(currentSegmentGroup == ""))
                        {
                            entry.segmentGroup = (int)Enum.Parse(typeof(SegmentGroupType), currentSegmentGroup, true);
                        }

                        if (!(currentSegment == ""))
                        {
                            entry.segment = getIndexForSegment((SegmentGroupType)entry.segmentGroup, currentSegment);
                        }

                        entry.paramName = paramName;
                        entry.paramValue = paramValue;

                        if (entry.segmentGroup == -1 && entry.segment == -1)
                        {
                            if (globalParametersMap.Contains(entry))
                            {
                                globalParametersMap.Remove(entry);
                            }

                            globalParametersMap.Add(entry);
                        }

                        else if (entry.segmentGroup != -1 && entry.segment == -1)
                        {
                            if (segmentGroupParametersMap.Contains(entry))
                            {
                                segmentGroupParametersMap.Remove(entry);
                            }

                            segmentGroupParametersMap.Add(entry);
                        }

                        else if (entry.segmentGroup != -1 && entry.segment != -1)
                        {
                            if (segmentParametersMap.Contains(entry))
                            {
                                segmentParametersMap.Remove(entry);
                            }

                            segmentParametersMap.Add(entry);
                        }
                    }
                }
            }

            /*
             *  At this point, all Parameters are read.
             *  Now, SegmentParameter objects will inherit the parameters from those lists obeying the rule:
             *
             *  if segmentParameter exists --> use segment parameter
             *  else if segmentGroupParameter exists --> use segmentGroupParameter
             *  else if globalParameter exists --> use globalParameter
             *  else --> use defaultValue
             */

            propogateParameters();
            parseParameters();
            SegEnabledMask = createEnabledMask();
            SegEnabled.Reset();
            SegEnabled.Aggregate(SegEnabledMask);
            initMinCutoffFilters();
        }