Example #1
0
 private string FindPostCode()
 {
     return((from word in WordsCleaned
             from sub in LocalityCache.Where(x => !string.IsNullOrWhiteSpace(x.Postcode))
             where sub.Postcode.Trim().ToLowerInvariant() == word
             select sub.Postcode).FirstOrDefault());
 }
Example #2
0
        public Locality Where(string sentence)
        {
            CreateNgrams(sentence);
            var locality = new Locality {
                Suburb = FindSuburb()
            };

            if (!string.IsNullOrWhiteSpace(locality.Suburb))
            {
                var exists = LocalityCache.FirstOrDefault(x => x.Suburb == locality.Suburb);
                if (exists != null)
                {
                    return(exists);
                }
            }

            locality.Postcode = FindPostCode();

            if (!string.IsNullOrWhiteSpace(locality.Postcode))
            {
                var exists = LocalityCache.FirstOrDefault(x => x.Postcode == locality.Postcode);
                if (exists != null)
                {
                    return(exists);
                }
            }

            if (!string.IsNullOrWhiteSpace(locality.Postcode))
            {
                locality.AustralianState = FindAustralianState().GetValueOrDefault();
            }

            return(locality);
        }