Skip to content

Commit

Permalink
Merge pull request #7 from xwjdsh/master
Browse files Browse the repository at this point in the history
Show word's part of speech
  • Loading branch information
TimothyYe authored Mar 13, 2018
2 parents ec4aa7c + ed5e73f commit ff23fc1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,17 @@ func query(words []string, withVoice, withMore, isMulti bool) {
if isChinese {
// Find the result
fmt.Println()
doc.Find(".trans-container > ul > p > span.contentTitle").Each(func(i int, s *goquery.Selection) {
color.Green(" %s", s.Find(".search-js").Text())
doc.Find(".trans-container > ul > p").Each(func(i int, s *goquery.Selection) {
partOfSpeech := s.Children().Not(".contentTitle").Text()
if partOfSpeech != "" {
fmt.Printf("%14s ", color.MagentaString(partOfSpeech))
}

meanings := []string{}
s.Find(".contentTitle > .search-js").Each(func(ii int, ss *goquery.Selection) {
meanings = append(meanings, ss.Text())
})
fmt.Printf("%s\n", color.GreenString(strings.Join(meanings, "; ")))
})
} else {

Expand Down

0 comments on commit ff23fc1

Please sign in to comment.