making sentances into words...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qwe
    Confirmed User
    • Jul 2003
    • 2109

    #1

    making sentances into words...

    is there a way to let's say load up a .txt file with a bunch of lines of text and extract all the words as a list 1 word per line ? and maybe eliminate any words larger then 2-3 characters?
    Last edited by qwe; 05-03-2009, 08:04 PM.
  • baddog
    So Fucking Banned
    • Apr 2001
    • 107089

    #2
    and maybe eliminate any words larger then 2-3 characters? That is going to make it a pretty short list.

    Comment

    • qwe
      Confirmed User
      • Jul 2003
      • 2109

      #3
      Originally posted by baddog
      and maybe eliminate any words larger then 2-3 characters? That is going to make it a pretty short list.
      not when you load up 1mb .txt file.... any know how can that be done?

      Comment

      • d-null
        . . .
        • Apr 2007
        • 13724

        #4
        this kind of problem is first year computer science stuff, shouldn't be too hard to find a script example out there

        __________________

        Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
        Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
        Check out the #1 WordPress SEO Plugin: CyberSEO Suite

        Comment

        • Iron Fist
          Too lazy to set a custom title
          • Dec 2006
          • 23400

          #5
          Good luck to you
          i like waffles

          Comment

          • baddog
            So Fucking Banned
            • Apr 2001
            • 107089

            #6
            Originally posted by qwe
            not when you load up 1mb .txt file.... any know how can that be done?
            Maybe I am just burned out. Are you saying you want to get 1mb .txt file of words like

            and
            but
            or
            if
            may
            yes
            to
            too
            she
            he


            and randomize them to make sentences?

            Comment

            • qwe
              Confirmed User
              • Jul 2003
              • 2109

              #7
              Originally posted by d-null
              this kind of problem is first year computer science stuff, shouldn't be too hard to find a script example out there
              lol i know, but don't know jack about programming

              Comment

              • qwe
                Confirmed User
                • Jul 2003
                • 2109

                #8
                Originally posted by baddog
                Maybe I am just burned out. Are you saying you want to get 1mb .txt file of words like

                and
                but
                or
                if
                may
                yes
                to
                too
                she
                he


                and randomize them to make sentences?
                no, other way around.... you have a bunch of sentences and you want to make them into 1 word per line

                Comment

                • d-null
                  . . .
                  • Apr 2007
                  • 13724

                  #9
                  Originally posted by qwe
                  no, other way around.... you have a bunch of sentences and you want to make them into 1 word per line
                  so no count necessary, just extract all unique words with 1, 2, or 3 characters and list them in a text file one word per line?

                  __________________

                  Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
                  Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
                  Check out the #1 WordPress SEO Plugin: CyberSEO Suite

                  Comment

                  • qwe
                    Confirmed User
                    • Jul 2003
                    • 2109

                    #10
                    Originally posted by d-null
                    so no count necessary, just extract all unique words with 1, 2, or 3 characters and list them in a text file one word per line?
                    yes but all unique words EXCEPT 1/2/3 characters
                    Last edited by qwe; 05-03-2009, 08:22 PM.

                    Comment

                    • ProG
                      Confirmed User
                      • Apr 2009
                      • 1319

                      #11
                      PHP Code:
                      <?php
                      if ( ( $file = file( "file.txt" ) ) !== false )
                      {
                          foreach( $file as $line )
                          {
                              $words = explode( " ", trim( $line ) );
                              foreach( $words as $word )
                              {
                                  if ( strlen( $word ) > 3 )
                                  {
                                      echo $word . "\n";
                                  }
                              }
                          }
                      }
                      ?>
                      History will be kind to me for I intend to write it.

                      Comment

                      • qwe
                        Confirmed User
                        • Jul 2003
                        • 2109

                        #12
                        Originally posted by ProG
                        PHP Code:
                        <?php
                        if ( ( $file = file( "file.txt" ) ) !== false )
                        {
                            foreach( $file as $line )
                            {
                                $words = explode( " ", trim( $line ) );
                                foreach( $words as $word )
                                {
                                    if ( strlen( $word ) > 3 )
                                    {
                                        echo $word . "\n";
                                    }
                                }
                            }
                        }
                        ?>
                        thanks, is there anyway I can run it in windows ? sorry for stupid questions

                        Comment

                        • ProG
                          Confirmed User
                          • Apr 2009
                          • 1319

                          #13
                          Originally posted by qwe
                          thanks, is there anyway I can run it in windows ? sorry for stupid questions
                          WampServer.com
                          History will be kind to me for I intend to write it.

                          Comment

                          • qwe
                            Confirmed User
                            • Jul 2003
                            • 2109

                            #14
                            Originally posted by ProG
                            WampServer.com
                            sorry, i installed it and what do I do next ? i put that test.php into C:\wamp\www and go to http://localhost/phpmyadmin/test.php and page is blank.... i'm using windows7 64bit maybe thats an issue?

                            Comment

                            • ProG
                              Confirmed User
                              • Apr 2009
                              • 1319

                              #15
                              /www is the root directory which means it would be localhost/test.php
                              History will be kind to me for I intend to write it.

                              Comment

                              Working...