Coder Social home page Coder Social logo

nagypeterjob / xtractor Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 1.0 9 KB

Topic extractor with the idea of generating labels using genism.n_similarity

License: MIT License

Python 100.00%
topic-extraction machine-learning genism python pandas labels

xtractor's Introduction

License: MIT CircleCI

       _                   _             
 __ __| |_  _ _  __ _  __ | |_  ___  _ _ 
 \ \ /|  _|| '_|/ _` |/ _||  _|/ _ \| '_|
 /_\_\ \__||_|  \__,_|\__| \__|\___/|_|  
                                         
xtractor
Topic extractor with the idea of generating labels using genism.n_similarity
by Peter Nagy

Overview

xtractor is little package which aims to label text automatically harnessing the power of pre-trained word vectors.
The idea is the following:

  • You must provide one or more genism compatible pre-trained word vectors
  • You must define categories with keywords
  • You must provide a tokenized text features you want to label
  • Run the extractor to label input text
  • The extractor digests the cosine distance of each word (vector) in the sentence and each keyword (vector)
  • Then it chooses the most "similar" category as label

Installation

$ pip install xtractor

Usage

See example.py for a more detailed example.

from xtractor import TopicExtractor as te
extractor = te.TopicExtractor(models=models, categories=categories)
labels = extractor.extract(pandas_data_frame)

Parameters

TopicExtractor(models=models, categories=categories)

models
  • list of genism compatible models
categories
  • list of categories Format:

extract(X=pandas_dataframe)

  • input pandas data frame or python list
  • in case X is a pandas dataframe, it must have only one column (the feature column)
  • X can be a regular python list
  • the features are expected to be tokenized string (e.g. following format: ['Tokenized', 'string'])
  • the return value is a regular list containing the category names (labels) for each input row respectively (e.g. in case of a 2 row input ['economy', 'sport'])

Precision

It really depends on the quality of you pre-trained word vector and on the quality of your intuitively defined category keywords. In my use case I have used these vectors and played with several iterations of keywords.
I have reached around 69% precision which is not bad. With more carefully picked keywords it can be enhanced.

F.A.Q.

  • Q: Why did you make this? A: Because I looked for a way to automatically label huge amount of (hungarian) text and I found no simple way.

Author

xtractor's People

Contributors

nagypeterjob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

hari4om

xtractor's Issues

Load bin files

I would like to ask about the bins that we can load into the Word2Vec and which is their source for downloading?
Thanks in advance,

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.