Coder Social home page Coder Social logo

webstruct's Introduction

Contact extraction library

This package contains a library for extracting contact information from HTML pages.

Supported functionality (so far)

  • American contact information extraction
  • Netherlands open hours extraction
  • Ireland open hours extraction
  • Ireland contact address extraction

Installation

Clone the repository, then install package requirements (package requires lxml, scikit-learn and python-wapiti):

$ pip install -r requirements.txt

then install package itself:

$ python setup.py install

Usage

>>> import wapiti
>>> from webstruct.wapiti import WapitiChunker
>>> from sklearn.externals import joblib

Load trained model ('wfe.joblib' and 'model.wapiti' files must exists):

>>> feature_encoder = joblib.load('wfe.joblib')
>>> wapiti_model = wapiti.Model(model='model.wapiti')
>>> ner = WapitiChunker(wapiti_model, feature_encoder)

Get a HTML page somewhere:

>>> import requests
>>> page = requests.get(some_url)

and extract information:

>>> for text, label in ner.transform(page.text, page.encoding):
...     if label != 'O':
...         print("%6s %s" % (label, text))
     TEL 800-4-Altman ( 425-8626 )
   EMAIL [email protected]
     ORG Altman Lighting Co. Inc.
  STREET 57 Alexander Street
    CITY Yonkers
   STATE NY
 ZIPCODE 10701
     TEL 1-800-4-ALTMAN ( 425-8626 )

Training

Model should be trained before usage. See '../notebooks/train-token-model.ipynb' IPython notebook for an example.

Unit Testing

Make sure nose is installed, then run runtests.sh script.

webstruct's People

Contributors

kmike avatar tpeng avatar shaneaevans avatar

Watchers

嘿哟传说 avatar

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.