Skip to content

Commit

Permalink
support plain text extract
Browse files Browse the repository at this point in the history
  • Loading branch information
Miachol committed Apr 23, 2020
1 parent 99e93fe commit eea7f7c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
18 changes: 11 additions & 7 deletions cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func simpleExtr(cmd *cobra.Command, args []string) {
defer wg.Done()
sem <- struct{}{}
defer func() { <-sem }()
defer fmt.Println(string(parseJSON(stdin)))
defer fmt.Println(string(*parseJSON(stdin)))
}()
RootClis.HelpFlags = false
}
Expand All @@ -70,15 +70,15 @@ func simpleExtr(cmd *cobra.Command, args []string) {
log.Warnln(err)
return
}
defer fmt.Println(string(parseJSON(input)))
defer fmt.Println(string(*parseJSON(input)))
}(v)
}
RootClis.HelpFlags = false
}
wg.Wait()
}

func parseJSON(dat []byte) []byte {
func parseJSON(dat []byte) *[]byte {
var sraFields []*extract.SraFields
var pubMedFields []*extract.PubmedFields
var lock sync.Mutex
Expand All @@ -92,7 +92,7 @@ func parseJSON(dat []byte) []byte {
lock.Unlock()
}
dat, _ := json.MarshalIndent(pubMedFields, "", " ")
return dat
return &dat
} else if RootClis.Mode == "sra" && len(dat) > 0 {
json.Unmarshal(dat, &sraJSON)
done := make(map[string]int)
Expand All @@ -103,13 +103,17 @@ func parseJSON(dat []byte) []byte {
lock.Unlock()
}
dat, _ := json.MarshalIndent(sraFields, "", " ")
return dat
return &dat
} else if len(dat) > 0 {
obj, _ := extract.GetPlainFields("", &dat, &keyWords, RootClis.CallCor)
dat, _ := json.MarshalIndent(obj, "", " ")
return &dat
}
return []byte{}
return nil
}

func init() {
RootCmd.Flags().StringVarP(&RootClis.Keywords, "keywords", "w", "algorithm, tool, model, pipleline, method, database, workflow, dataset, bioinformatics, sequencing, http, github.com, gitlab.com, bitbucket.org", "Keywords to extracted from abstract.")
RootCmd.Flags().BoolVarP(&RootClis.CallCor, "call-cor", "", false, "Wheather to calculate the corelated keywords, and return the sentence contains >=2 keywords.")
RootCmd.Flags().StringVarP(&RootClis.Mode, "mode", "", "", "mode to extract information (pubmed, sra).")
RootCmd.Flags().StringVarP(&RootClis.Mode, "mode", "", "", "mode to extract information: plain,pubmed, or sra.")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/openbiox/ligo v0.0.0-20200423121108-3cfa60ff813d
github.com/openbiox/ligo v0.0.0-20200423134214-6abf93e36b96
github.com/sirupsen/logrus v1.5.0
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
13 changes: 11 additions & 2 deletions pdf2plain/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ require (
code.sajari.com/docconv v1.1.0
github.com/JalfResi/justext v0.0.0-20170829062021-c0282dea7198 // indirect
github.com/advancedlogic/GoOse v0.0.0-20191112112754-e742535969c1 // indirect
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 // indirect
github.com/go-resty/resty/v2 v2.2.0 // indirect
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 // indirect
github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 // indirect
github.com/openbiox/ligo v0.0.0-20200324043626-a1096f60db64
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/olekukonko/tablewriter v0.0.4 // indirect
github.com/openbiox/ligo v0.0.0-20200423121108-3cfa60ff813d
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.5.0
github.com/spf13/cobra v0.0.6
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/vbauerster/mpb/v4 v4.11.2 // indirect
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd // indirect
)

0 comments on commit eea7f7c

Please sign in to comment.