-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
173 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
.idea/ | ||
.vscode/ | ||
*.json | ||
.env | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "NLP test", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "test", | ||
"program": "${workspaceFolder}/tokenize/nlp", | ||
"env": { | ||
"GOOGLE_NLP_CREDS_PATH": "${input:google_nlp_creds_path}" | ||
}, | ||
"args": [] | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"id": "google_nlp_creds_path", | ||
"description": "Google Natural Language API credentials path", | ||
"type": "promptString" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package assocentity | ||
|
||
import "testing" | ||
|
||
func TestAnalyses(t *testing.T) { | ||
type test struct{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package nlp | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"slices" | ||
"testing" | ||
|
||
"github.com/ndabAP/assocentity/v15/tokenize" | ||
) | ||
|
||
func TestTokenize(t *testing.T) { | ||
if testing.Short() { | ||
t.SkipNow() | ||
} | ||
|
||
var ( | ||
ctx = context.Background() | ||
creds = os.Getenv("GOOGLE_NLP_CREDS_PATH") | ||
|
||
text = "You can't win this one, Max." | ||
) | ||
|
||
t.Run("syntax", func(t *testing.T) { | ||
nlp := NewNLP(creds, AutoLang) | ||
analysis, err := nlp.Tokenize(ctx, text, tokenize.FeatureSyntax) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
var ( | ||
want = []string{ | ||
"You", "ca", "n't", "win", "this", "one", ",", "Max", ".", | ||
} | ||
got = make([]string, 0, len(want)) | ||
) | ||
for _, token := range analysis.Tokens { | ||
got = append(got, token.Text.Content) | ||
} | ||
|
||
if !slices.Equal[[]string, string](got, want) { | ||
t.Errorf("got %v, want %v", got, want) | ||
} | ||
}) | ||
|
||
t.Run("sentiment", func(t *testing.T) { | ||
nlp := NewNLP(creds, AutoLang) | ||
analysis, err := nlp.Tokenize(ctx, text, tokenize.FeatureSentiment) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if analysis.Sentiment == nil { | ||
t.Errorf("got %v", analysis.Sentiment) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package tokenize | ||
|
||
import v2 "cloud.google.com/go/language/apiv2/languagepb" | ||
|
||
type Sentiment = v2.Sentiment |
Oops, something went wrong.