public void testRetrievingContent() { var sample = new SentenceSample("1. 2.", new Span(0, 2), new Span(3, 5)); Assert.AreEqual("1. 2.", sample.Document); Assert.AreEqual(new Span(0, 2), sample.Sentences[0]); Assert.AreEqual(new Span(3, 5), sample.Sentences[1]); }
private void RenderSentence(string word, SentenceSample sentence, Paragraph english, Paragraph chinese) { string eng = sentence.English; Regex wordReg = new Regex(word, RegexOptions.IgnoreCase); MatchCollection matches = wordReg.Matches(eng); int lastIndex = 0; string substr; Run run; foreach (Match match in matches) { substr = eng.Substring(lastIndex, match.Index - lastIndex); if (substr.Length > 0) { run = new Run() { Text = substr }; english.Inlines.Add(run); } if (match.Length > 0) { run = new Run() { Text = match.Value }; ApplyHighlightStyle(run); english.Inlines.Add(run); } lastIndex = match.Index + match.Length; } substr = eng.Substring(lastIndex); if (substr.Length > 0) { run = new Run() { Text = substr }; english.Inlines.Add(run); } string chn = sentence.Chinese; run = new Run() { Text = chn }; chinese.Inlines.Add(run); }
public DummySD(SentenceSample sample) { this.sample = sample; }
public DummySd(SentenceSample sample) { this.sample = sample; }