<commit_before>package main

import (
  "os"
  "github.com/gin-gonic/gin"
  "bufio"
  "math/rand"
  "time"
)

// Set numWords constant
const numWords int = 5000

func check(e error) {
  if e != nil {
    panic(e)
  }
}

func randChoice(arr [numWords]string) (string) {
  rand.Seed(time.Now().Unix())
  idx := rand.Intn(len(arr))
  return arr[idx]
}

func main() {
  // Create gin router
  r := gin.Default()

  // Create word array
  var words [numWords]string

  // Read from 5000-common-words.txt
  f, err := os.Open("5000-common-words.txt")
  check(err)
  scanner := bufio.NewScanner(f)
  scanner.Split(bufio.ScanLines)

  // Fetch words
  for i := 0; i < numWords; i++ {
    scanner.Scan()
    words[i] = scanner.Text()
  }

  /* Begin routes */

  // Index
  r.GET("/", func(c *gin.Context) {
    c.String(200, "index")
  })

  // Random word
  r.GET("/randword", func(c *gin.Context) {
    myWord := randChoice(words)
    c.String(200, myWord)
  })

  /* End routes */

  // Run server
  port := os.Getenv("PORT")
  if port == "" {
    port = "8000"
  }
  r.Run(":" + port)
}<commit_msg>Add randwords path for fetching multiple words<commit_after>package main

import (
  "os"
  "github.com/gin-gonic/gin"
  "bufio"
  "math/rand"
  "strconv"
)

// Set numWords constant
const numWords int = 5000

func check(e error) {
  if e != nil {
    panic(e)
  }
}

func randChoice(arr [numWords]string) (string) {
  idx := rand.Intn(len(arr))
  return arr[idx]
}

func main() {
  // Create gin router
  r := gin.Default()

  // Create word array
  var words [numWords]string

  // Read from 5000-common-words.txt
  f, err := os.Open("5000-common-words.txt")
  check(err)
  scanner := bufio.NewScanner(f)
  scanner.Split(bufio.ScanLines)

  // Fetch words
  for i := 0; i < numWords; i++ {
    scanner.Scan()
    words[i] = scanner.Text()
  }

  /* Begin routes */

  // Index
  r.GET("/", func(c *gin.Context) {
    c.String(200, "index")
  })

  // Random word
  r.GET("/randword", func(c *gin.Context) {
    myWord := randChoice(words)
    c.String(200, myWord)
  })

  // Random words
  r.GET("/randwords", func(c *gin.Context) {
    num, err := strconv.Atoi(c.DefaultQuery("num", "4"))
    if err != nil {
      c.String(500, "Atoi failed")
    } else if num < 0 {
      c.String(500, "Invalid input")
    } else {
      // Dynamic array allocation
      var myWords []string
      myWords = make([]string, num)
      for i, _ := range myWords {
        myWords[i] = randChoice(words)
      }
      c.JSON(200, gin.H{"words": myWords})
    }
  })

  /* End routes */

  // Run server
  port := os.Getenv("PORT")
  if port == "" {
    port = "8000"
  }
  r.Run(":" + port)
}
{'fraction_non_alphanumeric': 0.1747100635989525, 'fraction_numerical': 0.02132435465768799, 'mean_word_length': 2.523056653491436, 'pattern_counts': {'":': 3, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5403850', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1011, 'n_words': 234}