private void FindStreetNamesByKadStreetCode(AddressMatchBuilder results) { if (string.IsNullOrWhiteSpace(results?.Query.KadStreetNameCode)) { return; } foreach (var municipalityWrapper in results) { municipalityWrapper .AddStreetNames( _streetNameService .GetStreetNamesByKadStreet( results.Query.KadStreetNameCode, municipalityWrapper.NisCode)); } var searchName = results ?.Query ?.StreetName ?.RemoveDiacritics(); if (!string.IsNullOrEmpty(results?.Query?.StreetName) && !results.AllStreetNames().Any(w => !string.IsNullOrWhiteSpace(w.StreetName.NameDutchSearch) && w.StreetName.NameDutchSearch.EqIgnoreCase(searchName) || !string.IsNullOrWhiteSpace(w.StreetName.NameFrenchSearch) && w.StreetName.NameFrenchSearch.EqIgnoreCase(searchName) || !string.IsNullOrWhiteSpace(w.StreetName.NameGermanSearch) && w.StreetName.NameGermanSearch.EqIgnoreCase(searchName) || !string.IsNullOrWhiteSpace(w.StreetName.NameEnglishSearch) && w.StreetName.NameEnglishSearch.EqIgnoreCase(searchName))) { _warnings.AddWarning("7", "Geen overeenkomst tussen 'KadStraatcode' en 'Straatnaam'."); } }
private void FindStreetNamesByRrStreetCode(AddressMatchBuilder results) { var streetName = _streetNameService .GetStreetNameByRrStreet( results.Query.RrStreetCode, results.Query.PostalCode); if (streetName != null) { results .Where(g => g.PostalCode == results.Query.PostalCode) .ToList() .ForEach(g => g.AddStreetName(streetName)); } var searchName = results ?.Query ?.StreetName ?.RemoveDiacritics(); if (!string.IsNullOrEmpty(results?.Query?.StreetName) && !results.AllStreetNames().Any(w => !string.IsNullOrWhiteSpace(w.StreetName.NameDutchSearch) && w.StreetName.NameDutchSearch.EqIgnoreCase(searchName) || !string.IsNullOrWhiteSpace(w.StreetName.NameFrenchSearch) && w.StreetName.NameFrenchSearch.EqIgnoreCase(searchName) || !string.IsNullOrWhiteSpace(w.StreetName.NameGermanSearch) && w.StreetName.NameGermanSearch.EqIgnoreCase(searchName) || !string.IsNullOrWhiteSpace(w.StreetName.NameEnglishSearch) && w.StreetName.NameEnglishSearch.EqIgnoreCase(searchName))) { _warnings.AddWarning("7", "Geen overeenkomst tussen 'RrStraatcode' en 'Straatnaam'."); } }
protected override AddressMatchBuilder DoMatchInternal(AddressMatchBuilder results) { if (!string.IsNullOrEmpty(results.Query.KadStreetNameCode)) { FindStreetNamesByKadStreetCode(results); } if (!string.IsNullOrEmpty(results.Query.RrStreetCode) && !string.IsNullOrEmpty(results.Query.PostalCode)) { FindStreetNamesByRrStreetCode(results); } if (!string.IsNullOrEmpty(results.Query.StreetName)) { Dictionary <string, List <StreetNameLatestItem> > municipalityWithStreetNames = _latestQueries.GetLatestStreetNamesBy(results.Select(g => g.Name).ToArray()).GroupBy(s => s.NisCode).ToDictionary(g => g.Key, g => g.ToList()); FindStreetNamesByName(results, municipalityWithStreetNames); if (!IsValidMatch(results)) { FindStreetNamesByNameToggleAbreviations(results, municipalityWithStreetNames); } if (!IsValidMatch(results)) { FindStreetNamesByFuzzyMatch(results, municipalityWithStreetNames); } if (!IsValidMatch(results)) { FindStreetNamesByFuzzyMatchToggleAbreviations(results, municipalityWithStreetNames); } if (!IsValidMatch(results) && results.Query.StreetName.Length > 3) { FindStreetNamesByStreetNameContainsInput(results, municipalityWithStreetNames); } if (!IsValidMatch(results) && results.Query.StreetName.Length > 3) { FindStreetNamesByInputContainsStreetName(results, municipalityWithStreetNames); } } if (!IsValidMatch(results)) { _warnings.AddWarning("10", "'Straatnaam' niet interpreteerbaar."); //foreach (var gemeente in results) // _telemetry.TrackStraatnaamMatch(gemeente.Naam, results.Query.Straatnaam, results.Query.KadStraatcode, results.Query.RrStraatcode, 0, (int)StraatnaamMatchLevel.NoMatch); } else if (results.AllStreetNames().Count() > _config.MaxStreetNamesThreshold) { _warnings.AddWarning("100", "Uw zoekopdracht is te generiek"); results.ClearAllStreetNames(); } return(results); }
private void FindStreetNamesByKadStreetCode(AddressMatchBuilder results) { foreach (var municipalityWrapper in results) { municipalityWrapper.AddStreetNames(_streetNameService.GetStreetNamesByKadStreet(results.Query.KadStreetNameCode, municipalityWrapper.NisCode)); //_telemetry.TrackStraatnaamMatch(gemeente.Naam, results.Query.Straatnaam, results.Query.KadStraatcode, results.Query.RrStraatcode, gemeente.Count(), (int)StraatnaamMatchLevel.KadStraatCode); } if (!string.IsNullOrEmpty(results.Query.StreetName) && !results.AllStreetNames().Any(w => w.StreetName.NameDutch.EqIgnoreCase(results.Query.StreetName))) { _warnings.AddWarning("7", "Geen overeenkomst tussen 'KadStraatcode' en 'Straatnaam'."); } }
private void FindStreetNamesByRrStreetCode(AddressMatchBuilder results) { var streetName = _streetNameService.GetStreetNameByRrStreet(results.Query.RrStreetCode, results.Query.PostalCode); if (streetName != null) { results.Where(g => g.PostalCode == results.Query.PostalCode).ToList().ForEach(g => g.AddStreetName(streetName)); //_telemetry.TrackStraatnaamMatch(results.Where(g => g.Postcode == results.Query.Postcode).FirstOrDefault()?.Naam, results.Query.Straatnaam, results.Query.KadStraatcode, results.Query.RrStraatcode, 1, (int)StraatnaamMatchLevel.RrStraatCode); } if (!string.IsNullOrEmpty(results.Query.StreetName) && !results.AllStreetNames().Any(w => w.StreetName.NameDutch.EqIgnoreCase(results.Query.StreetName))) { _warnings.AddWarning("7", "Geen overeenkomst tussen 'RrStraatcode' en 'Straatnaam'."); } }
protected override AddressMatchBuilder?DoMatchInternal(AddressMatchBuilder?results) { if (!string.IsNullOrEmpty(results?.Query.KadStreetNameCode)) { FindStreetNamesByKadStreetCode(results); } if (!string.IsNullOrEmpty(results?.Query.RrStreetCode) && !string.IsNullOrEmpty(results.Query.PostalCode)) { FindStreetNamesByRrStreetCode(results); } if (!string.IsNullOrEmpty(results?.Query.StreetName)) { var municipalityWithStreetNames = _latestQueries .GetLatestStreetNamesBy( results .Select(g => g.Name) .ToArray()) .Where(s => s.NisCode != null) .GroupBy(s => s.NisCode !) .ToDictionary(g => g.Key, g => g.ToList()); FindStreetNamesByName(results, municipalityWithStreetNames); var isValidStreetnameMatch = IsValidMatch(results); if (isValidStreetnameMatch.HasValue && !isValidStreetnameMatch.Value) { FindStreetNamesByNameToggleAbreviations(results, municipalityWithStreetNames); } isValidStreetnameMatch = IsValidMatch(results); if (isValidStreetnameMatch.HasValue && !isValidStreetnameMatch.Value) { FindStreetNamesByFuzzyMatch(results, municipalityWithStreetNames); } isValidStreetnameMatch = IsValidMatch(results); if (isValidStreetnameMatch.HasValue && !isValidStreetnameMatch.Value) { FindStreetNamesByFuzzyMatchToggleAbreviations(results, municipalityWithStreetNames); } isValidStreetnameMatch = IsValidMatch(results); if (isValidStreetnameMatch.HasValue && !isValidStreetnameMatch.Value && results.Query.StreetName.Length > 3) { FindStreetNamesByStreetNameContainsInput(results, municipalityWithStreetNames); } isValidStreetnameMatch = IsValidMatch(results); if (isValidStreetnameMatch.HasValue && !isValidStreetnameMatch.Value && results.Query.StreetName.Length > 3) { FindStreetNamesByInputContainsStreetName(results, municipalityWithStreetNames); } } var validMatch = IsValidMatch(results); if (validMatch.HasValue && !validMatch.Value) { _warnings.AddWarning("10", "'Straatnaam' niet interpreteerbaar."); } else if (results?.AllStreetNames().Count() > _config.MaxStreetNamesThreshold) { _warnings.AddWarning("100", "Uw zoekopdracht is te generiek"); results.ClearAllStreetNames(); } return(results); }
protected override IReadOnlyList <TResult>?BuildResultsInternal(AddressMatchBuilder?results) => results? .AllStreetNames() .Select(w => _mapper.Map(w.StreetName)) .ToList();
protected override bool?IsValidMatch(AddressMatchBuilder?matchResult) => matchResult?.AllStreetNames().Any();