public ConsultWindow(TalesNetwork talesNetwork) : this() { Contract.Requires<ArgumentNullException>(talesNetwork != null); _talesNetwork = talesNetwork; TextAnalyzer textAnalyzer = new TextAnalyzer(AdapterKind.RussianCp1251Adapter); textAnalyzer.Load( @"Dictionaries\Russian\Dictionary.auto", @"Dictionaries\Russian\Paradigms.bin", @"Dictionaries\Russian\PredictionDictionary.auto"); _textGenerator = new TextGenerator(textAnalyzer); QuestionTextBox.Focus(); }
public ConsultWindow2(TalesNetwork network) { InitializeComponent(); _network = network; cmbTale.ItemsSource = _network.Tales; if (cmbTale.HasItems) cmbTale.SelectedIndex = 0; TextAnalyzer textAnalyzer = new TextAnalyzer(AdapterKind.RussianCp1251Adapter); textAnalyzer.Load( @"Dictionaries\Russian\Dictionary.auto", @"Dictionaries\Russian\Paradigms.bin", @"Dictionaries\Russian\PredictionDictionary.auto"); _textGenerator = new TextGenerator(textAnalyzer); }
public static void Main(string[] args) { TalesNetwork talesNetwork = CreateNetwork(); TextAnalyzer textAnalyzer = CreateTextAnalyzer(); TextGenerator textGenerator = new TextGenerator(textAnalyzer); Console.OutputEncoding = Encoding.UTF8; bool generateByNetwork = false; talesNetwork.SaveToXml().Save(@"C:\Temp\TalesNetwork.xml"); TalesNetwork loadedNetwork = new TalesNetwork(); loadedNetwork.LoadFromXml(XDocument.Load(@"C:\Temp\TalesNetwork.xml")); if (generateByNetwork) { string text = textGenerator.GenerateText(loadedNetwork.Tales[1]); Console.WriteLine(text); } else { File.WriteAllText(@"Output.txt", string.Empty); while (true) { TextGeneratorContext result = textGenerator.GenerateText(loadedNetwork, File.ReadAllText(@"Input.txt")); if (result != null) { string text = result.OutputText; File.AppendAllText(@"Output.txt", text + Environment.NewLine); Console.WriteLine(text); } Console.WriteLine("Press 'r' to repeat, 'q' to exit."); string input = Console.ReadLine(); if (input.ToLower() == "q") { break; } } } }