コード例 #1
0
        private static void ReorderByPartOfSpeech(List <JmdictEntity> results, WordInformation word)
        {
            if (results.Count < 2)
            {
                return;
            }

            string pos = word.GetPartOfSpeechInEnglish();

            if (String.IsNullOrEmpty(pos))
            {
                return;
            }

            List <JmdictEntity> removed = new List <JmdictEntity>();

            for (int i = 0; i < results.Count;)
            {
                if (word.IsVerb() &&
                    (!results[i].PartOfSpeech.Contains("Godan") || !results[i].PartOfSpeech.Contains("Ichidan"))
                    )
                {
                    removed.Add(results[i]);
                    results.RemoveAt(i);
                }
                else if (!results[i].PartOfSpeech.Contains(pos))
                {
                    removed.Add(results[i]);
                    results.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
            results.AddRange(removed);
        }