<def name="GenZIP"> <alt ref="Postcode" /> </def> <def name="Postcode"> <alt> <elt ref="PC_A" weight="50"/> <elt ref="PC_B" pre_separator="optional" weight="50"/> </alt> </def> <def name="PC_A"> <alt>`[a-zA-Z][0-9][a-zA-Z]`</alt> </def> <def name="PC_B"> <alt>`[0-9][a-zA-Z][0-9]`</alt> </def>
<def name="GenZIP"> <alt ref="Postcode" /> </def> <def name="Postcode"> <alt> <alt>`[a-zA-Z][0-9][a-zA-Z][0-9][a-zA-Z][0-9]`</alt> <alt>`[a-zA-Z][0-9][a-zA-Z][ ][0-9][a-zA-Z][0-9]`</alt> </alt> </def>
Solved! Go to Solution.
<section desc="Zones"> ... <def name="GenPostal"> <alt ref="FSALDU" /> <alt> <elt ref="Fsa"/> <elt ref="OptLdu"/> </alt> </def> <def name="Fsa"> <alt>`[a-zA-Z][0-9][a-zA-Z]`</alt> </def> <def name="Ldu"> <alt>`[0-9][a-zA-Z][0-9]`</alt> <alt>`[0-9][a-zA-Z]`</alt> <alt>`[0-9]`</alt> </def> <def name="FSALDU"> <alt> <elt ref="Fsa" weight="100"/> <elt ref="OptHyphen" weight="0"/> <elt ref="Ldu" weight="50" pre_separator="optional"/> </alt> </def> <def name="OptLdu"> <alt/> <alt fallback="true"> <elt ref="OptHyphen" weight="0"/> <elt ref="Ldu" weight="50" pre_separator="optional"/> </alt> <alt fallback="true"> <elt ref="word" pre_separator="none"/> </alt> </def> </section> <section desc="ZonesNoSearch"> ... <def name="OptPostalNoSearch"> <alt> <elt ref="GenPostalNoSearch"/> </alt> <alt/> </def> <def name="GenPostalNoSearch"> <alt> <elt ref="FSANoSearch" match_as="Fsa"/> <elt ref="OptLdu"/> </alt> <alt fallback="true"> <elt ref="FSANoSearch" match_as="Fsa" /> <elt ref="word" pre_separator="none"/> </alt> </def> <def name="FSANoSearch"> <alt>`[a-zA-Z][0-9][a-zA-Z]`</alt> </def> </section>
<def name="GenZIP"> <alt ref="Postcode" /> </def> <def name="Postcode"> <alt> `[a-zA-Z][0-9][a-zA-Z] ?[0-9][a-zA-Z][0-9]` </alt> </def>
What about this simple expression to include an optional space?<def name="GenZIP"> <alt ref="Postcode" /> </def> <def name="Postcode"> <alt> `[a-zA-Z][0-9][a-zA-Z] ?[0-9][a-zA-Z][0-9]` </alt> </def>
I am worried about the large alias problem for performance. What takes so long?
Are you using an include statement or are you actually pasting in the alternatives?
Do you duplicate the reference features to handle the same (only different by a space) postcodes?
The key point is that the reference data has to have both forms, all the geocode does is score them when found, based on the regular expression filter.
<alias_def> <alt>X0X0X0</alt> <alt>X0X 0X0</alt> </alias_def>
Placename alias tables are really for use with a set of Vanity Addresses. These are well known landmarks used instead of a real address. The alternative way to handle these would be to create a composite locator with the placenames as points and keep the real address as an alternative field.
They are not really designed for parsing address components for matching and scoring.
<section desc="Zones"> ... <def name="GenPostal"> <alt ref="FSALDU" /> <alt> <elt ref="Fsa"/> <elt ref="OptLdu"/> </alt> </def> <def name="Fsa"> <alt>`[a-zA-Z][0-9][a-zA-Z]`</alt> </def> <def name="Ldu"> <alt>`[0-9][a-zA-Z][0-9]`</alt> <alt>`[0-9][a-zA-Z]`</alt> <alt>`[0-9]`</alt> </def> <def name="FSALDU"> <alt> <elt ref="Fsa" weight="100"/> <elt ref="OptHyphen" weight="0"/> <elt ref="Ldu" weight="50" pre_separator="optional"/> </alt> </def> <def name="OptLdu"> <alt/> <alt fallback="true"> <elt ref="OptHyphen" weight="0"/> <elt ref="Ldu" weight="50" pre_separator="optional"/> </alt> <alt fallback="true"> <elt ref="word" pre_separator="none"/> </alt> </def> </section> <section desc="ZonesNoSearch"> ... <def name="OptPostalNoSearch"> <alt> <elt ref="GenPostalNoSearch"/> </alt> <alt/> </def> <def name="GenPostalNoSearch"> <alt> <elt ref="FSANoSearch" match_as="Fsa"/> <elt ref="OptLdu"/> </alt> <alt fallback="true"> <elt ref="FSANoSearch" match_as="Fsa" /> <elt ref="word" pre_separator="none"/> </alt> </def> <def name="FSANoSearch"> <alt>`[a-zA-Z][0-9][a-zA-Z]`</alt> </def> </section>