Table of content
At LingoHub we utilize Postgres and Elasticsearch to handle our large text base. Is there a way to do an SQL word count for our translations? There is. I wanted to share with you two SQL queries for character count and word count of a text column:
# Character count
select sum(length(YOUR_COLUMN)) from YOUR_TABLE;
# Word count
select sum(array_length(regexp_split_to_array(YOUR_COLUMN, '\s'),1)) from YOUR_TABLE;
Related articles
Dev Bit: Auto generate UUID with Postgres and Rails 4
Learn how to auto-generate UUIDs with PostgreSQL and Rails 4 using the uuid-ossp extension and database-level defaults.
Dev Bit: How to add plugins to elasticsearch under Mac/Brew
Learn how to install Elasticsearch plugins on Mac with Homebrew, find the right libexec path, and verify plugins like Kopf or Elastic HQ.
Reuse regex matches in JavaScript replace() functions
Learn how JavaScript's replace() function works with regular expressions and special $ replacement patterns through practical examples and common use cases.