/// <summary>
        /// Creates a new sense instance from a source sense with properties that occur on all sense types.
        /// </summary>
        private T ParseGeneralSenseProperties <T>(Response.SenseBase sourceSense)
            where T : SenseBase, new()
        {
            var sense = new T();

            if (sourceSense.GeneralLabels.Any())
            {
                sense.GeneralLabels = new List <Label>();
                foreach (var generalLabel in sourceSense.GeneralLabels)
                {
                    sense.GeneralLabels.Add(generalLabel);
                }
            }

            if (sourceSense.SubjectStatusLabels.Any())
            {
                sense.SubjectStatusLabels = new List <Label>();
                foreach (var subjectStatusLabel in sourceSense.SubjectStatusLabels)
                {
                    sense.SubjectStatusLabels.Add(subjectStatusLabel);
                }
            }

            if (!string.IsNullOrEmpty(sourceSense.SenseSpecificGrammaticalLabel))
            {
                sense.SenseSpecificGrammaticalLabel = sourceSense.SenseSpecificGrammaticalLabel;
            }

            if (sourceSense.Variants.Any())
            {
                sense.Variants = VariantHelper.Parse(sourceSense.Variants, _language, _parseOptions.AudioFormat).ToList();
            }

            if (sourceSense.Pronunciations.Any())
            {
                sense.Pronunciations = new List <Pronunciation>();
                foreach (var pronunciation in sourceSense.Pronunciations)
                {
                    sense.Pronunciations.Add(PronunciationHelper.Parse(pronunciation, _language, _parseOptions.AudioFormat));
                }
            }

            if (sourceSense.Inflections.Any())
            {
                sense.Inflections = InflectionHelper.Parse(sourceSense.Inflections, _language, _parseOptions.AudioFormat).ToList();
            }

            if (sourceSense.Etymologies.Any())
            {
                sense.Etymology = sourceSense.Etymologies.ParseEtymology();
            }

            return(sense);
        }
        private static IEnumerable <UndefinedRunOn> ParseUros(Entry result, Response.UndefinedRunOn [] uros, ParseOptions options)
        {
            var searchResults = new List <UndefinedRunOn>();

            foreach (var uro in uros)
            {
                var searchResult = new UndefinedRunOn
                {
                    EntryWord    = uro.EntryWord,
                    PartOfSpeech = uro.FunctionalLabel
                };

                if (uro.GeneralLabels.Any())
                {
                    searchResult.GeneralLabels = new List <Label>();
                    foreach (var generalLabel in uro.GeneralLabels)
                    {
                        searchResult.GeneralLabels.Add(generalLabel);
                    }
                }

                if (uro.Sls.Any())
                {
                    searchResult.SubjectStatusLabels = new List <Label>();
                    foreach (var sls in searchResult.SubjectStatusLabels)
                    {
                        searchResult.SubjectStatusLabels.Add(sls);
                    }
                }

                if (uro.Pronunciations.Any())
                {
                    searchResult.Pronunciations = new List <Pronunciation>();
                    foreach (var pronunciation in uro.Pronunciations)
                    {
                        var pron = PronunciationHelper.Parse(pronunciation, result.Metadata.Language,
                                                             options.AudioFormat);
                        searchResult.Pronunciations.Add(pron);
                    }
                }

                if (uro.AlternateEntry != null)
                {
                    searchResult.AlternateEntry = new AlternateUndefinedEntryWord
                    {
                        Text        = uro.AlternateEntry.Text,
                        TextCutback = uro.AlternateEntry.TextCutback
                    };
                }

                if (uro.Vrs.Any())
                {
                    searchResult.Variants = VariantHelper.Parse(uro.Vrs, result.Metadata.Language, options.AudioFormat).ToList();
                }

                if (uro.Inflections.Any())
                {
                    searchResult.Inflections = InflectionHelper.Parse(uro.Inflections, result.Metadata.Language, options.AudioFormat).ToList();
                }

                searchResults.Add(searchResult);
            }

            return(searchResults);
        }
        private static Entry CreateSearchResult(Response.DictionaryEntry result, ParseOptions options)
        {
            var searchResult = new Entry
            {
                Metadata     = result.ParseMetadata(),
                PartOfSpeech = result.FunctionalLabel ?? string.Empty,
                ShortDefs    = result.Shortdefs,
                Homograph    = result.Homograph.GetValueOrDefault()
                               // TODO
                               //Synonyms = result.Metadata.Synonyms.SelectMany(s => s).ToList(),
                               //Antonyms = result.Metadata.Antonyms.SelectMany(s => s).ToList()
            };

            if (!string.IsNullOrEmpty(result.FunctionalLabel))
            {
                searchResult.PartOfSpeech = result.FunctionalLabel;
            }

            if (result.GeneralLabels.Any())
            {
                searchResult.GeneralLabels = new List <Label>();
                foreach (var generalLabel in result.GeneralLabels)
                {
                    searchResult.GeneralLabels.Add(generalLabel);
                }
            }

            if (result.SubjectStatusLabels.Any())
            {
                searchResult.SubjectStatusLabels = new List <Label>();
                foreach (var subjectStatusLabel in result.SubjectStatusLabels)
                {
                    searchResult.SubjectStatusLabels.Add(subjectStatusLabel);
                }
            }

            ParseBasicStuff(options, result, searchResult);

            searchResult.Conjugations = ParseConjugations(result.Supplemental);
            if (result.CrossReferences.Any())
            {
                searchResult.CrossReferences = CrossReferenceHelper.Parse(result.CrossReferences).ToList();
            }

            if (result.CognateCrossReferences.Any())
            {
                searchResult.CognateCrossReferences = CognateCrossReferenceHelper.Parse(result.CognateCrossReferences).ToList();
            }

            if (result.Inflections.Any())
            {
                searchResult.Inflections = InflectionHelper.Parse(result.Inflections, searchResult.Metadata.Language, options.AudioFormat).ToList();
            }

            if (result.Synonyms.Any())
            {
                searchResult.Synonyms = ParseSynonyms(result.Synonyms).ToList();
            }

            if (result.DirectionalCrossReferences.Any())
            {
                searchResult.DirectionalCrossReferences = new List <FormattedText>();
                foreach (var crossReference in result.DirectionalCrossReferences)
                {
                    searchResult.DirectionalCrossReferences.Add(new FormattedText(crossReference));
                }
            }

            if (result.Usages.Any())
            {
                searchResult.Usages = new List <Usage>();
                foreach (var srcUsage in result.Usages)
                {
                    var usage = new Usage
                    {
                        ParagraphLabel = srcUsage.ParagraphLabel
                    };

                    foreach (var complexTypeWrapper in srcUsage.ParagraphText)
                    {
                        var type = complexTypeWrapper[0].TypeLabelOrText;
                        if (type == DefiningTextTypes.Text)
                        {
                            usage.ParagraphTexts.Add(new DefiningText(complexTypeWrapper[1].TypeLabelOrText));
                        }
                        else if (type == DefiningTextTypes.VerbalIllustration)
                        {
                            foreach (var dt in complexTypeWrapper[1].DefiningTextComplexTypes)
                            {
                                usage.ParagraphTexts.Add(VisHelper.Parse(dt.DefiningText));
                            }
                        }
                        else if (type == DefiningTextTypes.InAdditionReference)
                        {
                            // TODO, requires sample json
                        }
                    }

                    searchResult.Usages.Add(usage);
                }
            }

            if (result.Table != null)
            {
                searchResult.Table = new Table
                {
                    Displayname = result.Table.Displayname,
                    TableId     = result.Table.Tableid
                };
            }

            if (result.Bios.Any())
            {
                searchResult.BiographicalNote = new BiographicalNote();
                foreach (var bioElement in result.Bios)
                {
                    foreach (var element in bioElement)
                    {
                        var typeOrText = element[0].TypeOrText;
                        if (typeOrText == "bionw")
                        {
                            var note    = element[1].BiographicalNote;
                            var content = new BiographicalNameWrap()
                            {
                                FirstName     = note.Biopname,
                                AlternateName = note.Bioname,
                                Surname       = note.Biosname
                            };

                            if (note.Prs.Any())
                            {
                                content.Pronunciations = new List <Pronunciation>();
                                foreach (var pronunciation in note.Prs)
                                {
                                    content.Pronunciations.Add(PronunciationHelper.Parse(pronunciation, searchResult.Metadata.Language, options.AudioFormat));
                                }
                            }

                            searchResult.BiographicalNote.Contents.Add(content);
                        }

                        else if (typeOrText == "biodate" || typeOrText == "text" || typeOrText == "biotx")
                        {
                            searchResult.BiographicalNote.Contents.Add(new DefiningText(element[1].TypeOrText));
                        }
                    }
                }
            }

            return(searchResult);
        }