Created
June 24, 2017 12:11
-
-
Save wis/74ecff36b0badae0eea107126c0b1876 to your computer and use it in GitHub Desktop.
English words compressor. remove vowels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compressWord = function(word) { | |
console.log(word); | |
if(word.length <= 2) { | |
console.log(word + " =< 2"); | |
switch(word.toLowerCase()) { | |
case "you": | |
return "U"; | |
case "at": | |
return "@"; | |
case "be": | |
return "B"; | |
case "an": | |
return "ñ"; | |
case "in": | |
return "ŋ"; | |
case "on": | |
"ň"; | |
} | |
return word; | |
} | |
switch(word.toLowerCase()) { | |
case "are": | |
return "🆁"; | |
case "arent": | |
case "aren't": | |
return "🆁 not"; | |
case "you": | |
return "🆄"; | |
case "and": | |
return "&"; | |
case "would": | |
return "wUd"; | |
case "although": | |
return "althO"; | |
case "true": | |
return "trU"; | |
case "for": | |
return "𝟒"; | |
} | |
word = word.replace(/your/g, "🆄R"); | |
var w = word[0]; | |
var ord = word.substring(1); | |
ord = ord.replace(/a/g, ""); | |
ord = ord.replace(/A/g, ""); | |
ord = ord.replace(/e/g, ""); | |
ord = ord.replace(/E/g, ""); | |
ord = ord.replace(/i/g, ""); | |
ord = ord.replace(/I/g, ""); | |
ord = ord.replace(/U/g, ""); | |
ord = ord.replace(/u/g, ""); | |
var o,rd; | |
ord = ord.replace(/oo/g, "õ"); | |
ord = ord.replace(/OO/g, "Õ"); | |
ord = ord.replace(/o/g, ""); | |
ord = ord.replace(/O/g, ""); | |
o = ord.substring(0, ord.length - 2); | |
rd = ord.substring(ord.length - 2); | |
console.log("o ", o); | |
console.log("rd ", rd); | |
ord = o.replace(/y/g, "") + rd; | |
ord = o.replace(/Y/g, "") + rd; | |
var neword = w + ord; | |
console.log(word, word.length, neword, neword.length); | |
return neword; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment