public IEnumerable <CodePoint> LookupByRadicals(IEnumerable <CodePoint> radicals)
 {
     return(radkfile.LookupMatching(radicals.Select(r => r.ToString()))
            .OrderBy(r => kanjidict.Lookup(r)
                     .Map(e => e.StrokeCount)
                     .ValueOr(int.MaxValue))
            .Select(cp => CodePoint.FromString(cp)));
 }
Example #2
0
        public Option <IEnumerable <CodePoint> > LookupRadicalsByKanji(Kanji kanji)
        {
            if (remapper == null)
            {
                return(kradfile.LookupRadicals(kanji.ToString())
                       .Map(radicals => radicals.Select(cp => CodePoint.FromString(cp))));
            }

            return(remapper
                   .LookupRadicals(kanji.ToString())
                   .Map(radicals => radicals.Select(cp => CodePoint.FromString(cp))));
        }
Example #3
0
        public IEnumerable <CodePoint> LookupKanjiByRadicals(IEnumerable <CodePoint> radicals, IKanjiOrdering ordering)
        {
            if (remapper == null)
            {
                return(radkfile
                       .LookupMatching(radicals.Select(s => s.ToString()))
                       .Select(r => CodePoint.FromString(r))
                       .OrderBy(x => x, ordering)
                       .ToList());
            }

            return(remapper
                   .LookupKanji(radicals.Select(s => s.ToString()))
                   .Select(r => CodePoint.FromString(r))
                   .OrderBy(x => x, ordering)
                   .ToList());
        }
        public IEnumerable <CodePoint> FindSimilar(CodePoint point)
        {
            var oppositeSizedCp = OppositeSizedVersionOf(point.Utf32);
            var oppositeSized   = (oppositeSizedCp != null
                ? Enumerable.Repeat(char.ConvertFromUtf32(oppositeSizedCp.Value), 1)
                : Enumerable.Empty <string>())
                                  .Select(s => CodePoint.FromString(s));

            mapping.TryGetValue(point.ToString(), out var restStr);
            restStr = restStr ?? new List <string>();

            // TOFIX: support combo kana
            var rest = restStr
                       .Where(s => s.Length == 1)
                       .Select(s => CodePoint.FromString(s));

            return(oppositeSized.Concat(rest));
        }
 public CodePoint LookupCharacter(string character, int position = 0)
 {
     return(CodePoint.FromString(character, position));
 }
        public IEnumerable <IGrouping <string, CodePoint> > FindRelated(CodePoint codePoint)
        {
            similar.TryGetValue(codePoint.ToString(), out var resultList);
            IEnumerable <string> result = resultList ?? Enumerable.Empty <string>();

            return(EnumerableExt.OfSingle(new CategoryGrouping <CodePoint>("Similar Kanji",
                                                                           result.Select(r => CodePoint.FromString(r)))));
        }