PHP Classes

Get all words in sentence: Some class to get all of words in sentence

Recommend this page to a friend!
  All requests RSS feed  >  Get all words in sentence  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

Get all words in sentence

A request is featured when there is no good recommended package on the site when it is posted. Edit

Picture of Mehran Ko by Mehran Ko - 7 years ago (2016-04-15)

Some class to get all of words in sentence

This request is clear and relevant.
This request is not clear or is not relevant.

+1

I want to get all of words from this sentence.

After having owned the BMW X3, the MDX is a pleasure to drive. Reliability is great for 25,000 miles. Only things wrong are Bluetooth; rings and cannot hear whose on the other end and many viable addresses do not show up on Navigation system. Dealer service excellent. A few miss-steps in design; no lights for A/C controls at night; rear view pic doesn't come on in reverse for 10 seconds, some wind noise, transmission can be rough and erratic. No ipod plug which I didn't realize until after I purchased. Front end design could be improved, very masculine. Sounds like a lot but I do really like this car. Also test drove BMW X5 and Lexus 400.

Is there any library or prepared class to get all of words from this sentence cleanly? I know some functions exist like preg_match.

EX: look at this sentence"now in 2016. i am mikel and i from USA" when i get words i should get ("now","in","2016","i","am","mikel","and","from","USA");

like this example

  • 4 Clarification requests
  • 6. Picture of Mohammad Keramatifar by Mohammad Keramatifar - 7 years ago (2016-05-18) Reply

    did you get the answer?

    • 5. Picture of Anthony Amolochitis by Anthony Amolochitis - 7 years ago (2016-04-16) Reply

      Have you thought about using explode? What are you trying to do with the words. Is it the ordering? I do something with a class that I wrote for personal use that reads words in and looks for variables in it and does replacements. Let us know what you are trying to do to clarify. Otherwise just use explode to bust the words apart by a space.

      • 4. Picture of Anthony Amolochitis by Anthony Amolochitis - 7 years ago (2016-04-16) Reply

        Have you thought about using explode? What are you trying to do with the words. Is it the ordering? I do something with a class that I wrote for personal use that reads words in and looks for variables in it and does replacements. Let us know what you are trying to do to clarify. Otherwise just use explode to bust the words apart by a space.

        • 1. Picture of Manuel Lemos by Manuel Lemos - 7 years ago (2016-04-15) Reply

          Yes, but what does this have to do with XML parser you used as keywords for this request?

          • 2. Picture of Mehran Ko by Mehran Ko - 7 years ago (2016-04-15) in reply to comment 1 by Manuel Lemos Comment

            i solved my problem with below code: preg_match_all('/\w+/', $str, $matches); // match words $matchesUnique = array_unique($matches[0]); // get new array w/o duplicates print_r($matchesUnique); echo "<br>";

            so i needed function to find words and put them in array then delete stopwords from this array,

          • 3. Picture of Manuel Lemos by Manuel Lemos - 7 years ago (2016-04-16) in reply to comment 2 by Mehran Ko Comment

            I did not find a class that does exactly that but I found classes that do more complicated things, like keeping words that are more frequent.

            Maybe somebody can come up with a class that does more like what you need.

        Ask clarification

        3 Recommendations

        PHP String Foreach: Process strings as arrays of characters

        This recommendation solves the problem.
        This recommendation does not solve the problem.

        0

        Picture of zinsou A.A.E.Moïse by zinsou A.A.E.Moïse package author package author Reputation 5840 - 6 years ago (2017-06-15) Comment

        try this


        PHP Get All Words: Extract all words from string excluding stop words

        This recommendation solves the problem.
        This recommendation does not solve the problem.

        +1

        Picture of Lionel F. Lebeau by Lionel F. Lebeau package author package author Reputation 140 - 7 years ago (2016-04-16) Comment

        You can use this class to get an array of words. This array can be filtered with an optional stopwords array; The result array can be a lower one or contain the original case.

        I used your examples to create the rules. So, you'll get A/C and 25,000, not A, C, 25, 000 in the resulting array.


        wText: Detect and filter spam in text

        This recommendation solves the problem.
        This recommendation does not solve the problem.

        +1

        Picture of Till Wehowski by Till Wehowski package author package author Reputation 110 - 7 years ago (2016-04-16) Comment

        You can use this class to remove stopwords from a text. It does a bit more, maybe you have to do little modifications. The cleaned text you can find in $this->buf['clean'] / $this->buf['clean_spammy']

        • 3 Comments
        • 1. Picture of Mehran Ko by Mehran Ko - 7 years ago (2016-04-16) Reply

          thanks,, downloaded,its good one ,,,

        • 2. Picture of Till Wehowski by Till Wehowski package author package author - 7 years ago (2016-04-16) in reply to comment 1 by Mehran Ko Reply

          Another class I like to mention here is the Automatic Keyword Generator. In combination with my class above http://www.phpclasses.org/package/8349-PHP-Detect-and-filter-spam-in-text.html I built the "Tagesthema" (German for "Topics of the Day") functionalitiy of the Webfan.de News Meta serach Engine (www.webfan.de/Web_News.html). But I have to update this one day as the construction does not care about performance and memory usage! So if you have a VERY large amount of text, it would be better maybe to split the textes and stop-/spamwords/other detectors into parts and iterate over it and cache results, depending on hardware and text quantity.

          Unfortunatly phpclasses.org does not allow to recommend more than one package (@Manuel?!) The Link to "Automatic Keyord Genrator" is http://www.phpclasses.org/package/3245-PHP-Automatically-suggest-keywords-from-content-text.html

        • 3. Picture of Mehran Ko by Mehran Ko - 7 years ago (2016-04-17) in reply to comment 2 by Till Wehowski Reply

          yes i have about 40 megabyte text file,,

          thanks in advance


        Recommend package
        : 
        :