Skip to content

khoaipx/Document-Similarity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Context-based similar documents


1. Introduction

In this repository, I implemented Context-based similar documents according to Rich Anchor's blog

Context-based similar documents is a problem that finding the most similar documents of the given document. The blog's approach is using LDA (Latent Dirichlet Allocation) Model to build the generic topics of the documents in database, then vectorize them, and using LSH (Locality Sensitive Hashing) to find the most similar documents (nearest neighbors) of the given document.

This software is written by Python 2.x with LDA Model provided by gensim and LSHForest provided by scikit-learn

2. Installation

This software depends on NumPy, Scikit-learn, Gensim - Python packages for scientific computing. You must have them installed prior to using vnSRL.

The simple way to install them is using pip:

	# pip install -U numpy scikit-learn gensim

3. Usage

3.1 Data

This software requires 2 data files for training:

  • Input data file includes documents in database. Each document is written on each line.
  • Stop words file includes stop words which are are filtered out before processing data.

And for query, we need 1 file stored given documents.

To run demo, can download sample input files. Those are extracted from eva.vn provided by Rich Anchor Team:

3.2 Quick-start

You can use this software by the following command-line:

python main.py

You can modify source code to fit your data:

  • main.py:
    • input_file: path to input data file
    • stopwords_file: path to stop words file
    • num_topics: number of topics in LDA Model
    • prefix_name: prefix name of saved files (dictionary, corpus, model, etc.)
    • directory: path to saved data directory
    • query: path to query file
  • setting.py: stores default setting
  • corpus.py:
    • get_docs(): modify to fit data format

4. References

5. Contact

Xuan-Khoai Pham phamxuankhoai@gmail.com

Releases

No releases published

Packages

No packages published

Languages