Skip to content

Instantly share code, notes, and snippets.

@pressure679
Created September 19, 2019 14:31
Show Gist options
  • Save pressure679/5413d4b396c0c4f20ab28e893bb68b7f to your computer and use it in GitHub Desktop.
Save pressure679/5413d4b396c0c4f20ab28e893bb68b7f to your computer and use it in GitHub Desktop.
use the rake algorithm (rapid applicable keywords) on a txt file
package main
import (
// "io"
// "bufio"
// "strings"
// "strconv"
// "github.com/alixaxel/pagerank"
// "github.com/boltdb/bolt"
"fmt"
"io/ioutil"
"os"
"github.com/Obaied/RAKE.Go"
"flag"
)
func main() {
file := flag.String("file", "", "file with or without path variable.")
flag.Parse()
osFile, err := os.Open(*file)
if err != nil { panic(err) }
defer osFile.Close()
bytes, err := ioutil.ReadFile(osFile.Name())
if err != nil { panic(err) }
cands := rake.RunRake(string(bytes))
for _, cand := range cands {
fmt.Println(cand.Value, "-", cand.Key)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment