Ejemplo n.º 1
0
// Might be worth putting a defer in here incase a job breaks
// I.E to Clean up is processing
func Learn(s *session.Session) string {

	if s.SetLearning() {
		// New
		log.Println("Set up learning")
		status := http.GetStatus(s)
		s.SetLimits(int(status.Follows), int(status.Followed_by))
	}

	if !s.SetProcessing() {
		// Show we're still working
		return "    *"
	}

	switch s.GetLearningStep() {

	case utils.APPRAISE:
		jobs.MinePeople(s)
		return StatusBar(s, "Mining Followers")

	case utils.SCORN:
		jobs.MinePeople(s)
		return StatusBar(s, "Mining Following")

	case utils.BUILD:
		// Logistic Regression
		// Get records and run
		go jobs.LogisticRegression(s)
		s.IncrementStep()
		return "* Running Logistic Regression"

	case utils.GOODTAGS:
		go jobs.CrawlTags(s, true)
		return StatusBar(s, "Finding Good Tags")

	case utils.BADTAGS:
		go jobs.CrawlTags(s, false)
		return StatusBar(s, "Finding Bad Tags")

	case utils.COMPUTETAGS:
		go jobs.WeightTags(s)
		return "* Ranking Tags"

	case utils.SHARE:
		go s.Share()
		s.IncrementStep()
		s.StopProcessing()
		return "Sharing"
	}

	return "Stop"
}