moved the project to this repository
This commit is contained in:
+137
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ERROR",
|
||||
"evalue": "repl.go:6:5: error loading package \"dataframe\" metadata, maybe you need to download (go get), compile (go build) and install (go install) it? can't find import: \"dataframe\"",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"repl.go:6:5: error loading package \"dataframe\" metadata, maybe you need to download (go get), compile (go build) and install (go install) it? can't find import: \"dataframe\""
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import (\n",
|
||||
" \"io/ioutil\"\n",
|
||||
" \"fmt\"\n",
|
||||
" \"strings\"\n",
|
||||
" \"strconv\"\n",
|
||||
" \"dataframe\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"const kitchenReviews = \"./datasets/words/processed_acl/kitchen\"\n",
|
||||
"\n",
|
||||
"type Pair struct {\n",
|
||||
" Phrase string\n",
|
||||
" Frequency int\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"func pairsAndFilters(splitPairs []string) ([]Pair, map[string]bool) {\n",
|
||||
" var (\n",
|
||||
" pairs []Pair\n",
|
||||
" m map[string]bool\n",
|
||||
" )\n",
|
||||
" m = make(map[string]bool)\n",
|
||||
" for _, pair := range splitPairs{\n",
|
||||
" p := strings.Split(pair, \":\")\n",
|
||||
" phrase := p[0]\n",
|
||||
" m[phrase] = true\n",
|
||||
" if len(p) < 2 {\n",
|
||||
" continue\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" freq, err := strconv.Atoi(p[1])\n",
|
||||
" if err != nil {\n",
|
||||
" fmt.Println(\"Fuck \", err)\n",
|
||||
" }\n",
|
||||
" pairs = append(pairs, Pair{\n",
|
||||
" Phrase: phrase, \n",
|
||||
" Frequency: freq,\n",
|
||||
" })\n",
|
||||
" }\n",
|
||||
" return pairs, m\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"func exclude(pairs []Pair, exclusions map[string]bool) []Pair {\n",
|
||||
" var ret []Pair\n",
|
||||
" for _, pair := range pairs{\n",
|
||||
" if !exclusions[pair.Phrase] {\n",
|
||||
" ret = append(ret, pair)\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" return ret\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ERROR",
|
||||
"evalue": "repl.go:21:10: undefined \"dataframe\" in dataframe.LoadStructs <*ast.SelectorExpr>",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"repl.go:21:10: undefined \"dataframe\" in dataframe.LoadStructs <*ast.SelectorExpr>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"positives, err := ioutil.ReadFile(kitchenReviews + \"/positive.review\")\n",
|
||||
"if err != nil {\n",
|
||||
" fmt.Println(\"could not read positive reviews: \", err)\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"negatives, err := ioutil.ReadFile(kitchenReviews + \"/negative.review\")\n",
|
||||
"if err != nil {\n",
|
||||
" fmt.Println(\"could not read negative reviews: \", err)\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"pairsPositives := strings.Fields(string(positives))\n",
|
||||
"pairsNegatives := strings.Fields(string(negatives))\n",
|
||||
"\n",
|
||||
"parsedPositives, posPhrases := pairsAndFilters(pairsPositives)\n",
|
||||
"parsedNegatives, negPhrases := pairsAndFilters(pairsNegatives)\n",
|
||||
"parsedPositives = exclude(parsedPositives, negPhrases)\n",
|
||||
"parsedNegatives = exclude(parsedNegatives, posPhrases)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"dfPos := dataframe.LoadStructs(parsedPositives)\n",
|
||||
"dfNeg := dataframe.LoadStructs(parsedNegatives)\n",
|
||||
"\n",
|
||||
"fmt.Println(dfPos)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Go",
|
||||
"language": "go",
|
||||
"name": "gophernotes"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": "",
|
||||
"file_extension": ".go",
|
||||
"mimetype": "",
|
||||
"name": "go",
|
||||
"nbconvert_exporter": "",
|
||||
"pygments_lexer": "",
|
||||
"version": "go1.11.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user