-
Notifications
You must be signed in to change notification settings - Fork 5
/
pipelines.go
50 lines (35 loc) · 1.41 KB
/
pipelines.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Example pipeline and workflow functionality.
//
// Uses files from txtai unit tests: https://github.com/neuml/txtai/releases/download/v2.0.0/tests.tar.gz
package main
import (
"fmt"
"github.com/neuml/txtai.go"
)
func main() {
service := "http://localhost:8000"
segment := txtai.Segmentation(service)
sentences := "This is a test. And another test."
fmt.Println("---- Segmented Text ----")
fmt.Println(segment.Segment(sentences))
textractor := txtai.Textractor(service)
text := textractor.Textract("/tmp/txtai/article.pdf");
fmt.Println("\n---- Extracted Text ----")
fmt.Println(text)
summary := txtai.Summary(service)
summarytext := summary.Summary(text.(string), -1, -1)
fmt.Println("\n---- Summary Text ----")
fmt.Println(summarytext)
translate := txtai.Translation(service)
translation := translate.Translate(summarytext, "es", "")
fmt.Println("\n---- Summary Text in Spanish ----")
fmt.Println(translation)
workflow := txtai.Workflow(service)
output := workflow.Workflow("sumspanish", []string {"file:///tmp/txtai/article.pdf"})
fmt.Println("\n---- Workflow [Extract Text->Summarize->Translate] ----")
fmt.Println(output)
transcribe := txtai.Transcription(service)
transcription := transcribe.Transcribe("/tmp/txtai/Make_huge_profits.wav")
fmt.Println("\n---- Transcribed Text ----")
fmt.Println(transcription)
}