-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
26 changed files
with
2,204 additions
and
23 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 |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
*.so | ||
*.dylib | ||
|
||
bin | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 +1,7 @@ | ||
# library | ||
A unified (and indexed) library of Vale-related resources. | ||
# lois | ||
|
||
LOIS (or Line-Oriented Information System) provides an advanced, structured understanding of free-form notes and other unstructured documents. | ||
|
||
``` | ||
go build -ldflags="-s -w" -o bin/engine cmd/engine/main.go | ||
``` |
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,192 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/errata-ai/library/internal/nlp" | ||
"github.com/errata-ai/library/pkg/data" | ||
"github.com/errata-ai/library/pkg/search" | ||
"github.com/go-resty/resty/v2" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func printJSON(t interface{}) error { | ||
b, err := json.MarshalIndent(t, "", " ") | ||
if err != nil { | ||
fmt.Println("{}") | ||
return err | ||
} | ||
fmt.Println(string(b)) | ||
return nil | ||
} | ||
|
||
func main() { | ||
app := &cli.App{ | ||
Name: "lois", | ||
Usage: "A local, offline search engine", | ||
Commands: []*cli.Command{ | ||
{ | ||
Name: "read", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 argument required") | ||
} | ||
|
||
src, err := data.FromLinkList(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = search.NewEngineFromData(args[1], src) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "create", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 argument required") | ||
} | ||
|
||
src, err := data.FromMapping(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = search.NewEngineFromData(args[1], src) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "search", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 arguments required") | ||
} | ||
|
||
engine, err := search.LoadEngine(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
results, err := engine.Search(args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return printJSON(results) | ||
}, | ||
}, | ||
{ | ||
Name: "lookup", | ||
Usage: "Finds the context for a given result ID", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 arguments required") | ||
} | ||
|
||
m, err := data.ParseMap(args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
context, err := data.Context(args[0], m.Path) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(context) | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "parse", | ||
Usage: "", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 arguments required") | ||
} | ||
|
||
m, err := data.ParseMap(args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
context, err := data.Context(args[0], m.Path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tokens, err := nlp.TextToTokens(context) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return printJSON(tokens) | ||
}, | ||
}, | ||
{ | ||
Name: "post", | ||
Usage: "", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 arguments required") | ||
} | ||
client := resty.New() | ||
|
||
resp, err := client.R(). | ||
SetHeader("Content-Type", "application/x-www-form-urlencoded"). | ||
SetQueryParam("text", args[1]). | ||
Post(args[0]) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(resp) | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "fsm", | ||
Usage: "", | ||
Action: func(c *cli.Context) error { | ||
args := c.Args().Slice() | ||
if len(args) != 2 { | ||
return errors.New("2 arguments required") | ||
} | ||
|
||
out, err := nlp.DoSectionize(args[0], args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return printJSON(out) | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
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 @@ | ||
module github.com/errata-ai/library | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/GolangNLP/split v0.1.0 | ||
github.com/advancedlogic/GoOse v0.0.0-20210820140952-9d5822d4a625 | ||
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de | ||
github.com/blevesearch/bleve/v2 v2.1.0 | ||
github.com/go-resty/resty/v2 v2.6.0 | ||
github.com/sirikothe/gotextfsm v1.0.0 | ||
github.com/urfave/cli/v2 v2.3.0 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
require ( | ||
github.com/PuerkitoBio/goquery v1.4.1 // indirect | ||
github.com/RoaringBitmap/roaring v0.7.3 // indirect | ||
github.com/andybalholm/cascadia v1.0.0 // indirect | ||
github.com/bits-and-blooms/bitset v1.2.0 // indirect | ||
github.com/blevesearch/bleve_index_api v1.0.1 // indirect | ||
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect | ||
github.com/blevesearch/mmap-go v1.0.2 // indirect | ||
github.com/blevesearch/scorch_segment_api/v2 v2.0.1 // indirect | ||
github.com/blevesearch/segment v0.9.0 // indirect | ||
github.com/blevesearch/snowballstem v0.9.0 // indirect | ||
github.com/blevesearch/upsidedown_store_api v1.0.1 // indirect | ||
github.com/blevesearch/vellum v1.0.5 // indirect | ||
github.com/blevesearch/zapx/v11 v11.2.2 // indirect | ||
github.com/blevesearch/zapx/v12 v12.2.2 // indirect | ||
github.com/blevesearch/zapx/v13 v13.2.2 // indirect | ||
github.com/blevesearch/zapx/v14 v14.2.2 // indirect | ||
github.com/blevesearch/zapx/v15 v15.2.2 // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect | ||
github.com/fatih/set v0.2.1 // indirect | ||
github.com/gigawattio/window v0.0.0-20180317192513-0f5467e35573 // indirect | ||
github.com/golang/protobuf v1.3.2 // indirect | ||
github.com/golang/snappy v0.0.1 // indirect | ||
github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mattn/go-runewidth v0.0.13 // indirect | ||
github.com/mschoch/smat v0.2.0 // indirect | ||
github.com/neurosnap/sentences v1.0.6 // indirect | ||
github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84 // indirect | ||
github.com/pkg/errors v0.8.1 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.0.1 // indirect | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect | ||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect | ||
github.com/steveyen/gtreap v0.1.0 // indirect | ||
go.etcd.io/bbolt v1.3.5 // indirect | ||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect | ||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
) |
Oops, something went wrong.