Skip to content

Instantly share code, notes, and snippets.

@hden
Created January 29, 2014 04:44
Show Gist options
  • Select an option

  • Save hden/8681970 to your computer and use it in GitHub Desktop.

Select an option

Save hden/8681970 to your computer and use it in GitHub Desktop.
HuffPost-style Title Generator
'use strict'
_ = require 'underscore'
class TitleGenerator
n: =>
'' + _.random(1, 10) + '間'
getTitle: =>
n = do @n
a = [
@adjectives
@area
]
a = do _.chain(a)
.shuffle()
.first()
.value()
b = [
@genre
@descriptor
@time
@contentArea
@age
]
b = do _.chain(b)
.shuffle()
.first()
.value()
"#{n}#{a}#{b}餐廳"
adjectives: =>
list = [
'熱門'
'火紅'
'吃到爆'
'經濟'
'實惠'
'優惠'
'省錢'
'高單價'
'高格調'
'難訂到位'
'排隊'
'無雷'
'胖'
'肥'
'浪漫'
'方便'
]
'最' + _.chain(list)
.shuffle()
.first()
.value() + '的'
genre: =>
list = [
'Buffet'
'牛排'
'鐵板燒'
'燒烤'
'火鍋'
'下午茶'
'素食'
]
_.chain(list)
.shuffle()
.first()
.value()
descriptor: =>
list = [
'米其林星級'
'食尚玩家推薦'
'網友推薦'
'網友票選'
]
_.chain(list)
.shuffle()
.first()
.value()
area: =>
list = [
'台北市'
'新北市'
'新竹'
'高雄'
'台南'
'台中'
]
_.chain(list)
.shuffle()
.first()
.value()
time: =>
list = [
'70 年代'
'80 年代'
'90 年代'
'新世代'
'新開幕'
]
_.chain(list)
.shuffle()
.first()
.value()
contentArea: =>
list = [
'英'
'法'
'德'
'美'
'日'
'俄'
'意'
'奧'
'無國籍'
]
_.chain(list)
.shuffle()
.first()
.value() + '式'
age: =>
list = [
'全年齡'
'長輩'
'小朋友'
'上班族'
'學生'
]
'適合' + _.chain(list)
.shuffle()
.first()
.value() + '的'
task 'gen', 'generate title', ->
d = new TitleGenerator()
console.log d.getTitle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment