On this Page
This Snap enables you to identify the most common words in the input dataset and compute the frequency with which they occur. It also offers you the ability to specify the number of most common words you want to include in the output. The input of this Snap should be an array of tokens, which can be generated by the Tokenizer Snap.
This Snap is required for the Bag of Words Snap. The output of this Snap should be connected to the second input view of the Bag of Words Snap |
None.
Accounts are not used with this Snap.
Input | This Snap has exactly one document input view. |
---|---|
Output | This Snap has exactly one document output view. |
Error | This Snap has at most one document error view. |
None.
None.
The idea is to enable the user to get a good idea of the Snap's functionality, prerequisites, limitations, accounts, and views. Fill all the relevant sections, and if the information is not available (perhaps it is a new Snap and you don't know its limitations), then just add "None".
Label | Required. The name for the Snap. Modify this to be more specific, especially if there are more than one of the same Snap in the pipeline. |
---|---|
Token array field | Required. The field containing the array of tokens that must be examined for common words. This suggestible property is a JSONPath. Click the Suggestions icon to view a list of all available text fields. Default value: None. Example: $text |
Top words limit | Required. The number of most common words to be included in the output. Default value: 100 |
In this example, we shall demonstrate how you can use the Tokenizer and Common Words Snaps to compute the frequency of the most common words in a dataset.
Download this pipeline.
This pipeline contains the following Snaps:
The File Reader Snap reads an extract of the Yelp dataset (you can review the entire dataset here) and offers a binary stream as output. The JSON Parser Snap converts this binary stream into document stream, as shown below: The field $text refers to sentences from Yelp user reviews. These sentences are used as input to the Tokenizer Snap using the following configurations: As you can see, we selected $text for the Text field property. This is the content that will be tokenized and output as an array of tokens, as shown below: As you can see in the screenshot above, each word in the input sentences has now become a token, and sentences in each input document become an array. The Common Words Snap computes the frequency of each word that appears in the array of tokens. We need to configure the Common Words Snap to pick up data from the Tokenizer Snap and output frequency numbers related to the top 100 most common words, as shown below: The pipeline, when run, offers the following output: Based on the first 50 records of the Yelp dataset, during the pipeline validation, the most common words occur with the frequency shown above. Download this pipeline. |