void AnnotateMappingAndConvertToXhtml(ContentsMapping chapterMapping) { var xhtmlParagraphs = new List <XElement>(); foreach (var plainTextLine in chapterMapping.PlainTextContent) { foreach (var sentence in _sentenceBreaker.BreakToSentences(plainTextLine)) { IList <string> lines; using (var reader = _mecabBackend.ParseText(sentence)) { lines = _reader.ReadResponse(reader); } var words = new List <WordInfo>(); foreach (var line in lines) { var word = _parser.ParseWord(line); word.Translation = _dicReader.Lookup(word.RootForm); words.Add(word); } xhtmlParagraphs.Add(_xhtmlMaker.MakeParagraph(words.Select(w => _xhtmlMaker.MakeWord(w)))); xhtmlParagraphs.Add(_xhtmlMaker.MakeContextHelpParagraph(words.DistinctBy(w => w.Text))); words.Clear(); } } chapterMapping.XhtmlContent = _xhtmlMaker.MakeRootNode(xhtmlParagraphs); }
void Copy(List <string> source, ContentsMapping target) { for (int i = 0; i < target.LengthInLines && target.StartLine + i < source.Count; i++) { target.PlainTextContent.Add(source[target.StartLine + i]); } }