Guest User

Untitled

a guest
Jun 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'zip'
  4. require 'nokogiri'
  5.  
  6. class Docx
  7. def self.word_count(file, zip=Zip::ZipFile.open(file))
  8. Nokogiri::XML.parse(zip.find_entry("word/document.xml").get_input_stream).text.split(" ").uniq.length
  9. end
  10. end
  11.  
  12. puts Docx.word_count("sample.docx")
Add Comment
Please, Sign In to add comment