Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #88 from sotetsuk/develop-v0.1.1
Browse files Browse the repository at this point in the history
[release] v0.1.1
  • Loading branch information
sotetsuk committed May 8, 2016
2 parents c2c154e + 6b13937 commit e4616c4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 42 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ $ goscholar -h

```go
// create Query and generate URL
q := Query{Keywords:"deep learning", Author:"y bengio"}
url = q.SearchUrl()
q := Query{Keywords:"nature 2015", Author:"y bengio", Title:"Deep learning"}
url := q.SearchUrl()

// fetch document sending the request to the URL
doc, err := goscholar.Fetch(url)
doc, err := Fetch(url)
if err != nil {
log.Error(err)
log.Error(err)
return
}

// parse articles
ch := make(chan *goscholar.Article, 10)
go goscholar.ParseDocument(ch, doc)

ch := make(chan *Article, 10)
go ParseDocument(ch, doc)
for a := range ch {
fmt.Println("---")
fmt.Println(a)
}
```
Expand Down
24 changes: 12 additions & 12 deletions article.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ import (

// Article stores the parsed results from Google Scholar.
type Article struct {
Title *Title
Year string
ClusterId string
NumCite string
NumVer string
InfoId string
Link *Link
Title *Title `json:"title"`
Year string `json:"year"`
ClusterId string `json:"cluster_id"`
NumCite string `json:"num_cite"`
NumVer string `json:"num_ver"`
InfoId string `json:"info_id"`
Link *Link `json:"link"`
}

// Title is an attribute of Article.
type Title struct {
Name string
Url string
Name string `json:"name"`
Url string `json:"url"`
}

// Link is an attribute of Article
type Link struct {
Name string
Url string
Format string
Name string `json:"name"`
Url string `json:"url"`
Format string `json:"format"`
}

// NewArticle creates an Article in which all entry is blank.
Expand Down
2 changes: 1 addition & 1 deletion article_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func ExampleString() {
func ExampleJson() {
fmt.Println(article.Json())
// Output:
// {"Title":{"Name":"Deep learning via Hessian-free optimization","Url":"http://machinelearning.wustl.edu/mlpapers/paper_files/icml2010_Martens10.pdf"},"Year":"2010","ClusterId":"15502119379559163003","NumCite":"260","NumVer":"9","InfoId":"e6RSJHGXItcJ","Link":{"Name":"wustl.edu","Url":"http://machinelearning.wustl.edu/mlpapers/paper_files/icml2010_Martens10.pdf","Format":"PDF"}}
// {"title":{"name":"Deep learning via Hessian-free optimization","url":"http://machinelearning.wustl.edu/mlpapers/paper_files/icml2010_Martens10.pdf"},"year":"2010","cluster_id":"15502119379559163003","num_cite":"260","num_ver":"9","info_id":"e6RSJHGXItcJ","link":{"name":"wustl.edu","url":"http://machinelearning.wustl.edu/mlpapers/paper_files/icml2010_Martens10.pdf","format":"PDF"}}
}

func TestIsValid(t *testing.T) {
Expand Down
30 changes: 8 additions & 22 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,38 +75,24 @@ func checkWithFirst(doc *goquery.Document, aExpected *Article) (err error) {
}

func Example() {
ch := make(chan *Article, 10)

// create Query and generate URL
q := Query{Keywords:"nature 2015", Author:"y bengio", Title:"Deep learning"}
url := q.SearchUrl()

// fetch document sending the request to the URL
doc, err := Fetch(url)
if err != nil {
log.Error(err)
return
}

// parse articles
ch := make(chan *Article, 10)
go ParseDocument(ch, doc)
a := <- ch
fmt.Println(a)
// Output:
/*[Title]
Name: Deep learning
Url: http://www.nature.com/nature/journal/v521/n7553/abs/nature14539.html
[Year]
2015
[ClusterId]
5362332738201102290
[NumCite]
390
[NumVer]
7
[InfoId]
0qfs6zbVakoJ
[Link]
Name: psu.edu
Url: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.436.894&rep=rep1&type=pdf
Format: PDF*/
for a := range ch {
fmt.Println("---")
fmt.Println(a)
}
}

func TestParseSelection(t *testing.T) {
Expand Down

0 comments on commit e4616c4

Please sign in to comment.