Urgent.News

What's breaking now, across thousands of outlets.

Tech

English: A vs. An

In the English language, there exists an indefinite article "a" that can precede a word, as in "a raccoon." However, certain words require the use of "an," such as "an apple." When creating text programmatically, I sought a function called a_or_an( apple ) that would determine which article to employ. At first glance, it might appear straightforward to simply examine the first letter for a vowel.

Regrettably, this approach would result in outputting "an unicorn," instead of the correct "a unicorn." The true rule lies not in whether the written word commences with a vowel letter, but whether the spoken word begins with a vowel sound. For instance, the word "unicorn" initiates with the vowel letter "u," yet it begins with a consonant sound "Y."

Conversely, "hour" begins with a consonant letter "h," yet it begins with a vowel sound "OW." Intrigued by the prevalence of these exceptions, I dedicated a day to analyzing the data, constructing visualizations, and compiling the findings. To my astonishment, merely 129 out of the 32,455 words within my dataset necessitated exceptions.

Written by urgent.news from Hacker News's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at redblobgames.com →

More in Tech

Some Space Optimisations

Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k MY FIRST APPROACH: A very valid…

  • First approach uses dictionary to store indices of array values
  • Second approach optimizes space with set of size k
  • Both methods find indices i, j with nums[i] == nums[j] and |i - j| = k

1,558 Tests Green and No Auth: The Tests That Never Actually Ran

A test named test_all_adapters_importable asserted nothing. It would pass forever, even if every adapter was broken. 57 of 65 assertion files were in the wrong format, and the harness returned 0 / 0…

  • Three issues cause green test suites with no actual tests.
  • 57 assertion files in wrong format in planner-critic-engine module.
  • CauterRule v0.3.0 reports 1,558 green tests due to missing import.

More from Saturday 19 September →