DEV Community

ivkeMilioner
ivkeMilioner

Posted on • Edited on

How to count phrases in text with JS?

I am beginner and I cannot find any source to see how to JavaScript count phrases in text. I know how to count charters, words and sentence.

Top comments (4)

Collapse
 
savagepixie profile image
SavagePixie

I'm not sure you can without complex algorithms, as there's really no punctuation to mark them. Why do you need to count phrases?

Collapse
 
ivkemilioner profile image
ivkeMilioner

Just want to add something to my project.

Collapse
 
savagepixie profile image
SavagePixie

Let me make sure I understand what you mean by phrase. Are you trying to achieve something like this:

The house at the end of the street is red.
 |
 |- NP: The house at the end of the street
 |   |- PP: at the end of the street
 |       |- PP: of the street
 |- VP: is red

Or are you using phrase in any other way? Perhaps you could provide an example of what exactly you want to achieve?

Thread Thread
 
ivkemilioner profile image
ivkeMilioner

The house at the end of the street is red.
Car is red.
Book is red.

phrase = is red