Giter Site home page Giter Site logo

binarymax / hearst_patterns_python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mmichelsonif/hearst_patterns_python

0.0 2.0 0.0 13 KB

This is an implementation of Hearst patterns, for finding hyponyms, written in Python.

License: Apache License 2.0

Python 100.00%

hearst_patterns_python's Introduction

An implementation of Hearst patterns for hyponyms in Python. [1] Now, extended to include more patterns from [2]!

By default, the library does not use the extended patterns (so it behaves like "classic" Hearst patterns). If you do want to use the extended pattern set, you initialize the constructor and set the extended paramter to True

h = HearstPatterns(extended = True)

I couldn't find a version in Python, so I wrote and released this one.

The core API call is find_hyponyms(text) which will process the text and return the hyponyms in a list of tuples, of the form (specific-term, general-term)

It could certainly be optimized further for speed, etc. but I hope this release is useful to the community in general.

Note that Hearst patterns rely on Noun Phrases, so we build our own simple chunker, and therefore leverage NLTK in order to do the Part-of-Speech tagging. Therefore, there is a requirement on nltk (see requirements.txt)

Installation:

pip install hearstPatterns

Installation notes:

Some users report needing to install specific components of NLTK after the inital install. Specifically, you might need to:

$ python
>>> import nltk
>> nltk.download('punkt')
>> nltk.download('averaged_perceptron_tagger')

Testing:

python -m unittest discover

ToDo:

  • Speed it up
  • Add lemmatization or stemming so that we are only outputting singular NPs
  • NLTK pos-tags sometimes lead to issues, and chunker could certainly be improved

==== References:

[1] Hearst, M. A. "Automatic acquisition of hyponyms from large text corpora." Proceedings of the 14th conference on Computational linguistics-Volume 2. Association for Computational Linguistics, 1992.

[2] Seitner, J., Bizer, C., Eckert, K., Faralli, S., Meusel, R., Paulheim, H., & Ponzetto, S. "A large database of hypernymy relations extracted from the web." Proceedings of the 10th edition of the Language Resources and Evaluation Conference, 2016.

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.