Make factory public and fix a bug

Factory can be used to construct pipelines.

Also only yield documents once.  Because the user can specify
profile_paths and doc_paths we have the possibility of
duplicates.