Page 1 of 1

Narrative reports

Posted: 25 Nov 2016 08:03
by dewilkinson
I see in Narrative circa. dates can be replaced with (approx.), but is it possible to replace it with "about" which reads much better? Also, is it possible to have dates with nd, st, rd after the day. In my books I like to use these formats but it gets a bit tedious. I have searched the help and this Forum but it doesn't seem possible at present.

Re: Narrative reports

Posted: 25 Nov 2016 12:09
by tatewise
The short answer is, you are correct, it is not possible at present in FH to easily adapt the {date} Formats.

The long answer is:-
Check the Tools > Fact Types > Edit > <<Insert Code > How to Use Advanced Features where it describes How to Use a Specific Date Format and the link to Date Formats.
The big snag is in the second paragraph where it explains that prefixes such as in and on are only provided by the default unqualified {date} code, and believe me, it is much harder to automatically add those prefixes yourself than it suggests.
What are the alternatives?
You could post-edit the Book Narrative Reports in a PDF editor or word-processor, but that can be expensive, tedious, or result in disrupted document layouts.
Another idea is to design a Plugin that reformats each Date into some labelled Note text as desired.
A Plugin has more programmable capabilities to conditionally add embellishments such as: in, on, about, st, nd, rd, th, etc.
Then that labelled Note text is incorporated into the Narrative Sentence using the how_to:narrative_report_fact_sentence_templates#custom_fact_fields|> Custom Fact Fields technique with a label such as Date: and an Expression such as {=GetLabelledText(%FACT.NOTE2%,"Date: ")} in place of every {date} code.
It could equally use a Source Note field just same but less obtrusively.

P.S. I have a prototype Plugin for the above task if you are interested.

Re: Narrative reports

Posted: 26 Nov 2016 07:30
by dewilkinson
Mike,

Thank you I am making the changes in my word processor. I think I was mis-led by the help, see attached screen which has 'th' on the date.

I will think about this one before embarking on the labelled Note route which doesn't seem very elegant. Thank you for the offer to try the pilot plug-in but I won't take that up at present.
Untitled.jpg
Untitled.jpg (208.29 KiB) Viewed 10891 times

Re: Narrative reports

Posted: 26 Nov 2016 11:00
by tatewise
That mistake in the Help has existed for many years (it exists in FH V5.0).
Would you mind reporting it to Calico Pie please?

I've had a rethink about the Plugin approach and realised there is a much more elegant solution for formatting Dates.
I thought about using the rarely used Source Note field instead of the Fact Note field, but I have moved on......
Instead of using a Date: labelled Note: the Plugin can customise the Sentence for each Fact that needs it.
Then the user does not need to change any of the Fact Type default Sentence Templates as it is all automatic.
Give me a while to sort out the details then you could try it in a Copy of your Project, but the Plugin will have an option to Remove its changes at any time in the future, in addition to the Edit > Undo Plugin Updates command.

Re: Narrative reports

Posted: 26 Nov 2016 12:06
by dewilkinson
Mike,

Thank you, look forward to your PlugIn.

In the meantime I have created the following which works, but would be needed to pasted into every Fact sentence. Is there a way of saving such it can be referenced by say {date_expanded} as one would normally create a function when programming?

{%FACT.DATE:DAY%}{=TEXTIF( ISTRUE(%FACT.DATE:DAY%=1) OR (%FACT.DATE:DAY%=21) OR (%FACT.DATE:DAY%=31),"st",TEXTIF( ISTRUE(%FACT.DATE:DAY%=2) OR (%FACT.DATE:DAY%=22),"nd",TEXTIF( ISTRUE(%FACT.DATE:DAY%=3) OR (%FACT.DATE:DAY%=23),"rd", "th")))} {%FACT.DATE:MONTH_NAME%} {%FACT.DATE:YEAR%}

which gives for example 22nd December 2016

Re: Narrative reports

Posted: 26 Nov 2016 12:10
by dewilkinson
Mike,

Before I report this to Calico Pie what is the recommend way of doing so?

David

Re: Narrative reports

Posted: 26 Nov 2016 12:27
by tatewise
Currently there is no way of creating custom functions, but it is on Wish List as Ref 498 User Defined Macros (or Custom Functions) that you can Vote for.

Unfortunately, I think your expression has several deficiencies, and believe me I have tried similar techniques.
It may well work for simple single Dates but not for Range Dates or Period Dates.
Also don't overlook Quarter Dates and Date Phrases.
I think it adds superfluous space characters when there is no Day or no Month or no Date at all.
It does not add a prefix of ' in ' or ' on ' or nothing as appropriate.

To report to Calico Pie see how_to:about#problem_reporting|> About Family Historian > Problem Reporting.

Re: Narrative reports

Posted: 26 Nov 2016 13:13
by dewilkinson
Mike,

I wasn't suggesting this was the answer, just exploring if it could be done. If I was writing a function for wider use I would wrap it with tests for a full date etc and add in or on.

As it is not possible at present to save user defined functions it is a bit to long winded to include in each Sentence template.

Re: Narrative reports

Posted: 26 Nov 2016 14:13
by tatewise
If I remember correctly, the Expression to cope with all possibilities became so large that it exceeded the program limits.

See related Wish List Ref 546 Enhanced use of Narrative Template Codes.

The current workaround for replicating complex Expressions is to directly edit the underlying script files within C:\ProgramData\Calico Pie\Family Historian\ using a plain text editor such as Notepad. For Fact Sets those are the .fhf files are in the C:\ProgramData\Calico Pie\Family Historian\Fact Types\Standard/Custom/ folders.

Re: Narrative reports

Posted: 26 Nov 2016 15:47
by dewilkinson
Sorry but I can't resist an academic challenge so I have topped and tailed this so dates appear as they should, quarter dates, before, after etc. Between dates etc won't have th, nd though, that is where being able to call user defined functions would really work.

I shall put this on the back burner now and wait until we get the ability to get user defined functions as it far to unwieldy to use.

For your info this is what I have produced now

{=TEXTIF(ISTRUE(%FACT.DATE:DAY% >0),COMBINETEXT(%FACT.DATE:DAY%,TEXTIF( ISTRUE(%FACT.DATE:DAY%=1) OR (%FACT.DATE:DAY%=21) OR (%FACT.DATE:DAY%=31),"st",TEXTIF( ISTRUE(%FACT.DATE:DAY%=2) OR (%FACT.DATE:DAY%=22),"nd",TEXTIF( ISTRUE(%FACT.DATE:DAY%=3) OR (%FACT.DATE:DAY%=23),"rd", "th"))), COMBINETEXT(COMBINETEXT( " ", %FACT.DATE:MONTH_NAME%),COMBINETEXT(" ",%FACT.DATE:YEAR%))) ,%FACT.DATE%)} {=TEXTIF(ISTRUE(%FACT.DATE:XDATETYPE%="After" or %FACT.DATE:XDATETYPE%="Before" or %FACT.DATE:XDATETYPE%="Between" or %FACT.DATE:XDATETYPE%="Date" or%FACT.DATE:XDATETYPE%="To" or%FACT.DATE:XDATETYPE%="From" OR %FACT.DATE:XDATETYPE%="From/To"),"", %FACT.DATE:XDATETYPE%)}

Re: Narrative reports

Posted: 26 Nov 2016 16:30
by tatewise
My feedback on that expression is that:
1) It does not add the prefix 'in' or 'on' or nothing as appropriate.
2) It does not cope with Approx, Calculated, or Estimated simple dates.
3) It is not clear what the XDATETYPE section achieves.
4) As you say, it does convert Range and Period days into cardinal form.

Re: Narrative reports

Posted: 27 Nov 2016 12:49
by tatewise
Try attached Format Dates in Sentences Plugin Version 0.1 Date 27 Nov 2016.
I advise you initially run it it on a Copy of your Project or make sure you have good backups.

It creates (or removes) local Fact Sentence Templates where the Fact Date needs a different format to the default {date} code format, such as ordinal (st,nd,rd,,th) suffix on days, Approx/circa replaced by about, and Q1/2/3/4 replaced by 1st/2nd/3rd/4th quarter of (others are feasible).

It produces a Result Set of all the changes each time it is run, and they can be reversed by using Edit > Undo Plugin Updates before closing FH.

It should cope with any changes to the Fact Date or to the default Fact Types Sentence Templates and cope with custom local Fact Sentence Templates. Just run the Plugin again using the Create Sentence option after any changes.

If you investigate, you will see it uses the {=ForceText(...)} code so that it can identify where a formatted Date has been applied and later needs adjusting or removing.

[EDIT: Attachment deleted.]

Re: Narrative reports

Posted: 27 Nov 2016 15:32
by dewilkinson
Mike,

Thank you but I am afraid it had an error, see image.
Untitled.jpg
Untitled.jpg (216.98 KiB) Viewed 10740 times
I also download your Quick Child Lookup which is excellent. It in fact plugs a gap (excuse the pun) having moved from TMG where child birth details were visible in the equivalent of the Focus Window in FH.

Re: Narrative reports

Posted: 27 Nov 2016 16:37
by tatewise
My analysis of what the Plugin is doing there, suggests that you have a custom Fact for which there is no Tools > Fact Types definition. I suspect the most probable cause is the FTM Extended Set of imported Facts provided automatically by FH but is Hidden by default. That is such a common likelihood that I have made an exception for that Extended Set in the Plugin, but it might be better if you enabled all its definitions. In the Fact Types dialogue, in the Fact Set: filter select Extended Set and follow the popup instructions. Please try running the Plugin both before and after making that change to check it supports both modes.

Try attached prototype Format Dates in Sentences Plugin Version 0.2 Date 27 Nov 2016.
[ EDIT Attachment deleted as superseded later. ]

Re: Narrative reports

Posted: 27 Nov 2016 18:03
by dewilkinson
Mike,

Worked like a dream. I restored a back up and ran it with no errors and the results look perfect. I then restored the back up again and opened Fact Types, selected Extended, filter = "None" only one appeared Military Service. No pop up though, so I revealed hidden and made them all visible. Created a couple on entries on these hidden facts and ran the plugin again, no problems and results looked perfect.

I am happy to run it again under any other conditions you would like me to try.

Re: Narrative reports

Posted: 27 Nov 2016 18:43
by tatewise
Just to clarify, in Fact Set: drop-list top left select Extended Set (not Filter: on right).

To test features you should be able to use Remove the sentences and Create the sentences at any time with predictable results. Remove... should get back to the default FH status with no custom formatted Dates. Whereas Create... should add all the formatted Dates.

Try normal editing operations such as adding Facts with Dates, or deleting Dates from Facts, or changing the Dates in existing Facts. This should include changes that need formatting to be added, and where formatting needs to be removed. i.e. change 1900 to 23 Mar 1900 and the reverse.

Try changing default Sentence Templates in Tools > Fact Types for both primary Fact and Witness Roles. See how_to:narrative_report_fact_sentence_templates|> Narrative Report Fact Sentence Templates under Default Fact Definitions.

Add or remove or change local custom Sentence Templates for specific Facts by editing Sentence box at bottom of Facts tab. See how_to:narrative_report_fact_sentence_templates|> Narrative Report Fact Sentence Templates under Specific Fact Sentences. It is this feature that the Plugin finds trickiest, and I may not have considered all the possibilities.
The Plugin is using this feature to customise Sentences that need formatted Dates, so where necessary you will see the Sentence box background is white instead of beige.
So if it is already white and uses the Plugin {=ForceText("...")} function, and needs local customisation, then delete it all to return to default (beige) Template, and start customising from there.
If it had previously been customised, then it will use {=ForceText("...")} {date:YEAR} and can be further customised without reverting to default Template.
Explanation:
Plugin uses {=ForceText("...")} with year digits where formatted Dates are added to default Templates.
It uses {=ForceText("...")} {date:YEAR} where formatted dates are added to specific custom Templates.

After any changes, use the Plugin Create the sentences option, and it should update just the affected Fact Sentences and list them in the Result Set.

I'm thinking of adding a menu of options to Plugin to let users choose their desired formatting:
i.e.
Day ordinal suffixes (st,nd,rd,th).
Quarter Date in the ... quarter of.
Approx/circa qualifier to about.
But what about Calculated and Estimated qualifiers?
Any other ideas?

Re: Narrative reports

Posted: 27 Nov 2016 19:24
by dewilkinson
Mike,

I have been having a play doing quite a bit of editing and creating facts and all seems to be well . I will have a go at the things you suggest but I won't have much time over the next few days as I have three long days in court (I am a magistrate) Mon-Wed.

The narrative reports are very much improved and I attach an example. This does not now require much tedious editing before inserting into our book, just making it flow and adding images of census documents etc. This exercise has been very worthwhile already. When you add a fact you of course have to rerun the plugin but it runs very quickly, only taking a few seconds to complete.
Untitled.jpg
Untitled.jpg (209.16 KiB) Viewed 10703 times
Regarding options:-

Day ordinal suffixes (st,nd,rd,th). - these are just what I wanted, other languages will of course need something different

Quarter Date in the ... quarter of. - you can see in the attachment how that looks, just right for me, not sure I'd want fourth quarter but it could be an option. Having a quarter date is great, this wasn't in TMG.

Approx/circa qualifier to about. - about or around - I think I prefer about

But what about Calculated and Estimated qualifiers? - (a calculated date) (an estimated date) - to say something like "His date of birth was estimated as ..." would require a different sentence template. I think "x was born on 4th November 1901 (a calculated date) at ..." is fine. I am sure though there could be many opinions on this.

Between - my entries come out perfect e.g. .. between 19th September 1935 and 31st July 1940 at ...

Re: Narrative reports

Posted: 27 Nov 2016 20:31
by dewilkinson
Mike,

If you do release this, a couple of things I think need to made very clear to users.

If you amend a Fact Sentence Template, the changes won't appear in all instances of the Fact until the Plugin is run again as the instant update is lost.

If you customise a Sentence in the Facts window, when you next run the plugin, which you would have to do to get new Facts Sentences appearing correctly, you lose that individual sentence customisation. Although being very new to FH customising sentences like that is not something I would recommend, I would use the note field and choose the words so the sentence reads OK. If users have customised sentences that way, they must never use the plugin.

I am just wondering if a remove the ForceText insertion option should be available?

Re: Narrative reports

Posted: 27 Nov 2016 21:46
by tatewise
I did try and explain some of the techniques needed to incorporate changes, and these would accompany a published version of the Plugin.

Any Sentence that has been synthesised by the Plugin (and thus has a white background) forfeits its instant update, not only for changed default Templates, but also changed Fact Dates. Yes, the Plugin must be run with Create the sentences to incorporate such changes.

There is a remove ForceText() option; it is the Remove the sentences button.
That reverts everything back to the original status, but retains any pre-existing custom Sentences.
The drawback is that it modifies the Updated timestamp on every affected record.

It would be possible to constrain that removal affect to just one selected Individual record.
Then the customisation can be applied, and the Plugin run again to synthesise new Sentences.
That will only affect the Updated timestamp of that one record, which will change anyway due to the new specific custom Sentence being added. I will add that as new option.

That would be better than the manual method to avoid the problem, which (as I tried to explain) is to first delete the Sentence synthesised by the Plugin so it reverts to the default Template. Then customise the Sentence as desired using {date} as normal. Finally run the Plugin. This time it uses {=ForceText("...")} {date:YEAR} which uniquely prevents it being upset by future runs of the Plugin.

BTW: See how_to:narrative_report_fact_sentence_templates|> Narrative Report Fact Sentence Templates for a neat way to use the Note field for Custom Fact Fields employing default Templates.

One set of Dates the Plugin cannot tackle are the Citation Entry Dates, but we just have to accept that.

Re: Narrative reports

Posted: 28 Nov 2016 08:02
by dewilkinson
Mike,

Apologies, I knew the remove option was there, just hadn't run it. I ran it just now and it reset all Sentences except one which is illustrated. I reran it but it still didn't reset it. The attached image shows the record. Interestingly the Miscellaneous Facts either side of it didn't get changed but did not appear in records window, only the illustrated one did.
Untitled.jpg
Untitled.jpg (190.81 KiB) Viewed 10646 times
I was just thinking there should be quite a health warning with this Plugin if people have customised Sentences in the Facts window.

Re: Narrative reports

Posted: 29 Nov 2016 12:44
by tatewise
Try attached prototype Format Dates in Sentences Plugin Version 0.4 Date 29 Nov 2016.

It fixes that minor bug with about due to a rogue space character.
I suspect the Miscellaneous facts either side use Calculated or Estimated instead of Approx.

It fixes a minor problem with Date Phrases, and with Fact Type definitions that are Hidden.

If a Sentence is customised, or a Fact Type default Template is changed, the Plugin cannot tell which, so it now prompts the user for advice.
If the former, then synthetic Sentence is adjusted for that one specific Fact.
If the latter, then all similar synthetic Sentences are adjusted to match the default Template.
That should avoid the need for a health warning, unless you can prove me wrong!
It also avoids the need for an option to Reset the Sentences for one Individual which was starting to get tricky anyway.

Re: Narrative reports

Posted: 29 Nov 2016 19:47
by dewilkinson
Mike,

Thank you for your good work, this seems very good now. I have tried Approx, Estimated, Calculated dates and they all seem to be fine with Updating and Removal. My previous error seems to be resolved. Period dates seem unchanged and I haven't used Date Phrases as this wasn't something in TMG. I might have a go with them later to explore.

I also customised a couple of Fact Sentences in the Fact Sentence Window and those customisations seem to be preserved in both Update and Removal. As you say no longer needing a health warning.

As far I am concerned this plug-in does a very good job now adding and removing ordinals to the vast majority of fact types. The remaining few present little overhead when editing narrative reports. As I continue to explore FH I will let you know of any other glitches.

Re: Narrative reports

Posted: 29 Nov 2016 21:35
by tatewise
That sounds good David.

Another thing to try is Tools > Fact Types > Edit > Template and the Roles > Edit > Template.
See how_to:narrative_report_fact_sentence_templates|> Narrative Report Fact Sentence Templates for advice.

Remember, you should only ever need to use Update the Sentences so that only a few record Updated timestamps will change.