Exemplo n.º 1
0
                public MultiRepresentationWeightFunction <TDictionary> FromValues(IEnumerable <KeyValuePair <TSequence, double> > sequenceWeightPairs)
                {
                    var collection = sequenceWeightPairs as ICollection <KeyValuePair <TSequence, double> > ?? sequenceWeightPairs.ToList();

                    if (collection.Count == 0)
                    {
                        return(Zero());
                    }
                    if (collection.Count == 1 && collection.Single().Value == 1.0)
                    {
                        return(FromPoint(collection.Single().Key));
                    }
                    else
                    {
                        if (collection.Count <= MaxDictionarySize)
                        {
                            return(FromDictionary(DictionaryWeightFunction <TDictionary> .FromValues(sequenceWeightPairs)));
                        }
                        else
                        {
                            return(FromAutomaton(Automaton <TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton> .FromValues(collection)));
                        }
                    }
                }