Terry's ORA Tips

Template Example – Extracting U.S. Place Names

This page created 4 Jul 2020

Version note: Applies to ORA 1.04

This article describes one of my example Templates for Online Repository Assistant (ORA). The other example Templates can be found in the index of Example Templates. Other articles in my ORA Section cover various topics about using the software. The "How it Works" section below includes links to articles describing the ORA features used in this Template.

Description:

The Templates described here extract the parts of a place name when the whole name is presented in a single field, and displays them separately. The examples are designed for place names in the United States, but the methods used could be adapted to place names elsewhere in the world. Because of the great variety of ways place names are constructed and how they are indexed by repositories, it is virtually impossible to write a template that will work in every case. The Templates described here deal with the simplest cases and leave for manual correction cases where they cannot extract the names correctly.

Example Output:

When a name appears in the field as: Chicago, Cook, Illinois, or as Chicago, Cook, Illinois, USA

City Name:

Chicago

County Name:

Cook Co.

State Name:

Illinois

Place parts that are not present in the field will produce no output, provided the following parts are in the order shown.

Type:

Text or Auto Type

Use:

For a Text Template, in the ORA Control Panel in the browser window containing the record of interest, click the  icon of this Template to copy the data to the clipboard. Then open the census event or citation data input screen of your genealogy program and paste it in the desired field.

If used as an Auto Type Template, place the cursor in the desired field in the genealogy program and click the appropriate Auto Type button in the ORA Control Panel, or include the segment as part of a more comprehensive Template.

Limitations:
How it Works:

The Templates are designed to ignore the name of the country, and to work with place name fields that may or may not include the country name. The Template segment below is part of each of the three templates, and uses the Assignment Variable and the :replace Transform to remove the country name if present:

[=:Residence:[Residence:replace:, USA::l]]
[=:Residence:[Residence:replace:, United States::l]]

The Assignment Variable is being used to assign to the "Residence" field the value of itself after applying the :replace Transform. The modified contents of the "Residence" field is then used in the following segments to separate out the desired parts of the field. Doing this first means we do not need to know whether or not the country name is present in the field, so the count of parts used below works regardless of whether or not the country name is present.

The :replace Transform here uses all three of the possible parameters. The first is the string to be searched for, the name of the country. The second is empty, indicating that the search string, if found, is to be replaced with nothing. The third is the letter " l " to make the search literal, rather than using a Regular Expression, so that any characters having special meaning to a Regular Expression, if present, are ignored.

In this case two forms of the country name are being tested. Since each test that does not find a match in the field is ignored, as many variations as desired can be tested.

If you know that the country name will never appear in the place string these terms can be omitted and only the segments below used. If you know the country name will always be included these terms can be omitted and each of the "count" numbers in the segments below increased by one.

The segments that differ for the three Templates are described below. These segments use the :split Transform to extract the place name parts, then output the desired parts:

City Name:

The template extracts the third from last name parts to find the city name, using the :split Transform:

[Residence:split:,:-3]

The :split Transform requires two parameters. The first here is a comma, because the place name parts are separated by commas. The second parameter is the number representing the position of the part that is desired. The minus sign indicates the counting is from the end, not the beginning, of the field. Counting from the end is used so that the state, and if present the county, will produce correct results when the city name is missing.

County Name:

This template extracts the next-to-last name part using the :split Transform:

<[Residence:split: :-2] Co.>

This segment is enclosed in Conditional brackets so that if there is no county name the text "Co." will not appear in the output.

State Name:

This template extracts the last name part using the :split Transform:

[Residence:split: :-1]
 
Template:

The following are the complete Templates. They can be copied from the area below and pasted into either a Text Template or Auto Type Template in the OraSettings window. For details on creating a Template, see my article on Template Basics.  The separation of the coding into "paragraphs" below is used only to make the coding easier to understand. The paragraph breaks are ignored by ORA when the Template is used.

City Name:

[=:Residence:[Residence:replace:, USA::l]]

[=:Residence:[Residence:replace:, United States::l]]

[Residence:split:,:-3]

County Name:

[=:Residence:[Residence:replace:, USA::l]]

[=:Residence:[Residence:replace:, United States::l]]

<[Residence:split:,:-2] Co.>

State Name:

[=:Residence:[Residence:replace:, USA::l]]

[=:Residence:[Residence:replace:, United States::l]]

[Residence:split:,:-1]

 

ReigelRidge Home Terry's Tips Home Contact Terry

 

 

Copyright 2000- by Terry Reigel