4 Replies Latest reply on May 21, 2015 2:41 PM by markomodsching

    split a text and store a word statistic in a relationship table

    markomodsching

      Title

      split a text and store a word statistic in a relationship table

      Post

      Hi,

      I'm new to filemaker and searching for a solution. I like to store a keyword statistic of a web-page and compare it to another one. The single words should be analzed according to their occurences and stored in a separate table called analyzed_words. From my point-of-view I need the following steps:

      1. load the content of a web-page via url given in a text-field

      2. cleanup the html content to get the pure text

      3. split the text into the single words

      4. count equal words and store the result in the analyzed_words related table

      I managed to do steps 1-2. I'm now searching for a way to split the text into the words and store them in the related table. I think I need to trigger a skript via button-click and do the action there?

      Maybe somebody has an aproach for me. Or is this kind of task not possible with filemaker?

      Thanks in advance,

      Marko

        • 1. Re: split a text and store a word statistic in a relationship table
          philmodjunk

          1. See the Insert From URL script step

          2. You'll need to do a lot of text parsing. There are many text functions available in FileMaker and if you have advanced there are additional custom functions available. (There are web sites that share FileMaker custom functions that you can google.) You can give the substitute function a list of words for which it substitutes an empty string to filter out text, such as HTML tags from the downloaded mass of text.

          3. See the leftwords, middlewords and rightwords functions.

          4. You'll probably need to parse your filtered text into a table with one record per word and then sort them (To group same words together) in order to get statistics on each word. A looping script comes to mind as a way to extract the words one at a time from the text field storing test with the HTML tags removed (or you can just skip over them in this looping script.)

          The main thing that you will need is probably a pause after the Insert From URL possibly with a loop that checks to see if the field getting the data from this step is empty or not. Don't see a need for a button click to do the text analyzing as a separate step though that may be the simpler option.

          • 2. Re: split a text and store a word statistic in a relationship table
            markomodsching

            Hi PhilModJunk,

             

            thanks for your reply. I managed to execute steps 1-3. Can you give me a hint on how to do step 4? How can I store each word in an own record from a script? Do you have a link to a tutorial or an example on how to do it?

            Thanks again,

            Marko

            • 3. Re: split a text and store a word statistic in a relationship table
              philmodjunk

              The following script assumes that you have the following table and relationships:

              WebPage----<WordStats
              WebPage::__pkPageID = WordStats::_fkPageID

              This script would be run from a layout based on WebPage after the text from the web page has been inserted and the HTML Tags removed. (Or you could add code after set variable [$Word... that skips the next five steps if $Word is an HTML tag.

              Set Variable [$PageID ; WebPage::__pkWebPageID ]
              Loop
                 Set Variable [$K ; value: $K + 1 ]
                 Exit Loop If [ $K > WordCount ( WebPage::PageTextField ) ]
                 Set Variable [$Word ; value: MiddleWords ( WebPage::TextField ; $K ; 1 ) ]
                 Go to Layout ["WordStats" (WordStats) ]
                 New Record/Request
                 Set Field [WordStats::_fkPageID ; $PageID ]
                 Set Field [ WordStats::Word ; $Word ]
                 Go To Layout [original layout]
              End Loop

              For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

              • 4. Re: split a text and store a word statistic in a relationship table
                markomodsching

                awesome! It really worked! Thank you so much!