Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript to create an array with the repeating phrases in a text

The idea is simple: you put a text in textarea press "send" and return a list of the repeating phrases. By phrases i mean two or more word repeating. My problem is that i have no idea how to detect these (I can whit single words).

$(function() {
    $("#but").click(function() {
        var get = $("#inc").val();
        $("#res").html(get);
        return false;
    });
});

And the HTML:

<form action="" method="POST">
    <textarea name="inc" id="inc" spellcheck="false"></textarea> <br>
    <input type="submit" id="but" value="Send">
</form>

<div id="res"></div>

The problem is of course i dont know even where to start. Any ides?

Example:

Paris s the capital and most populous city of France. Paris and the Paris region account for more than 30% of the gross domestic product of France and have one of the largest city GDPs in the world.

like image 658
faq Avatar asked Nov 12 '22 05:11

faq


1 Answers

Checkout the http://brettterpstra.com/2011/11/02/word-repetition-checking-with-javascript/ This may be really helpful in what you are trying to do.Since the problem is not so very simple. It is better to have a look this blog post along with the solution given. Its actually a word repetition script.

like image 82
Shiv Kumar Ganesh Avatar answered Nov 14 '22 22:11

Shiv Kumar Ganesh