Append() public method

public Append ( string moreText ) : void
moreText string
return void
Esempio n. 1
0
        private static void CompressColumns(Dictionary<string, AggregationPolicy> aggregationPolicies, PoiService aggregate)
        {
            // Compress all keyword columns to a single column (this may be a setting later).
            var labelsWithKeywordAggregation = aggregationPolicies.Where(kv => kv.Value.IsKeywordAggregation).Select(kv => kv.Key);
            foreach (BaseContent poi in aggregate.PoIs)
            {
                WordHistogram sumHistogram = null;
                foreach (string label in labelsWithKeywordAggregation)
                {
                    string labelValue;
                    if (poi.Labels.TryGetValue(label, out labelValue))
                    {
                        WordHistogram wordHistogram = new WordHistogram();
                        wordHistogram.Append(labelValue);

                        if (sumHistogram == null)
                        {
                            sumHistogram = wordHistogram.Clone();
                        }
                        else
                        {
                            sumHistogram.Merge(wordHistogram);
                        }
                    }
                }
                if (sumHistogram != null)
                {
                    poi.Keywords = sumHistogram;
                }
            }

            // Remove all columns that have been compressed to keywords.
            foreach (BaseContent poI in aggregate.PoIs)
            {
                foreach (KeyValuePair<string, AggregationPolicy> kv in aggregationPolicies)
                {
                    if (!kv.Value.DataIsNumeric &&
                        kv.Value.NonNumericAggregationPolicy == AggregationPolicy.NonNumericAggregation.Keywords)
                    {
                        poI.Labels.Remove(kv.Key);
                    }
                }
            }

            // Remove obsolete labels; only in the PoiTypes; they are already gone from the Pois.
            foreach (BaseContent baseContent in aggregate.PoITypes)
            {
                List<string> toOmit = new List<string>();
                foreach (string label in baseContent.Labels.Keys)
                {
                    AggregationPolicy policy;
                    bool remove = true;
                    if (aggregationPolicies.TryGetValue(label, out policy))
                    {
                        if (!policy.IsOmit && 
                            !(policy.DataIsNumeric &&
                            policy.NonNumericAggregationPolicy == AggregationPolicy.NonNumericAggregation.Keywords))
                        {
                            remove = false;
                        }
                    }
                    if (remove)
                    {
                        toOmit.Add(label);
                    }
                }
                foreach (string label in toOmit)
                {
                    baseContent.Labels.Remove(label);
                }
            }
        }