/// <summary> /// Writes the Viterbi lattice for the provided text to an output stream /// /// The output is written in <a href="https://en.wikipedia.org/wiki/DOT_(graph_description_language)">DOT</a> format. /// /// This method is not thread safe /// </summary> /// <param name="output">output stream to write to</param> /// <param name="text">text to create lattice for</param> public void DebugLattice(Stream output, string text) { var lattice = ViterbiBuilder.Build(text); using (var writer = new StreamWriter(output, Encoding.UTF8, 1024, true)) { writer.Write(ViterbiFormatter.Format(lattice)); } }
/// <summary> /// Tokenizes the provided text and outputs the corresponding Viterbi lattice and the Viterbi path to the provided output stream /// /// The output is written in <a href="https://en.wikipedia.org/wiki/DOT_(graph_description_language)">DOT</a> format. /// /// This method is not thread safe /// </summary> /// <param name="output">output stream to write to</param> /// <param name="text">text to tokenize</param> public void DebugTokenize(Stream output, string text) { var lattice = ViterbiBuilder.Build(text); var bestPath = ViterbiSearcher.Search(lattice); using (var writer = new StreamWriter(output, Encoding.UTF8, 1024, true)) { writer.Write(ViterbiFormatter.Format(lattice, bestPath)); } }