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:

  • 'english' or 'en'
  • 'spanish' or 'es'

filterlinks

Optional. Default false. When set to true, sentences that are only links are not counted as a sentence.

filterusermentions

Optional. Default false. When set to true, sentences that are only Twitter user mentions (@username) are not counted as a sentence.

filterhashtags

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

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)

See Also