Пример #1
0
func main() {
	godotenv.Load()
	var syllabi = rhyme.ConstructSyllabi(&[]string{"../rhyme/cmudict-0.7b", "../rhyme/cmudict-0.7b_my_additions"})

	uuid := "b57fee24-cb3c-11e5-be0b-b7ece4e953a0"
	meter := "1010101010"

	aws := GetArticleWithSentencesAndMeter(uuid, meter, syllabi)
	fmt.Println("main: article.Title=", aws.Title)
	fmt.Println("main: body=", aws.Body)

	fmt.Println("main: num Sentences=", len(*(aws.Sentences)), "num MatchedPhrases=", len(*(aws.MatchedPhrases)))

	for _, mp := range *(aws.MatchedPhrases) {
		fmt.Println("main: mp.MatchesOnMeter.During=", mp.MatchesOnMeter.During)
	}
}
Пример #2
0
	"github.com/railsagainstignorance/alignment/article"
	"github.com/railsagainstignorance/alignment/ontology"
	"github.com/railsagainstignorance/alignment/rhyme"
	"github.com/railsagainstignorance/alignment/rss"
	"html/template"
	"net/http"
	"os"
	"regexp"
	"strconv"
)

// compile all templates and cache them
var templates = template.Must(template.ParseGlob("templates/*"))

// construct the syllable monster
var syllabi = rhyme.ConstructSyllabi(&[]string{"rhyme/cmudict-0.7b", "rhyme/cmudict-0.7b_my_additions"})

func templateExecuter(w http.ResponseWriter, pageName string, data interface{}) {
	err := templates.ExecuteTemplate(w, pageName, data)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
}

func alignFormHandler(w http.ResponseWriter, r *http.Request) {
	templateExecuter(w, "alignPage", nil)
}

func alignHandler(w http.ResponseWriter, r *http.Request) {
	p := align.Search(r.FormValue("text"), r.FormValue("source"))