Skip to content

Commit

Permalink
add url portrait
Browse files Browse the repository at this point in the history
  • Loading branch information
paul committed Mar 15, 2017
1 parent 863e501 commit 23c6558
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Binary file added female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions url_portrait.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
library(jiebaR)
library(wordcloud2)

#文件路径
readChineseWords<-function(path){
rawstring = readLines(path)
rawstring = paste0(rawstring,collapse = ' ')
s <- gsub('\\w','',rawstring,perl = T)
s <- gsub('[[:punct:]]',' ',s)
return(s)
}

#url
male_link <- 'https://s.taobao.com/search?q=男'
female_link <- 'https://s.taobao.com/search?q=女'

male_str <- readChineseWords(male_link)
female_str <- readChineseWords(female_link)

#分词
cc <- worker()
new_user_word(cc,'打底裤','n')
male_words <- cc[male_str]
female_words <- cc[female_str]

male_df <- freq(male_words)
wordcloud2(male_df,figPath = 'male.png',backgroundColor = 'black',color = 'random-light')

female_df <- freq(female_words)
wordcloud2(female_df,figPath = 'female.png',backgroundColor = 'black',color = 'random-light')

0 comments on commit 23c6558

Please sign in to comment.