1 2 Previous Next 19 Replies Latest reply on Jan 9, 2012 9:41 AM by braxton

    Detailed acronym of a sentence

    braxton

      Title

      Detailed acronym of a sentence

      Post

      I can make a acronym of a sentence by using a calculation - Acronym (Sentence).  The result yields all capital letters of the first words of the sentence.  Does anyone know how I can get a more detailed acronym that would reflect capital letters, punctuation, and spacing?

      I would love to get the following result from this sentence:  She said, "Go to the store; run there, and please say hello to Anne."

      Desired Result:  S s, "G t t s; r t, a p s h t A."

      Thanks so much for any help.

        • 1. Re: Detailed acronym of a sentence
          philmodjunk

          Acronym (Sentence) would appear to be a custom function. Can you post that function definition here? (look in manage | custom functions.)

          • 2. Re: Detailed acronym of a sentence
            braxton

            Your right Phil.  Thanks.

            Function Name:  Acronym

            Function Parameters:  Text

            Acronym (Text) =
            If (
            WordCount ( text) > 1;
            Upper ( Left ( text; 1)) &
            Acronym ( RightWords ( text; WordCount( text ) - 1));
            Upper ( Left ( text; 1))
            )

            • 3. Re: Detailed acronym of a sentence
              braxton

              Looked up where I found the custom function Acronym and want to give credit to the author Ray Cologon.

              • 4. Re: Detailed acronym of a sentence
                philmodjunk

                You can modify the existing function by removing the Upper function to just get the first character of each word in the original case, but the use of the RightWords function will automatically filter out the punctuation you want.

                //AcronymDetailed ( text ; WordStart ) =
                //
                Let ( [ L = Left ( text ; 1 ) ;
                           Remainder = Right ( Text ; Length ( text ) - 1 )
                        ] ;
                        Case ( IsEmpty ( L ) ; "" ;
                                   Position ( ";,.-?!@$%^&*() " ; L ; 1 ; 1 ) ; Trim ( L & " " & AcronymDetailed ( Remainder  ; True ) ) ;
                                   WordStart and Position ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Upper ( L )  ; 1 ; 1 ) ;  Trim ( L & " " & AcronymDetailed ( Remainder  ; False ) ) ;
                                   AcronymDetailed ( Remainder  ; False )
                        ) // case
                      ) // Let

                • 5. Re: Detailed acronym of a sentence
                  raybaudi

                  If you could live with all capital letters, this is the simplest way:

                  Filter(Proper ( Sentence ) ; Upper ( Sentence ))

                  The result will be:

                  S S, "G T T S; R T, A P S H T A."

                  Otherwise you'll need a complex custom function.

                  • 6. Re: Detailed acronym of a sentence
                    raybaudi

                    @Phil

                    This is the result of your CF: 

                    S s , t t s ; r t , a p s h t A .

                    • 7. Re: Detailed acronym of a sentence
                      philmodjunk

                      Good catch Raybaudi, The quote character needs to be added to the filter expression.

                      //AcronymDetailed ( text ; WordStart ) =
                      //
                      Let ( [ L = Left ( text ; 1 ) ;
                                 Remainder = Right ( Text ; Length ( text ) - 1 )
                              ] ;
                              Case ( IsEmpty ( L ) ; "" ;
                                         Position ( "\";,.-?!@$%^&*() " ; L ; 1 ; 1 ) ; Trim ( L & " " & AcronymDetailed ( Remainder  ; True ) ) ;
                                         WordStart and Position ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Upper ( L )  ; 1 ; 1 ) ;  Trim ( L & " " & AcronymDetailed ( Remainder  ; False ) ) ;
                                         AcronymDetailed ( Remainder  ; False )
                              ) // case
                            ) // Let

                      That will produce:

                      S s , " G t t s ; r t , a p s h t A . "

                      Instead of

                      S s, "G t t s; r t, a p s h t A."

                      So we are very close, but have some extra spaces being returned between letters and punctuation. I don't have time to fix that right now, but you or others are welcome to contribute. Otherwise, I'll check back in on Monday.

                      • 8. Re: Detailed acronym of a sentence
                        braxton

                        Thanks so much for your help Phil and Ray!

                        I wrote Ray Cologon, PhD. about this function, and he so generously replied with his Mnemonic Generator.  He gave me permission to post the code here.


                             //  SYNTAX:     Mnemonic ( phrase )
                            //   ORIGIN:      http://www.nightwingenterprises.com
                           //    NOTES:       Builds an mnemonic string from the initial letters of words in the supplied phrase
                          //     VERSION:    1.0v2
                         //      © 2007 Ray Cologon, NightWing Enterprises, Melbourne, Australia

                        Let([
                        w1 = LeftWords(phrase; 1);
                        w2 = MiddleWords(phrase; 2; 1);
                        p1 = Position(phrase; w1; 1; 1);
                        p2 = Position(phrase; w2; 1; 1);
                        n1 = p1 + Length(w1)];
                        Case(
                        WordCount(phrase) > 1;
                        Left(phrase; p1 - 1) & Left(w1; 1) & Middle(phrase; n1; p2 - n1) &
                        Mnemonic(Right(phrase; Length(phrase) - p2 + 1));
                        Left(w1; 1) & Right(phrase; Length(phrase) - Length(w1))
                        )
                        )

                         

                        • 9. Re: Detailed acronym of a sentence
                          Sorbsbuster

                          And for those of us of the Pedant Religion, it is a relief to see it as a 'Mnemonic' and not an 'Acronym'.

                          • 10. Re: Detailed acronym of a sentence
                            braxton
                            I think I found a bug in the Mnemonic Generator.
                             
                            This bug occurs between adjacent words where the 2nd word is composed of any group of adjacent letters found in the 1st word.  This bug also occurs in the same manner with numbers.  Also, it doesn't matter where the adjacent words are in a group of words.
                             
                            For example:
                             
                            Error:  I had a lot of fun today.  ("a" is composed of the letter "a" in had.)
                             
                            Error:  orange or apple  ("or" is composed of the "or" in orange)
                            Ok:     apple or orange  (The "or" in orange is part of the word orange and not by itself.
                             
                            Error:    1234 23   ("23" is composed of the adjacent numbers "23" in 1234)
                            Ok:       23 1234   (Just like the orange example that is ok.)
                            Ok:       1234 235  (The "5" breaks the "23" pattern in 1234.)
                             
                            Error:   Dogs do help.     -   (Do)gs (do) help.
                            Ok:      Dogs doing help
                            • 11. Re: Detailed acronym of a sentence
                              raybaudi

                              Try this one:

                              // MnemonicNew ( text )

                              Let([
                              adj = Substitute ( text ; " " ; ¶ ) ;
                              value = GetValue ( adj ; 1 ) ;
                              discard = Right ( LeftWords ( value ; 1 ) ; Length ( LeftWords ( value ; 1 ) ) - 1 ) ;
                              result = Substitute ( value ; discard ; "" )
                              ];
                              Case(
                              ValueCount ( adj ) > 1 ; result & " " & MnemonicNew ( Middle ( adj ; Length ( value ) + 2 ; Length ( adj ) ) ) ;
                              result
                              )
                              )

                              • 12. Re: Detailed acronym of a sentence
                                braxton

                                When I try and store this I can a pop-up saying the function Code cannot be found.  Is this because I am still using FM 9 Pro?

                                Thanks.

                                • 13. Re: Detailed acronym of a sentence
                                  raybaudi

                                  Yes, and there was also an error.

                                  BTW: try the new one I posted.

                                  • 14. Re: Detailed acronym of a sentence
                                    raybaudi

                                    There was another error.

                                    This is the new one to try:

                                    // MnemonicNew ( text ) v 1.00

                                    Let([
                                    adj = Substitute ( text ; " " ; ¶ ) ; // transforms the text into a list of values
                                    value = GetValue ( adj ; 1 ) ; // takes the first value
                                    word = LeftWords ( value ; 1 ) ; // takes ONLY the word of the first value
                                    character = Left ( word ; 1 ) ; // takes the first alphanumeric character of the word of the first value
                                    result = Substitute ( value ; word ; character ) ; // replaces the first word with its first alphanumeric character, preserving punctuation
                                    next = RightValues ( adj ; ValueCount ( adj ) - 1 ) // next text to evaluate
                                    ];
                                    Case(
                                    ValueCount ( adj ) > 1 ; result & " " & MnemonicNew ( next ) ; // recursion for each value
                                    result
                                    )
                                    )

                                    1 2 Previous Next