Newbies Limbic_Response Posted March 12, 2018 Newbies Posted March 12, 2018 As part of a much larger text calculation (in the style of a merge letter style solution) , I am trying to create a custom function that will substitute a tag/placeholder such as <<a or an>> with either "a" or "an" in the final calculation, which I think will need to based on a pre-defined list of words that would require one or the other. From a grammar perspective, the use of the articles "a" or "an" is irregular, as it is based on if the subsequent word (most of the time at least) has a vowel sound (e.g., both "university" and "undone" start with the letter "u", but each requires a different article because one has a vowel sound when said aloud and the other doesn't. So, I would expect to have to supply 2 lists of words within the custom function that (which I would update regularly), unless someone happens to know another way to do this. Given a text calculation that might read something like: "The client's reading performance was found to be at <<a or an>> eighth grade level, while his math calculation skills were found to be at <<a or an>> first grade level. " The first placeholder would be "an" and the second would be "a". Thank you.
OlgerDiekstra Posted March 13, 2018 Posted March 13, 2018 I think you are looking at this the wrong way. In your example it makes no sense to substitute only <<a or an>> as they would never change based on the text. The substitution would always be the same. So, for your example to make sense, the words following <<a or an>> (ie, eight and fifth) would also have to be substituted. In which case it makes much more sense to do something like this: "The client's reading performance was found to be at <<subst1>> grade level, while his math calculation skills were found to be at <<subst2>> first grade level. " And substitute <<subst1>> with "an eight" and <<subst2>> with "a fifth". Whilst you are substituting you could check whether the word starts with a vowel or not and include "a " or "an " depending on whatever rule you define.
Newbies Limbic_Response Posted March 13, 2018 Author Newbies Posted March 13, 2018 (edited) OlgerDiekstra, You raise a good point, but this is just one part of a much larger calculation that does already have <<subst1>> and <<subst2>>, which is determined by test scores and different descriptive terms that the end user decides. So the reality is that the same sentence looked something like this originally: <<First Name>> <<Last Name>>'s reading performance was found to be at <<a or an>> <<subst1>>, while <<his or her>> math calculation skills were found to be at <<subst2>>. Since the end user can define what labels are being used for <<subst1>>, <<a or an>> cannot be calculated until the other text calculations have been completed first. Edited March 13, 2018 by Limbic_Response
OlgerDiekstra Posted March 14, 2018 Posted March 14, 2018 You're making it more difficult than it needs to be. When you substitute <<subst1>> or <<subst2>> in your sentence: "<<First Name>> <<Last Name>>'s reading performance was found to be at <<a or an>> <<subst1>>, while <<his or her>> math calculation skills were found to be at <<subst2>> " you can determine <<a or an>> when you substitute. In which case you don't have <<a or an>> in your text, just <<subst1>>. So your user selects "eight" from a dropdown list, and right before you substitute in your CF you determine whether eight requires "a" or "an". The text then becomes: "<<First Name>> <<Last Name>>'s reading performance was found to be at <<subst1>>, while <<his or her>> math calculation skills were found to be at <<subst2>> " Something like: Substitute( $text; "<<subst1>>"; If( left( $term; 1 ) = "e"; "an "; "a " ) & $term )
Featured Comment OlgerDiekstra Posted March 14, 2018 Featured Comment Posted March 14, 2018 You can make the If( left( $term; 1 ) = "e"; "an "; "a " ) into a custom function: function repl_term( _term ) Case( Left( _term; 1 ) = "e"; "an "; Left( _term; 1 ) = "a"; "an "; Left( _term; 1 ) = "i"; "an "; Left( _term; 1 ) = "o"; "an "; Left( _term; 1 ) = "u"; "an "; "a " ) & _term And then do Substitute( $text; "<<subst1>>"; repl_term( $term ) ) 1
Newbies Limbic_Response Posted March 19, 2018 Author Newbies Posted March 19, 2018 Ok, I understand now. Yes, that should work in my solution! Thank you OlgerDiekstra.
Recommended Posts
Posted by OlgerDiekstra,
nice
Recommended by Ocean West
1 reaction
Go to this post
This topic is 2801 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now