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.
Dev Bit: How to reuse matched value of regex in JavaScript's replace() function
JavaScript's replace() function has special $ references that can be used with regular expressions to replace (sub)strings. In this article, we provide a detailed overview of how it works.