Everyone knows that the news is boring. Really boring. Unless if it's about Politicians and their scandals. That is fun! But alas, Politicians can commit only so many scandals. So, I am employing you to make the news more interesting.
Objective Given an HTML snippet, perform all the substitutions found here, that is, in this picture:
BUT you should not edit any HTML tags themselves. I call a valid word any word that is not found within any HTML tag or their attributes. That is, you shouldn't replace <div class="smartphone">iPhone</div>
with <div class="pokedex">iPhone</div>
, but should replace <div>election</div>
with <div>eating contest</div>
.
Parsing rules
- EDIT You should only match words delineated by a non-word. That is, you should only match full words. (E.g., match "Hello witness" but not "Hellowitness", "Hellow itness", or "Witnesspacelection."
- If you can't type out the character on your keyboard, you should display the closest equivalent. (E.g., "Smartphone" would really become "Pokedex")
- First-letter case or all-letter case must be retained. (E.g., "Allegedly, they died" becomes "Kinda probably, they died", "They allegedly died" becomes "They kinda probably died", and "THE ELECTION!" becomes "THE EATING CONTEST!", while "SpAcE" becomes "Spaaace" and "nEW STUDY" becomes "tumblr post")
- All cases must be matched. (I.e., you must match a word, regardless of its capitalization.)
- Any instance in which
a <vowel>
is met should becomean <vowel>
and vice versa. (E.g., "A senator" becomes "An elf-lord") You do not have to do this for every instance, but at least for your own replacements. - Anything plural must also retain pluralization in the translation (E.g., "Smartphones" becomes "pokedex" and "Spaces" becomes "Spaaaces")
- Anything in a certain tense must remain in that tense in the translation. (E.g., "Rebuilt" becomes "Avenged", "Rebuilds" becomes "Avenges", etc.)
- Anything in the singular must remain singular in the translation (E.g., "Congressional leader" becomes "River spirit")
- If the entry spans multiple HTML elements, you should still match it, but you may "throw away" any intermediate elements. (E.g.,
S<b>pa</b>ace
should become simply "spaaace"). If the entry is self-contained within a single element, it should be matched properly and the tag retained. - "The witnesses" should become "Those dudes I know"
- "witness" should become "This dude I know"
- "The witness" should become "That dude I know"
- "Couldn't be reached for comment" should become "Is guilty and everyone knows it"
- "Cannot be reached for comment" should become "Are guilty and everyone knows it"
Bonuses
If you meet a -N%
bonus, your new amount = (old amount) * (1 - N/100)
. So, if you met a -5%
bonus with a 500 byte code, your new amount = 500 * (1 - 5/100) = 500 * .95 = 475
.
- -5% bonus if, for every instance of "space" after the first replacement, an extra "a" is added. So, the first replacement would be "spaaace", the second would be "spaaaace", the third would be "spaaaaace", etc.
- -5% bonus if, for every valid number, you replace that number with a link to the respective XKCD comic. (It doesn't have to yet exist). If you do go for this bonus, you should match numbers such as
500
,3,000
,4 523
, and5.324
. (You may opt to replace, instead, the number with the image of the comic. If you do this, instead of a-5%
bonus, you will get a-15% bonus
. Another extra-15%
bonus if you can add the title-text to the picture, if any.) - -25% bonus if you can replace simultaneously all instances on the right side of the image with those on the left. (E.g., "spaaace" becomes "space", "eating contest" becomes "election", etc.) If you opt for any of the bonuses, you should be able to revert those to their respective entries. (E.g.,
http://www.xkcd.com/542
should become "542", and "spaaaaaaaace" should become "space".) - You may choose to do a minimum of 6 substitutions, but for each substitution not done (exclusive of bonus substitutions), you will receive an additional +10% penalty.
Example IOs (no bonuses)
Input: Witnesses allegedly used their smartphones to commit the crime.
Output: These dudes I know kinda probably used their pokedex to commit the crime.
Input: Mayor Golfalot rebuilt the city after the fatal election.
Output: Mayor Golfalot avenged the city after the fatal eating contest.
Input: This <b>new study</b> shows that people in <span class="space">space</span> cannot be reached for comment.
Output: This <b>tumblr post</b> shows that people in <span class="space">spaaace</span> are guilty and everyone knows it.
Input: <b>g</b><i>oo</i><s>g</s><u>le</u> glass is terrible. :(
Output: virtual boy is terrible. :(
Input: Electric SMARTPHONES have been shown to be more productive when not used by Senators and when not used in cars.
Output: Atomic POKEDEX have been shown to be more productive when not used by Elf-lords and when not used in cats.
Input: Homeland Security has been established as an evil foundation, especially in space.
Output: Homestar runner has been established as an evil foundation, especially in spaaace.
Input: The congressional leaders are testy today.
Output: The river spirits are testy today.
Input: SPACE is not a Senator or a cAR.
Output: SPAAACE is not an Elf-lord or a cat.
Input: Mr. Biz is running for reelection.
Output: Mr. Biz is running for reelection.
Input: Google glass !
Output: Virtual boy !
Input: New (or old) study
Output: New (or old) study
This is a code-golf, so the shortest program in bytes wins.
<br/>
) \$\endgroup\$