-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbustrofedon.go
42 lines (32 loc) · 936 Bytes
/
bustrofedon.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"fmt"
"github.com/yaderv/bustrofedon/corpus"
"github.com/yaderv/bustrofedon/poem"
)
// Strip trailing whitespace and comments
var OUTPUTFILE = "corpus.json"
func CreateJSON(inputFile string) {
versesNumber, haikusString := corpus.CreateCorpusFromFile(inputFile, OUTPUTFILE)
fmt.Printf("verses: %d\n", versesNumber)
fmt.Printf("%s Haikus Found\n", haikusString)
}
func main() {
source := flag.String("source", "", "The input file to build the haikus source")
poemType := flag.String("type", "haiku", "Poem type: haiku | quartet")
flag.Parse()
if *source != "" {
fmt.Printf("Reading from: %s", *source)
CreateJSON(*source)
}
if *poemType == "haiku" {
haiku := poem.CreateHaiku(OUTPUTFILE)
fmt.Println(haiku)
} else if *poemType == "quartet" {
haiku := poem.CreateQuartet(OUTPUTFILE)
fmt.Println(haiku)
} else {
fmt.Println("Type option should be haiku or quartet")
}
}