geocoder_core/profile/
lu.rs1use once_cell::sync::Lazy;
8
9use super::fr::{SYNONYMS_SOURCE, france, phonemicize};
10use super::{FieldSpec, Profile, benelux};
11use crate::doc::Document;
12use crate::text::{Synonyms, Token};
13
14static SYNONYMS: Lazy<Synonyms> = Lazy::new(|| Synonyms::parse(SYNONYMS_SOURCE));
15
16const FILTERS: &[&str] = &["type", "citycode", "postcode"];
17
18pub struct LuProfile;
19
20impl Profile for LuProfile {
21 fn name(&self) -> &'static str {
22 "lu"
23 }
24
25 fn version(&self) -> u32 {
26 1
27 }
28
29 fn min_score(&self) -> f64 {
30 0.3
31 }
32
33 fn min_limit(&self) -> usize {
34 10
35 }
36
37 fn fields(&self) -> &[FieldSpec] {
38 super::fr::FIELDS
39 }
40
41 fn filters(&self) -> &[&'static str] {
42 FILTERS
43 }
44
45 fn synonyms(&self) -> Option<&Synonyms> {
46 Some(&SYNONYMS)
47 }
48
49 fn process_query(&self, query: &str) -> String {
50 france::remove_leading_zeros(&benelux::clean_query(query))
51 }
52
53 fn process_tokens(&self, tokens: Vec<Token>) -> Vec<Token> {
54 let tokens = benelux::glue_ordinal(tokens);
55 let tokens: Vec<Token> = tokens.into_iter().map(france::fold_ordinal).collect();
56 let tokens = benelux::flag_housenumber(tokens);
57 let tokens = SYNONYMS.apply(tokens);
58 tokens
59 .into_iter()
60 .map(|t| t.with_value(phonemicize(&t.value)))
61 .collect()
62 }
63
64 fn make_labels(&self, doc: &Document, housenumber: Option<&str>) -> Vec<String> {
65 france::make_labels(doc, housenumber)
66 }
67}