6
\$\begingroup\$

Write a program or function to estimate as closely as possible the number of syllables in English words.

The input list is here: 1000 basic English words. There are only 997 words because a few duplicates were removed.

For each word, output a line containing the word, a comma (,), and the number of syllables and no other characters except for new-line, e.g. photograph,3 (pho-to-graph). Use the code snippet below to score your answer. Paste your code and output into the respective boxes and press the "Submit" button.

Scoring

All scoring is calculated automatically by the snippet, but here is how it works in order to lower your score:

  • 60 points for each byte, however if you don't use any Unicode codepoints above U+00FF the snippet will calculate characters instead of bytes
  • Each word where the number of syllables is correct will score 0

Scoring table for wrong syllables. The axes are symmetrical, one is the number of wrong syllables per word, and the other is the number of words with that number of syllables wrong:

 | 1| 2| 3| 4| …
-+--+--+--+--+--
1| 1| 3| 6|10|
-+--+--+--+--+--
2| 3| 9|18|30|
-+--+--+--+--+--
3| 6|18|36|60|
-+--+--+--+--+--
4|10|30|60|100
-+--+--+--+--+--
…|  |  |  |  |
  • If you have 200 words with 1 wrong syllable and 100 words with 2 wrong syllables your score for wrong syllables will be 200*201/2 * 1*2/2 + 100*101/2 * 2*3/2 = 20100 * 1 + 5050 * 3 = 20100 + 15150 = 35250
  • The scoring is designed to make it easy to lower your score when you have a lot of wrong syllables but hard when you only have a few
  • Duplicate words in your output will not be removed. Outputting photograph,1, photograph,2, photograph,3 will simply increase your score
  • Post all three scores, Code, Word and Total. The Total Score will be used to determine a winner

You can use the code snippet to see how many syllables are expected for each word. Simply run it with no input and it will output the list in the expected format, as well as all the words where the number of syllables is wrong, e.g. photograph *1, (3).

var syl = {
  "a": 1,
  "about": 2,
  "above": 2,
  "across": 2,
  "act": 1,
  "active": 2,
  "activity": 4,
  "add": 1,
  "afraid": 2,
  "after": 2,
  "again": 2,
  "age": 1,
  "ago": 2,
  "agree": 2,
  "air": 1,
  "all": 1,
  "alone": 2,
  "along": 2,
  "already": 3,
  "always": 2,
  "am": 1,
  "amount": 2,
  "an": 1,
  "and": 1,
  "angry": 2,
  "another": 3,
  "answer": 2,
  "any": 2,
  "anyone": 3,
  "anything": 3,
  "anytime": 3,
  "appear": 3,
  "apple": 2,
  "are": 1,
  "area": 3,
  "arm": 1,
  "army": 2,
  "around": 2,
  "arrive": 2,
  "art": 1,
  "as": 1,
  "ask": 1,
  "at": 1,
  "attack": 2,
  "aunt": 1,
  "autumn": 2,
  "away": 2,
  "baby": 2,
  "back": 1,
  "bad": 1,
  "bag": 1,
  "ball": 1,
  "bank": 1,
  "base": 1,
  "basket": 2,
  "bath": 1,
  "be": 1,
  "bean": 1,
  "bear": 1,
  "beautiful": 3,
  "bed": 1,
  "bedroom": 2,
  "beer": 2,
  "before": 2,
  "begin": 2,
  "behave": 2,
  "behind": 2,
  "bell": 1,
  "below": 2,
  "besides": 2,
  "best": 1,
  "better": 2,
  "between": 2,
  "big": 1,
  "bird": 1,
  "birth": 1,
  "birthday": 2,
  "bit": 1,
  "bite": 1,
  "black": 1,
  "bleed": 1,
  "block": 1,
  "blood": 1,
  "blow": 1,
  "blue": 1,
  "board": 1,
  "boat": 1,
  "body": 2,
  "boil": 2,
  "bone": 1,
  "book": 1,
  "border": 2,
  "born": 1,
  "borrow": 2,
  "both": 1,
  "bottle": 2,
  "bottom": 2,
  "bowl": 1,
  "box": 1,
  "boy": 1,
  "branch": 1,
  "brave": 1,
  "bread": 1,
  "break": 1,
  "breakfast": 2,
  "breathe": 1,
  "bridge": 1,
  "bright": 1,
  "bring": 1,
  "brother": 2,
  "brown": 1,
  "brush": 1,
  "build": 1,
  "burn": 1,
  "bus": 1,
  "business": 2,
  "busy": 2,
  "but": 1,
  "buy": 1,
  "by": 1,
  "cake": 1,
  "call": 1,
  "can": 1,
  "candle": 2,
  "cap": 1,
  "car": 1,
  "card": 1,
  "care": 1,
  "careful": 2,
  "careless": 2,
  "carry": 2,
  "case": 1,
  "cat": 1,
  "catch": 1,
  "central": 2,
  "century": 3,
  "certain": 2,
  "chair": 1,
  "chance": 1,
  "change": 1,
  "chase": 1,
  "cheap": 1,
  "cheese": 1,
  "chicken": 2,
  "child": 1,
  "children": 2,
  "chocolate": 2,
  "choice": 1,
  "choose": 1,
  "circle": 2,
  "city": 2,
  "class": 1,
  "clean": 1,
  "clear": 2,
  "clever": 2,
  "climb": 1,
  "clock": 1,
  "close": 1,
  "cloth": 1,
  "clothes": 1,
  "cloud": 1,
  "cloudy": 2,
  "coat": 1,
  "coffee": 2,
  "coin": 1,
  "cold": 1,
  "collect": 2,
  "colour": 2,
  "comb": 1,
  "come": 1,
  "comfortable": 3,
  "common": 2,
  "compare": 2,
  "complete": 2,
  "computer": 3,
  "condition": 3,
  "contain": 2,
  "continue": 3,
  "control": 2,
  "cook": 1,
  "cool": 1,
  "copper": 2,
  "corn": 1,
  "corner": 2,
  "correct": 2,
  "cost": 1,
  "count": 1,
  "country": 2,
  "course": 1,
  "cover": 2,
  "crash": 1,
  "cross": 1,
  "cry": 1,
  "cup": 1,
  "cupboard": 2,
  "cut": 1,
  "dance": 1,
  "dangerous": 3,
  "dark": 1,
  "daughter": 2,
  "day": 1,
  "dead": 1,
  "decide": 2,
  "decrease": 2,
  "deep": 1,
  "deer": 2,
  "depend": 2,
  "desk": 1,
  "destroy": 2,
  "develop": 3,
  "die": 1,
  "different": 2,
  "difficult": 3,
  "dinner": 2,
  "direction": 3,
  "dirty": 2,
  "discover": 3,
  "dish": 1,
  "do": 1,
  "dog": 1,
  "door": 1,
  "double": 2,
  "down": 1,
  "draw": 1,
  "dream": 1,
  "dress": 1,
  "drink": 1,
  "drive": 1,
  "drop": 1,
  "dry": 1,
  "duck": 1,
  "dust": 1,
  "duty": 2,
  "each": 1,
  "ear": 2,
  "early": 2,
  "earn": 1,
  "earth": 1,
  "east": 1,
  "easy": 2,
  "eat": 1,
  "education": 4,
  "effect": 2,
  "egg": 1,
  "eight": 1,
  "either": 2,
  "electric": 3,
  "elephant": 3,
  "else": 1,
  "empty": 2,
  "end": 1,
  "enemy": 3,
  "enjoy": 2,
  "enough": 2,
  "enter": 2,
  "entrance": 2,
  "equal": 2,
  "escape": 2,
  "even": 2,
  "evening": 2,
  "event": 2,
  "ever": 2,
  "every": 2,
  "everybody": 4,
  "everyone": 3,
  "exact": 2,
  "examination": 5,
  "example": 3,
  "except": 2,
  "excited": 3,
  "exercise": 3,
  "expect": 2,
  "expensive": 3,
  "explain": 2,
  "extremely": 3,
  "eye": 1,
  "face": 1,
  "fact": 1,
  "fail": 2,
  "fall": 1,
  "false": 1,
  "family": 2,
  "famous": 2,
  "far": 1,
  "farm": 1,
  "fast": 1,
  "fat": 1,
  "father": 2,
  "fault": 1,
  "fear": 2,
  "feed": 1,
  "feel": 2,
  "female": 3,
  "fever": 2,
  "few": 1,
  "fight": 1,
  "fill": 1,
  "film": 1,
  "find": 1,
  "fine": 1,
  "finger": 2,
  "finish": 2,
  "fire": 2,
  "first": 1,
  "fit": 1,
  "five": 1,
  "fix": 1,
  "flag": 1,
  "flat": 1,
  "float": 1,
  "floor": 1,
  "flour": 2,
  "flower": 2,
  "fly": 1,
  "fold": 1,
  "food": 1,
  "fool": 1,
  "foot": 1,
  "football": 2,
  "for": 1,
  "force": 1,
  "foreign": 2,
  "forest": 2,
  "forget": 2,
  "forgive": 2,
  "fork": 1,
  "form": 1,
  "four": 1,
  "fox": 1,
  "free": 1,
  "freedom": 2,
  "freeze": 1,
  "fresh": 1,
  "friend": 1,
  "friendly": 2,
  "from": 1,
  "front": 1,
  "fruit": 1,
  "full": 1,
  "fun": 1,
  "funny": 2,
  "furniture": 3,
  "further": 2,
  "future": 2,
  "game": 1,
  "garden": 2,
  "gate": 1,
  "general": 2,
  "gentleman": 3,
  "get": 1,
  "gift": 1,
  "give": 1,
  "glad": 1,
  "glass": 1,
  "go": 1,
  "goat": 1,
  "god": 1,
  "gold": 1,
  "good": 1,
  "goodbye": 2,
  "grandfather": 3,
  "grandmother": 3,
  "grass": 1,
  "grave": 1,
  "great": 1,
  "green": 1,
  "grey": 1,
  "ground": 1,
  "group": 1,
  "grow": 1,
  "gun": 1,
  "hair": 1,
  "half": 1,
  "hall": 1,
  "hammer": 2,
  "hand": 1,
  "happen": 2,
  "happy": 2,
  "hard": 1,
  "hat": 1,
  "hate": 1,
  "have": 1,
  "he": 1,
  "head": 1,
  "healthy": 2,
  "hear": 2,
  "heart": 1,
  "heaven": 2,
  "heavy": 2,
  "height": 1,
  "hello": 2,
  "help": 1,
  "hen": 1,
  "her": 1,
  "here": 2,
  "hers": 1,
  "hide": 1,
  "high": 1,
  "hill": 1,
  "him": 1,
  "his": 1,
  "hit": 1,
  "hobby": 2,
  "hold": 1,
  "hole": 1,
  "holiday": 3,
  "home": 1,
  "hope": 1,
  "horse": 1,
  "hospital": 3,
  "hot": 1,
  "hotel": 2,
  "hour": 2,
  "house": 1,
  "how": 1,
  "hundred": 2,
  "hungry": 2,
  "hurry": 2,
  "hurt": 1,
  "husband": 2,
  "I": 1,
  "ice": 1,
  "idea": 3,
  "if": 1,
  "important": 3,
  "in": 1,
  "increase": 2,
  "inside": 2,
  "into": 2,
  "introduce": 3,
  "invent": 2,
  "invite": 2,
  "iron": 2,
  "is": 1,
  "island": 2,
  "it": 1,
  "its": 1,
  "jelly": 2,
  "job": 1,
  "join": 1,
  "juice": 1,
  "jump": 1,
  "just": 1,
  "keep": 1,
  "key": 1,
  "kill": 1,
  "kind": 1,
  "king": 1,
  "kitchen": 2,
  "knee": 1,
  "knife": 1,
  "knock": 1,
  "know": 1,
  "ladder": 2,
  "lady": 2,
  "lamp": 1,
  "land": 1,
  "large": 1,
  "last": 1,
  "late": 1,
  "lately": 2,
  "laugh": 1,
  "lazy": 2,
  "lead": 1,
  "leaf": 1,
  "learn": 1,
  "leave": 1,
  "left": 1,
  "leg": 1,
  "lend": 1,
  "length": 1,
  "less": 1,
  "lesson": 2,
  "let": 1,
  "letter": 2,
  "library": 2,
  "lie": 1,
  "life": 1,
  "light": 1,
  "like": 1,
  "lion": 2,
  "lip": 1,
  "list": 1,
  "listen": 2,
  "little": 2,
  "live": 1,
  "lock": 1,
  "lonely": 2,
  "long": 1,
  "look": 1,
  "lose": 1,
  "lot": 1,
  "love": 1,
  "low": 1,
  "lower": 2,
  "luck": 1,
  "machine": 2,
  "main": 1,
  "make": 1,
  "male": 2,
  "man": 1,
  "many": 2,
  "map": 1,
  "mark": 1,
  "market": 2,
  "marry": 2,
  "matter": 2,
  "may": 1,
  "me": 1,
  "meal": 2,
  "mean": 1,
  "measure": 2,
  "meat": 1,
  "medicine": 3,
  "meet": 1,
  "member": 2,
  "mention": 2,
  "method": 2,
  "middle": 2,
  "milk": 1,
  "million": 2,
  "mind": 1,
  "minute": 2,
  "miss": 1,
  "mistake": 2,
  "mix": 1,
  "model": 2,
  "modern": 2,
  "moment": 2,
  "money": 2,
  "monkey": 2,
  "month": 1,
  "moon": 1,
  "more": 1,
  "morning": 2,
  "most": 1,
  "mother": 2,
  "mountain": 2,
  "mouth": 1,
  "move": 1,
  "much": 1,
  "music": 2,
  "must": 1,
  "my": 1,
  "name": 1,
  "narrow": 2,
  "nation": 2,
  "nature": 2,
  "near": 2,
  "nearly": 2,
  "neck": 1,
  "need": 1,
  "needle": 2,
  "neighbour": 2,
  "neither": 2,
  "net": 1,
  "never": 2,
  "new": 1,
  "news": 1,
  "newspaper": 3,
  "next": 1,
  "nice": 1,
  "night": 1,
  "nine": 1,
  "no": 1,
  "noble": 2,
  "noise": 1,
  "none": 1,
  "nor": 1,
  "north": 1,
  "nose": 1,
  "not": 1,
  "nothing": 2,
  "notice": 2,
  "now": 1,
  "number": 2,
  "obey": 2,
  "object": 2,
  "ocean": 2,
  "of": 1,
  "off": 1,
  "offer": 2,
  "office": 2,
  "often": 2,
  "oil": 2,
  "old": 1,
  "on": 1,
  "one": 1,
  "only": 2,
  "open": 2,
  "opposite": 3,
  "or": 1,
  "orange": 2,
  "order": 2,
  "other": 2,
  "our": 2,
  "out": 1,
  "outside": 2,
  "over": 2,
  "own": 1,
  "page": 1,
  "pain": 1,
  "paint": 1,
  "pair": 1,
  "pan": 1,
  "paper": 2,
  "parent": 2,
  "park": 1,
  "part": 1,
  "partner": 2,
  "party": 2,
  "pass": 1,
  "past": 1,
  "path": 1,
  "pay": 1,
  "peace": 1,
  "pen": 1,
  "pencil": 2,
  "people": 2,
  "pepper": 2,
  "per": 1,
  "perfect": 2,
  "period": 3,
  "person": 2,
  "petrol": 2,
  "photograph": 3,
  "piano": 3,
  "pick": 1,
  "picture": 2,
  "piece": 1,
  "pig": 1,
  "pin": 1,
  "pink": 1,
  "place": 1,
  "plane": 1,
  "plant": 1,
  "plastic": 2,
  "plate": 1,
  "play": 1,
  "please": 1,
  "pleased": 1,
  "plenty": 2,
  "pocket": 2,
  "point": 1,
  "poison": 2,
  "police": 1,
  "polite": 2,
  "pool": 1,
  "poor": 1,
  "popular": 3,
  "position": 3,
  "possible": 3,
  "potato": 3,
  "pour": 1,
  "power": 2,
  "present": 2,
  "press": 1,
  "pretty": 2,
  "prevent": 2,
  "price": 1,
  "prince": 1,
  "prison": 2,
  "private": 2,
  "prize": 1,
  "probably": 3,
  "problem": 2,
  "produce": 2,
  "promise": 2,
  "proper": 2,
  "protect": 2,
  "provide": 2,
  "public": 2,
  "pull": 1,
  "punish": 2,
  "pupil": 2,
  "push": 1,
  "put": 1,
  "queen": 1,
  "question": 2,
  "quick": 1,
  "quiet": 2,
  "quite": 1,
  "radio": 3,
  "rain": 1,
  "rainy": 2,
  "raise": 1,
  "reach": 1,
  "read": 1,
  "ready": 2,
  "real": 2,
  "really": 2,
  "receive": 2,
  "record": 2,
  "red": 1,
  "remember": 3,
  "remind": 2,
  "remove": 2,
  "rent": 1,
  "repair": 2,
  "repeat": 2,
  "reply": 2,
  "report": 2,
  "rest": 1,
  "restaurant": 2,
  "result": 2,
  "return": 2,
  "rice": 1,
  "rich": 1,
  "ride": 1,
  "right": 1,
  "ring": 1,
  "rise": 1,
  "road": 1,
  "rob": 1,
  "rock": 1,
  "room": 1,
  "round": 1,
  "rubber": 2,
  "rude": 1,
  "rule": 1,
  "ruler": 2,
  "run": 1,
  "rush": 1,
  "sad": 1,
  "safe": 1,
  "sail": 2,
  "salt": 1,
  "same": 1,
  "sand": 1,
  "save": 1,
  "say": 1,
  "school": 1,
  "science": 2,
  "scissors": 2,
  "search": 1,
  "seat": 1,
  "second": 2,
  "see": 1,
  "seem": 1,
  "sell": 1,
  "send": 1,
  "sentence": 2,
  "serve": 1,
  "seven": 2,
  "several": 2,
  "sex": 1,
  "shade": 1,
  "shadow": 2,
  "shake": 1,
  "shape": 1,
  "share": 1,
  "sharp": 1,
  "she": 1,
  "sheep": 1,
  "sheet": 1,
  "shelf": 1,
  "shine": 1,
  "ship": 1,
  "shirt": 1,
  "shoe": 1,
  "shoot": 1,
  "shop": 1,
  "short": 1,
  "should": 1,
  "shoulder": 2,
  "shout": 1,
  "show": 1,
  "sick": 1,
  "side": 1,
  "signal": 2,
  "silence": 2,
  "silly": 2,
  "silver": 2,
  "similar": 3,
  "simple": 2,
  "since": 1,
  "sing": 1,
  "single": 2,
  "sink": 1,
  "sister": 2,
  "sit": 1,
  "six": 1,
  "size": 1,
  "skill": 1,
  "skin": 1,
  "skirt": 1,
  "sky": 1,
  "sleep": 1,
  "slip": 1,
  "slow": 1,
  "small": 1,
  "smell": 1,
  "smile": 2,
  "smoke": 1,
  "snow": 1,
  "so": 1,
  "soap": 1,
  "sock": 1,
  "soft": 1,
  "some": 1,
  "someone": 2,
  "something": 2,
  "sometimes": 2,
  "son": 1,
  "soon": 1,
  "sorry": 2,
  "sound": 1,
  "soup": 1,
  "south": 1,
  "space": 1,
  "speak": 1,
  "special": 2,
  "speed": 1,
  "spell": 1,
  "spend": 1,
  "spoon": 1,
  "sport": 1,
  "spread": 1,
  "spring": 1,
  "square": 1,
  "stamp": 1,
  "stand": 1,
  "star": 1,
  "start": 1,
  "station": 2,
  "stay": 1,
  "steal": 2,
  "steam": 1,
  "step": 1,
  "still": 1,
  "stomach": 1,
  "stone": 1,
  "stop": 1,
  "store": 1,
  "storm": 1,
  "story": 2,
  "strange": 1,
  "street": 1,
  "strong": 1,
  "structure": 2,
  "student": 2,
  "study": 2,
  "stupid": 2,
  "subject": 2,
  "substance": 2,
  "successful": 3,
  "such": 1,
  "sudden": 2,
  "sugar": 2,
  "suitable": 3,
  "summer": 2,
  "sun": 1,
  "sunny": 2,
  "support": 2,
  "sure": 1,
  "surprise": 2,
  "sweet": 1,
  "swim": 1,
  "sword": 1,
  "table": 2,
  "take": 1,
  "talk": 1,
  "tall": 1,
  "taste": 1,
  "taxi": 2,
  "tea": 1,
  "teach": 1,
  "team": 1,
  "tear": [1, 2],
  "telephone": 3,
  "television": 4,
  "tell": 1,
  "ten": 1,
  "tennis": 2,
  "terrible": 3,
  "test": 1,
  "than": 1,
  "that": 1,
  "the": 1,
  "their": 1,
  "then": 1,
  "there": 1,
  "therefore": 2,
  "these": 1,
  "thick": 1,
  "thin": 1,
  "thing": 1,
  "think": 1,
  "third": 1,
  "this": 1,
  "though": 1,
  "threat": 1,
  "three": 1,
  "tidy": 2,
  "tie": 1,
  "title": 2,
  "to": 1,
  "today": 2,
  "toe": 1,
  "together": 3,
  "tomorrow": 3,
  "tonight": 2,
  "too": 1,
  "tool": 1,
  "tooth": 1,
  "top": 1,
  "total": 2,
  "touch": 1,
  "town": 1,
  "train": 1,
  "tram": 1,
  "travel": 2,
  "tree": 1,
  "trouble": 2,
  "true": 1,
  "trust": 1,
  "try": 1,
  "turn": 1,
  "twice": 1,
  "type": 1,
  "uncle": 2,
  "under": 2,
  "understand": 3,
  "unit": 2,
  "until": 2,
  "up": 1,
  "use": 1,
  "useful": 2,
  "usual": 2,
  "usually": 3,
  "vegetable": 3,
  "very": 2,
  "village": 2,
  "visit": 2,
  "voice": 1,
  "wait": 1,
  "wake": 1,
  "walk": 1,
  "want": 1,
  "warm": 1,
  "wash": 1,
  "waste": 1,
  "watch": 1,
  "water": 2,
  "way": 1,
  "we": 1,
  "weak": 1,
  "wear": 1,
  "weather": 2,
  "wedding": 2,
  "week": 1,
  "weight": 1,
  "welcome": 2,
  "well": 1,
  "west": 1,
  "wet": 1,
  "what": 1,
  "wheel": 2,
  "when": 1,
  "where": 1,
  "which": 1,
  "while": 2,
  "white": 1,
  "who": 1,
  "why": 1,
  "wide": 1,
  "wife": 1,
  "wild": 2,
  "will": 1,
  "win": 1,
  "wind": 1,
  "window": 2,
  "wine": 1,
  "winter": 2,
  "wire": 2,
  "wise": 1,
  "wish": 1,
  "with": 1,
  "without": 2,
  "woman": 2,
  "wonder": 2,
  "word": 1,
  "work": 1,
  "world": 1,
  "worry": 2,
  "worst": 1,
  "write": 1,
  "wrong": 1,
  "year": 2,
  "yes": 1,
  "yesterday": 3,
  "yet": 1,
  "you": 1,
  "young": 1,
  "your": 1,
  "zero": 2,
  "zoo": 1
};

function checkcode(e) {
  var t = document.getElementById('words').value;
  var re = new RegExp(/^(\w+),(\d+)/gm);
  var lines = t.match(re);
  re = new RegExp(/^(\w+),(\d+)/);
  if (!lines) {
    lines = [];
  }
  var keys = JSON.parse(JSON.stringify(syl));
  var tally = [];
  var wrong = [];
  for (i = 0; i < lines.length; ++i) {
    var num = lines[i].match(re);
    if (num[1] in syl) {
      var res = num[1] !== "tear"? Math.abs(syl[num[1]] - num[2]): Math.min(Math.abs(syl[num[1]][0] - num[2]), Math.abs(syl[num[1]][1] - num[2]));
      if (!(res in tally)) {
        tally[res] = 0;
      }
      ++tally[res];
      if (res) {
        wrong.push(num[1] + " *" + num[2] + ", (" + syl[num[1]] + ")");
      }
      delete(keys[num[1]]);
    }
  }
  for (i in keys) {
    if (!(keys[i] in tally)) {
      tally[keys[i]] = 0;
    }
    ++tally[keys[i]];
  }
  var score = 0;
  for (i = 0; i < tally.length; ++i) {
    if (i in tally) {
      score += i * (i + 1) * tally[i] * (tally[i] + 1) / 4;
    }
  }
  var missing = 0;
  var missinglist = []
  for (i in keys) {
    missinglist.push(i + "," + keys[i]);
    ++missing;
  }
  codescore = document.getElementById("code").value.length;
  codescore = document.getElementById("code").value;
  if (codescore.match(/[^\u0000-\u00FF]/)) {
    cs1 = codescore.match(/[\u0000-\u007F]/g);
    cs2 = codescore.match(/[\u0080-\u07FF]/g);
    cs3 = codescore.match(/[\u0800-\uFFFF]/g);
    codescore = (cs1? cs1.length: 0) + (cs2? cs2.length * 2: 0) + (cs3? cs3.length * 3: 0);
  }
  else {
    codescore = codescore.length;
  }
  codescore *= 60;
  document.getElementById("result").value = "Code score: " + codescore + "\nWord score: " + score + "\nTotal score: " + (codescore + score) + "\nValid lines: " + lines.length + "\nMissing words: " + missing + "\n\nMissing words:\n" + missinglist.join("\n") + "\n\nWrong number:\n" + wrong.join("\n");
}
textarea {
        width: 320px;
        height: 480px;
      }
      
      textarea#code {
        width: 650px;
        height: 80px;
      }
      
      span {
        display: inline-block;
      }
<span>Code:<br/>
    <textarea id="code">
</textarea></span><br/>
    <span>Output:<br/>
    <textarea id="words">
</textarea></span>
    <span>Score:<br/><textarea id="result" disabled="disabled">
</textarea></span><br/>
    <input type="submit" onclick="checkcode(this)"/>

The variant of English used for the syllables is Australian English, spoken slower than usual. There is one word in the list that has two pronunciations with different numbers of syllables: tear to rip, 1 syllable; and water from the eye, 2 syllables (te-ar). Either tear,1 or tear,2 is correct for this word. I have gone through the whole list twice, but there might be some errors. Please don't complain that a particular word has a different number of syllables in British, American, etc. English. I will only make changes to the expected number of syllables if I agree that the number of syllables is wrong in Australian English.

Standard Code Golf rules with custom scoring.

\$\endgroup\$
  • \$\begingroup\$ Should the function just take the word as input an output the number of syllables? \$\endgroup\$ – LegionMammal978 Jan 17 '16 at 11:09
  • \$\begingroup\$ @LegionMammal978 I have provided a few examples of the output lines such as photograph,3, plus running the snippet with no input also shows the expected output in the correct format. \$\endgroup\$ – CJ Dennis Jan 17 '16 at 11:11
  • \$\begingroup\$ I know, but what should our programs output? Adding support for the word,number format would nearly double my code length, as opposed to just outputting the number. \$\endgroup\$ – LegionMammal978 Jan 17 '16 at 11:13
  • \$\begingroup\$ @LegionMammal978 If you just output the number there's no way for the snippet to know which was the input word. If your language is PHP or Perl, writing print("$w,$n") instead of print($n) doesn't add that many characters. It's best to input the entire list to your program (e.g. as a file) and output the whole list too. \$\endgroup\$ – CJ Dennis Jan 17 '16 at 11:16
  • \$\begingroup\$ However, that adds many more bytes. It's the difference between programprogramprogram&, #<>","<>ToString[programprogramprogram]&, and Print[""<>(#<>","<>ToString[programprogramprogram]<>"\n"&/@StringSplit[InputString[]~Import~"Text"])]. \$\endgroup\$ – LegionMammal978 Jan 17 '16 at 11:19
1
\$\begingroup\$

Ruby, 5160 code + 4008 words = 9168

->l{l.lines{|w|print w.chop,?,,w.sub("e\n","").tr_s('aeiouy','******').count('*'),$/}}

Anonymous function. Expects as an argument all the words in a single string, newline separated, (as direct from pastebin.) Requires a trailing newline in order to print zoo correctly (can be fixed for 1 byte if required.)

ungolfed

f=->l{                       #Lambda assigned to varible f. Call as f[list]
  l.lines{|w|                #for each line, complete with newline
    print w.chop,?,,         #print the word with the newline removed, and a comma, and the following:
    w.sub("e\n","").         #Take the word. If there is an (e and newline) at the end remove them
    tr_s('aeiouy','******'). #convert all vowel clusters to a single *
    count('*'),              #and count the stars
    $/                       #finally print a newline ($/ is a special variable holding the line separator, newline by default.)
  }
}

wrong words

About twice as many as Legionmamma's mathematica answer.

I've marked 3 common and easy to fix errors. Whether difference in code length is worth it is another matter. I might get back to this later.

anyone *2, (3)
appear *2, (3)
apple *1, (2)             #A consonant+le ending (19 incidences)
area *2, (3)
be *0, (1)                #B words must have at least one syllable (7 incidences)
beer *1, (2)
besides *3, (2)           #C es ending (3 incidences)
boil *1, (2)
bottle *1, (2)            #A
business *3, (2)
candle *1, (2)            #A
careful *3, (2)
careless *3, (2)
chocolate *3, (2)
circle *1, (2)            #A
clear *1, (2)
clothes *2, (1)           #C
deer *1, (2)
different *3, (2)
double *1, (2)            #A
ear *1, (2)
evening *3, (2)
every *3, (2)
everybody *5, (4)
example *2, (3)           #A
extremely *4, (3)
fail *1, (2)
family *3, (2)
fear *1, (2)
feel *1, (2)
female *2, (3)
fire *1, (2)
flour *1, (2)
general *3, (2)
he *0, (1)                #B
hear *1, (2)
here *1, (2)
hour *1, (2)
I *0, (1)                 #B
idea *2, (3)
lately *3, (2)
library *3, (2)
lion *1, (2)
little *1, (2)            #A
lonely *3, (2)
male *1, (2)
me *0, (1)                #B
meal *1, (2)
middle *1, (2)            #A
near *1, (2)
needle *1, (2)            #A
noble *1, (2)             #A
oil *1, (2)
our *1, (2)
people *1, (2)            #A
period *2, (3)
piano *2, (3)
pleased *2, (1)
police *2, (1)
possible *2, (3)
quiet *1, (2)
radio *2, (3)
real *1, (2)
restaurant *3, (2)
sail *1, (2)
science *1, (2)
several *3, (2)
she *0, (1)               #B
simple *1, (2)            #A
single *1, (2)            #A
smile *1, (2)
something *3, (2)
sometimes *4, (2)         #C
steal *1, (2)
stomach *2, (1)
suitable *2, (3)          #A
table *1, (2)             #A
terrible *2, (3)          #A
the *0, (1)               #B
therefore *3, (2)
title *1, (2)             #A
trouble *1, (2)           #A
uncle *1, (2)             #A
useful *3, (2)
we *0, (1)                #B
wheel *1, (2)
while *1, (2)
wild *1, (2)
wire *1, (2)
year *1, (2)
\$\endgroup\$
1
\$\begingroup\$

Mathematica, score 4560 (code) + 1128 (words) = 5688 (total)

""<>({#,",",ToString@Length[#~WordData~"Hyphenation"],"
"}&/@StringSplit@#)&

Anonymous function. Uses Mathematica's built-in WordData. For reference, here are the incorrect words (some of which I disagree with):

appear *2, (3)
beer *1, (2)
boil *1, (2)
chocolate *3, (2)
clear *1, (2)
colour *1, (2)
comfortable *4, (3)
deer *1, (2)
different *3, (2)
ear *1, (2)
fail *1, (2)
family *3, (2)
fear *1, (2)
feel *1, (2)
female *2, (3)
fire *1, (2)
flour *1, (2)
general *3, (2)
hear *1, (2)
here *1, (2)
hour *1, (2)
library *3, (2)
male *1, (2)
meal *1, (2)
near *1, (2)
oil *1, (2)
our *1, (2)
over *1, (2)
petrol *1, (2)
piano *2, (3)
police *2, (1)
really *3, (2)
restaurant *3, (2)
sail *1, (2)
several *3, (2)
smile *1, (2)
steal *1, (2)
stomach *2, (1)
tidy *1, (2)
usual *3, (2)
usually *4, (3)
vegetable *4, (3)
wheel *1, (2)
while *1, (2)
wild *1, (2)
wire *1, (2)
year *1, (2)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.