Simple word counter using postgres

-- Setup a dictionary in enus CREATE TEXT SEARCH DICTIONARY dict_en ( TEMPLATE = simple, STOPWORDS = english ); CREATE TEXT SEARCH CONFIGURATION ENUS(copy = english); ALTER TEXT SEARCH CONFIGURATION ENUS ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, hword, hword_part, word with dict_en; --Query for the word and number of repetitions dictionary select word, nentry from ts_stat('select to_tsvector(''enus'', field_text) from table) order by nentry desc
Simple way to count words excluding stop words. First creating a dictionary in the chosen language, then perform a query using to_tsvector and ts_stat.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.