Quantcast
Channel: Remove filler words from a string - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 6

Remove filler words from a string

$
0
0

I always stutter and use filler words when speaking to a lot of people at a time. So I need something to remove all my filler words.

So here is the challenge.

Your program should take input as a string. You can assume that all characters in the string are ASCII printables with character codes between 32 and 126 inclusive, and contains at least one character which is not a space or a period ..

Then:

  1. Split the input into sentences by periods followed by spaces. In other words, . .
  2. Remove any um, uh, like or you know from the string (case-insensitive). (Not substrings, but space-seperated "words" or "phrases", for example sum and ayou knowb are left unchanged).
  3. Replace any continuous string of two or more spaces with one space.
  4. Titlecase the first word of every sentence. That is, make the first character (if it is a letter in [A-Za-z]) uppercase and the other letters lowercase.
  5. Remove all spaces before a comma, and any spaces before the first non-space character.

The steps are only done once, not until the string stops changing.

However, filler words in quoted strings should not be removed, as this is not using the words, this is mentioning them. A string is quoted iff it is between an odd-numbered " and an even-numbered one (the first one is number 1, the next 2, and so on).

Test cases:

Hi, it's me here. -> Hi, it's me here.Like this sucks. -> This sucks.Today, I will be using, um uh uh um Linux. -> Today, I will be using, Linux.JS floats have like, 64 bits. -> Js floats have, 64 bits."Um" is an overused word. -> "Um" is an overused word."Um" has hex codes, uh 55, and you know, 6d. -> "Um" has hex codes, 55, and, 6d.You know I love code golf. -> I love code golf.Say "like" and "uh" less. -> Say "like" and "uh" less.Um "uh" like "you know" -> "uh" "you know"Ah yes,     Spaces! -> Ah yes, Spaces!Um here are two sentences. Uh um this is the last one. -> Here are two sentences. This is the last one.Uh 1. Uh digits again. -> 1. Digits again.Uh +1. Um    plus one. -> +1. Plus one.uM aLtErNaTiNg CaPs -> Alternating CaPs   , get it right! -> , get it right!Who even likes it? -> Who even likes it? 1.5 is a fine number. -> 1.5 is a fine number.cOmPoUnD-wOrD. -> Compound-word.cOmPoUnD_wOrD. -> Compound_word._uNdErScOrE. -> _underscore.1A is hex. -> 1a is hex.Yes, you you know know what I mean. -> Yes, you know what I mean."Fruit flies like bananas. As said." just like "Time flies like an arrow. As said." -> "Fruit flies like bananas. As said." just like "Time flies an arrow. As said."Um. You know. Yes. -> . . Yes.

This is , so fewest bytes wins!


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>