6 Replies Latest reply on Nov 9, 2012 12:34 PM by shamat

    calculation for displaying multiple db entries in a line

    shamat

      Title

      calculation for displaying multiple db entries in a line

      Post

           Hi guys,

           I'm pretty new to filemaker 12. I'mbuilding a database of literary texts. So far, it looks like this:

            

           id_text            text_label          part                   line_num               word_num        word                        type

           00001               Hamlet                3_1                    1                                1                             To                              PREP

           00001               Hamlet                3_1                    1                                2                             be,                            VERB

           00001               Hamlet                3_1                    1                                3                             or                               CONJ

           00001               Hamlet                3_1                    1                                4                             not                            NEG

           00001               Hamlet                3_1                    1                                5                             to                               PREP

           00001               Hamlet                3_1                    1                                6                             be:                            VERB

           00001               Hamlet                3_1                    1                                7                             that                           DEM

           00001               Hamlet                3_1                    1                                8                             is                                VERB

           00001               Hamlet                3_1                    1                                9                             the                            ART

           00001               Hamlet                3_1                    1                                10                          question.                NOUN

           00001               Hamlet                3_1                    2                                1                             Whether                 ADV

           00001               Hamlet                3_1                    2                                2                             'tis                             VERB

           00001               Hamlet                3_1                    2                                3                             nobler                      ADJ

           00001               Hamlet                3_1                    2                                4                             in                               PREP

           00001               Hamlet                3_1                    2                                5                             the                            ART

           00001               Hamlet                3_1                    2                                6                             mind                         NOUN

           00001               Hamlet                3_1                    2                                7                             to                               PREP

           00001               Hamlet                3_1                    2                                8                             suffer                       VERB

            

           As you see, the data are structured and encoded as to make possible basic literary analysis (for instance I would like to get the total number of verbs, nouns, the average lenght of a sentence, etc.). I’m trying to make a calculation field that displays in a printer-firendly version, i.e.:

            To be, or not to be: that is the question.

           Whether 'tis nobler in the mind to suffer

           Any suggestion?

        • 1. Re: calculation for displaying multiple db entries in a line
          philmodjunk

               If you establish a relationship to this table that links only to this id_text value, then this calculation, defined from the other table, would serve:

               Substitute ( List ( LiteraryTextTable::Word ) ; ¶ ; " " )

          • 2. Re: calculation for displaying multiple db entries in a line
            shamat

                 Thank you so much for your suggestion PhilModJunk! I'm getting closer to the output I want, but the problem is that the calculation should to take in to account the line division. In other words, the substitution should not to apply to the entry for the word "Whether", which starts line 2. Maybe I shall loop and use some conditinal function, but I just can't figure the proper syntax. Thanks again for your time and your help!

            • 3. Re: calculation for displaying multiple db entries in a line
              philmodjunk

                   The substitution can be made more sophisticated:

                   Substitute ( List ( LiteraryTextTable::Word ) ; [¶ ; " "] ; ["." ;".¶" ] ; ["!" ; "!¶" ]  )

                   I am assuming that each new sentence must start a new line. You can add as many brackets as you need for each punctuation mark that serves to end a sentence, I've just use . ! as examples to show how it is done.

              • 4. Re: calculation for displaying multiple db entries in a line
                shamat

                     Thanks PhilModJunk. The trick works well with the example above, but unfortunately in poetry not always a dot ends a line. Consider for instance this other passage from Hamlet:

                     Good now, sit down, and tell me, he that knows,
                     Why this same strict and most observant watch
                     So nightly toils the subject of the land,

                     If we take the comma as "new line character" to properly end line 1,  the result would be

                     Good now,
                     sit down,
                     and tell me,
                     he that knows,
                     Why this same strict and most observant watchSo nightly toils the subject of the land,

                     So I think the calculation should somehow consider the actual content of the line_num column, and check if it is different from the value considered. Any help is very appreciated.

                • 5. Re: calculation for displaying multiple db entries in a line
                  philmodjunk

                       And how could that work? If you were going to write down instructions to someone on how to take that list of vertical words--for someone who can't read English, how would you tell them where to put the line breaks?

                       I think you will need to add some data to the above table to indicate the location of your line breaks. This might be an additional field or it might be an added record with some sort of special character in place of the word.

                       Here's how it might work if you added a number field named "Break" where you entered the number 1 in each record where it is the last word on the line:

                       Define a calculation field cWord as:

                       Word & If ( Break ; "§" )

                       Then the substitute expression becomes:

                       Substitute ( List ( LiteraryTextTable::cWord ) ; [¶ ; " "] ; ["§" ;¶ ]  )

                       Note: the bracketed parameters must be used in the left to right order shown.

                  • 6. Re: calculation for displaying multiple db entries in a line
                    shamat

                         Great! That works smoothly. Thank you so much  PhilModJunk! Now I'm going to build a script that locates the line breaks for me.