Page 1 of 1
Sentence template
Posted: 04 Oct 2020 09:04
by mezentia
I am re-building my sentence template for passenger lists. It makes extensive use of =GetLabelledText to extract information from the note accompanying the event to build up a narrative sentence. My template, so far, looks like this:
<para>{individual} was listed on the {label} for the vessel {=GetLabelledText(%FACT.NOTE2%,"Vessel:")} <sailing from {=GetLabelledText(%FACT.NOTE2%,"Leaving from:")}>< arriving at {=GetLabelledText(%FACT.NOTE2%,"Arriving at:")}>< with a final destination of {=GetLabelledText(%FACT.NOTE2%,"Final destination:")}>. < {individual} last permanent place of residence was {=GetLabelledText(%FACT.NOTE2%,"Previous residence:")}>
However, how do I prevent the appropriate part of the sentence being displayed when the labelled text is missing? Then, how do I get the second sentence to start "His ..." rather than "he ..."? Indeed, how do I signify a new sentence so that the initial word is properly capitalized?
I thought that < ... > caused the text between them to be omitted if the result of the GetLabelledText was empty?
Re: Sentence template
Posted: 04 Oct 2020 10:05
by tatewise
As far as I can tell, the appropriate part of the sentence is not displayed when the labelled text is missing, providing that the {=GetLabelledText(%FACT.NOTE2%,"Label:")} component is the only {variable} component.
The last sentence has two such components, {individual} and {=GetLabelledText(%FACT.NOTE2%,"Previous residence:")} so the rules for < ... > are compromised, and use {individual} to decide whether text should be displayed, so it is always displayed as {individual} always returns a value.
BYW: The code to display His/Her is {individual's} but that won't get automatically capitalised.
The solution is to use the =CombineText( ... ) function that is similar to < ... > but with better rules.
Its parameters are (prefix text, conditional text, suffix text, alternate text) any of which can be blank, but only 'conditional text' governs what text is displayed.
Unfortunately, codes such as {individual's} don't work inside functions, so use the =Sex( ... ) function instead.
To join the =Sex( ... ) function with the text " last ... was " requires the =Text( ... ) function to form the prefix text.
Here is the complete Sentence Template expression for that last sentence:
{=CombineText( Text( Sex( %CUR_PRIN%, " His", " Her", " Their" ) . " last permanent place of residence was " ), GetLabelledText( %FACT.NOTE2%, "Previous residence:" ), , )}
Re: Sentence template
Posted: 04 Oct 2020 13:58
by mezentia
Thanks Mike. Round 1 completed
Now, passenger manifests may be for incoming or outgoing passengers. I want to use the date field on the event to identify either the date of arrival or the date of departure. Clearly, I can create two events, one for arrival and one for departure with the date from the event date applied to the correct direction, but if I use a labelled field to indicate if the event is an arrival or departure, can I create a wholly conditional template that caters for both cases?
Re: Sentence template
Posted: 04 Oct 2020 14:11
by tatewise
Firstly, there already are Arrival and Departure facts in the Extended Set of facts.
See glossary:work_with_fact_sets#custom_facts_from_other_products|> Custom Facts from other Products and although designed for FTM migrants, anyone can use them.
Yes, you could design a wholly conditional Sentence Template using labelled Note fields to replace the {label} code, but such a fact will not be meaningful if exported to any other product.
Re: Sentence template
Posted: 04 Oct 2020 15:14
by mezentia
I had seen the Arrival and Departure facts from the extended set, Mike, but I don't feel that they alone allow me to tell the story behind the event as I would like - although I'm well aware that there are probably several other different ways to use FH to present this information. The main reason for building my own Passenger Manifest template is that it will hopefully allow me to provide a description of an event that contains more than simply a place and a date, i.e. an arrival at a particular place, having departed from a particular location, on what vessel, and any other information of interest that gets recorded on a passenger manifest, such as last and futre permanent residence, details of friends or relatives, reason for travel, etc. As for exporting to other programs, the only one I'm likely to use is a word processor, as anyone I'm likely to share information with will be far more interested in the narrative story than whether or not a fact can be exported.
Re: Sentence template
Posted: 04 Oct 2020 16:47
by tatewise
I'm not sure what point you are making as you can adjust the Sentence Template for any fact to use any features.
So you could make the Departure and Arrival facts produce narratives exctly the same as a Passenger Manifest fact.
The only benefit of a Passenger Manifest fact is that you might be able to include both departure and arrival details in the one narrative, but you were asking about using a labelled field to indicate if the event is an arrival or departure.