예제 #1
0
 private static SearchV2Response.Types.SearchCard GenericMessageCard(string message)
 {
     return(new SearchV2Response.Types.SearchCard
     {
         GenericMessage = new SearchV2Response.Types.SearchCard.Types
                          .GenericMessageCard()
         {
             Message = RichTextUtil.FromString(message)
         }
     });
 }
예제 #2
0
        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
                    }
                };
            }));
        }