Esempio n. 1
0
            public Action <TextWriter> GetTopicSummaryWriter(VBuffer <ReadOnlyMemory <char> > mapping)
            {
                Action <TextWriter> writeAction;

                if (mapping.Length == 0)
                {
                    writeAction =
                        writer =>
                    {
                        for (int i = 0; i < _ldaTrainer.NumTopic; i++)
                        {
                            KeyValuePair <int, float>[] topicSummaryVector = _ldaTrainer.GetTopicSummary(i);
                            writer.Write("{0}\t{1}\t", i, topicSummaryVector.Length);
                            foreach (KeyValuePair <int, float> p in topicSummaryVector)
                            {
                                writer.Write("{0}:{1}\t", p.Key, p.Value);
                            }
                            writer.WriteLine();
                        }
                    };
                }
                else
                {
                    writeAction =
                        writer =>
                    {
                        ReadOnlyMemory <char> slotName = default;
                        for (int i = 0; i < _ldaTrainer.NumTopic; i++)
                        {
                            KeyValuePair <int, float>[] topicSummaryVector = _ldaTrainer.GetTopicSummary(i);
                            writer.Write("{0}\t{1}\t", i, topicSummaryVector.Length);
                            foreach (KeyValuePair <int, float> p in topicSummaryVector)
                            {
                                mapping.GetItemOrDefault(p.Key, ref slotName);
                                writer.Write("{0}[{1}]:{2}\t", p.Key, slotName, p.Value);
                            }
                            writer.WriteLine();
                        }
                    };
                }

                return(writeAction);
            }
Esempio n. 2
0
 internal KeyValuePair <int, float>[] DescribeTopic(int topicID)
 {
     return(_ldaTrainer.GetTopicSummary(topicID));
 }