GetSentenceCount
Returns the number of sentences in a body of text. You can use this function to count the number of sentences in a long piece of text. It is also useful if you are programmatically using the ExtractSentence function and need to know the number of sentences in a piece of text.
Syntax
select GetSentenceCount(text [, language] [ USING PARAMETERS
[ filterlinks = boolean ]
[, filterusermentions = boolean ]
[, filterhashtags = boolean ] [, adjustcasing = boolean ] [, language = string ]
])
Parameters
Argument | Description |
---|---|
text |
The text from which to extract the number of sentences. Currently English and Spanish language text are supported for analysis. |
language |
The language:
|
|
Optional. Default false. When set to true, sentences that are only links are not counted as a sentence. |
|
Optional. Default false. When set to true, sentences that are only Twitter user mentions (@username) are not counted as a sentence. |
|
Optional. Default false. When set to true, sentences that are only Twitter hashtags (#hashtag) are not counted as a sentence. |
adjustcasing | Optional. Defaults to false. When set to true, all letters in the sentence are converted to upper-case before sentence detection. After sentence detection all letters are converted to lower-case. This option is helpful if the original data is all in lower-case and Pulse is incorrectly identifying parts of speech in the sentence. |
Notes
- The text argument is limited to 65,000 bytes.
-
This function must be used with the
over()
clause. Use withOVER(PARTITION BEST)
for the best performance if the query does not require specific columns in theover()
clause. -
language can be specified as an argument and/or as a parameter where the argument value supersedes the parameter value.
Examples
SELECT GetSentenceCount('The quick brown fox jumped over the lazy dog. Every good boy deserves fudge') OVER(PARTITION BEST); sentence_count ---------------- 2 (1 row) SELECT getsentencecount('http://hp.com. @hp. http://hp.com is great!') OVER(PARTITION BEST); sentence_count ---------------- 3 (1 row)
select getsentencecount('el zorro rapido brinco sobre el perro flojo. Todos los chicos buenos merecen un premio' using PARAMETERS language='spanish') over(); sentence_count ---------------- 2 (1 row) select getsentencecount('el zorro rapido brinco sobre el perro flojo. Todos los chicos buenos merecen un premio' ,'spanish') over(); sentence_count ---------------- 2 (1 row) select getsentencecount('the quick brown fox jumped over the lazy dog. All good boys deserve fudge' using parameters language='english') over(); sentence_count ---------------- 2 (1 row) select getsentencecount('the quick brown fox jumped over the lazy dog. All good boys deserve fudge' ,'english') over(); sentence_count ---------------- 2 (1 row)
Filtering Links and User Mentions
SELECT GetSentenceCount('http://hp.com. @hp. http://hp.com is great!' USING PARAMETERS filterlinks=true, filterusermentions=true) OVER(PARTITION BEST); sentence_count ---------------- 1 (1 row)