public RichTextNode ToRichTextNode(FengDocument doc) { var output = new RichTextNode() { VerticalContainer = new RichTextNode.Types.VerticalContainerNode() { Children = { SectionHeader(zc.tH(doc.HanziOriginal), RenderSourcePronunciations( ToFeng(doc.YngpingUnderlyingOriginal), ToFeng(doc.YngpingCanonicalOriginal))), } } }; if (doc.ExplanationStructured != null) { output.VerticalContainer.Children.Add(explanationRenderer.ToRichTextNode(doc.ExplanationStructured, doc.HanziCanonical)); } else { output.VerticalContainer.Children.Add(SimpleText(zc.tH(doc.Explanation))); } output.VerticalContainer.Children.Add(Source(zc.tM($"出处:冯爱珍. 1998. 福州方言词典. 南京: 江苏教育出版社. 第 {doc.Source.PageNumber} 页. 用字可能经过编辑修订."))); return(output); }
public RichTextNode ToRichTextNode(ContribDocument doc) { var output = new RichTextNode() { VerticalContainer = new RichTextNode.Types.VerticalContainerNode() { Children = { SectionHeader(doc.Hanzi, RenderSourcePronunciations(doc.YngpingUnderlying, doc.YngpingSandhi)), } } }; if (doc.ExplanationStructured != null) { output.VerticalContainer.Children.Add(explanationRenderer.ToRichTextNode(doc.ExplanationStructured, doc.Hanzi)); } else { output.VerticalContainer.Children.Add(SimpleText(zc.tH(doc.ExplanationRaw))); } output.VerticalContainer.Children.Add( Source(zc.tM("此释义来自网友贡献。 贡献者: " + string.Join(",", doc.Contributors))) ); return(output); }
public RichTextNode ToRichTextNode(HistoricalDocument doc) { var sources = new List <string>(); if (doc.CiklinSource != null) { sources.Add(zc.tM("戚林八音校注")); } if (doc.DfdSource != null) { sources.Add("榕腔注音辞典·目录"); } var children = new List <RichTextNode>(); children.Add(SectionHeader(zc.tH(HanziUtils.HanziToString(doc.HanziCanonical)))); children.Add(Label(zc.tM("音韵地位(戚林八音)"))); children.Add(SimpleText(PhonologyUtils.ToHanzi(doc.Initial, doc.Final, doc.Tone))); children.Add(Label(zc.tM("榕拼(八音)"))); children.Add(SimpleText(doc.Yngping)); children.Add(Label(zc.tM("教会罗马字"))); children.Add(SimpleText(doc.Buc)); if (!string.IsNullOrEmpty(doc.CiklinSource?.ExplanationCik)) { children.Add(Label(zc.tM("戚书释义"))); children.Add(SimpleText(zc.tM(doc.CiklinSource.ExplanationCik))); } if (!string.IsNullOrEmpty(doc.CiklinSource?.ExplanationLing)) { children.Add(Label(zc.tM("林书释义"))); children.Add(SimpleText(zc.tM(doc.CiklinSource.ExplanationLing))); } children.Add(Source(zc.tM("来源:" + string.Join(", ", sources)))); return(new RichTextNode() { VerticalContainer = new RichTextNode.Types.VerticalContainerNode() { Children = { children } } }); }
private IEnumerable <SearchV2Response.Types.SearchCard> RenderDocs(IEnumerable <ScoreDoc> scoreDocs, ZhConverter zhConverter) { var searcher = this._indexHolder.LuceneIndexSearcher; return(scoreDocs.Select(sd => { var docId = searcher.Doc(sd.Doc).GetField(LuceneUtils.Fields.DocId).GetStringValue(); var ydDoc = _indexHolder.GetIndex().YngdiengDocuments.Single(y => y.DocId == docId); return new SearchV2Response.Types.SearchCard { Word = new SearchV2Response.Types.SearchCard.Types.WordCard { Id = docId, Yngping = RichTextUtil.FromString(ydDoc.YngpingSandhi.OrElse(ydDoc.YngpingUnderlying)), Hanzi = RichTextUtil.FromString(zhConverter.tH(HanziUtils.HanziToString(ydDoc.HanziCanonical))), Details = RichTextUtil.FromString(zhConverter.tM(Yngdieng.Backend.Services.Frontend.Words.GetSnippet (ydDoc, new Extension[] { }))), Score = sd.Score } }; })); }
public RichTextNode ToRichTextNode(Explanation e, string currentWord = "~") { var output = new RichTextNode() { VerticalContainer = new RichTextNode.Types.VerticalContainerNode() { Children = { Label(zc.tM("释义")), new RichTextNode { List = new RichTextNode.Types.ListNode { Ordered = true, Children = { e.Senses.Select(s => ToRichTextNode(s, currentWord) ) } } } } } }; if (!string.IsNullOrEmpty(e.NotesOriginal)) { output.VerticalContainer.Children.Add(Label(zc.tM("注"))); output.VerticalContainer.Children.Add( SimpleTextWithOuterStyles(zc.tM(MaybeAddPeriod(e.NotesOriginal)), new string[] { "notes" })); } if (!string.IsNullOrEmpty(e.NotesOurs)) { output.VerticalContainer.Children.Add(Label(zc.tM("榕典注"))); output.VerticalContainer.Children.Add( SimpleTextWithOuterStyles(zc.tM(MaybeAddPeriod(e.NotesOurs)), new string[] { "notes" })); } return(output); }