The following command (minimally-tested) will collect all of the words in the buffer and display the unique ones (ignoring case) in a new buffer.
(defun show-unique-words (&optional alphabetical)
"Collect all of the unique words in the current buffer and
display them in a new buffer. With prefix, alphabetize the
list."
(interactive "P")
(let ((buf (buffer-name))
(new (get-buffer-create "*Unique Words*"))
(txt (delete-dups (mapcar #'downcase
(split-string (buffer-string)
nil nil
"[^[:alnum:]]+")))))
(with-current-buffer new
(delete-region (point-min) (point-max))
(insert (format "%d unique words in the <%s> buffer:\n\n"
(length txt) buf))
(cl-dolist (word (if alphabetical (sort txt #'string<) txt))
(insert (concat word "\n"))))
(pop-to-buffer new)))
query-replace
to replace spaces with newlines and thendelete-duplicate-lines
. I am assuming that this document is just a list of words. Because if the document has proper meaningful sentences, they will get butchered. – Kaushal Modi Aug 2 '15 at 13:53