Coder Social home page Coder Social logo

mayank-02 / vector-space-model Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 2.0 11 KB

Implementation of Vector Space Model using TF-IDF and Cosine Similarity

License: MIT License

Python 100.00%
cosine-similarity tf-idf information-retrieval vector-space-model ranked-retrieval python

vector-space-model's Introduction

Vector Space Model

The program vsm.py implements a toy search engine to illustrate the vector space model using TF-IDF for documents.

The program asks you to enter a search query, and then returns all documents from the corpus matching the query, in decreasing order of cosine similarity, according to the vector space model.

The document corpus consists of just four documents, which are product descriptions of popular books, taken from amazon.com.

Getting Started

  • Install Python 3.6+
  • Install all pip requirements from the requirements.txt:
$ python3 -m pip install -r requirements.txt
  • To download stopwords used for the model, open your terminal or command prompt and enter following commands:
$ python3
>>> import nltk
>>> nltk.download('stopwords')

Usage

$ python3 vsm.py
Search query >> lord of the ring
------------------------------------------
| Score | Document                       |
------------------------------------------
| 0.731 | corpus/lotr.txt                |
| 0.118 | corpus/the_hobbit.txt          |
------------------------------------------

Queries

It supports free-form queries

Corpus

You can point CORPUS in vsm.py to your own corpus to use vector space model on it.

Authors

Mayank Jain

License

MIT

vector-space-model's People

Contributors

mayank-02 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

imannrhman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.