Giter Site home page Giter Site logo

anchorman's Introduction

Welcome to Anchorman

Latest Version https://travis-ci.org/rebeling/anchorman.svg?branch=master

Turn your text into [hypertext](http://en.wikipedia.org/wiki/Hypertext) and enrich the content. Anchorman finds terms in text and replaces them with another representation.

The replacement is rule-based. Each term is checked against the rules and will be applied if valid:

# How many items will be marked at all in the text.
replaces_at_all: 5

# Input term has to be exact match in text.
case_sensitive: true

Features

  • replacement rules
  • consider text units in the rules (e.g. paragraphs)
  • replace only n items of the same item
  • specify restricted_areas for linking by tag: a, img
  • sort elements by value before apply them
  • return applied elements

Usage

This shows a little example how to annotate elements in text:

>>> from anchorman import annotate
>>> text = 'The quick brown fox jumps over the lazy dog.'
>>> elements = [{'fox': {'value': '/wiki/fox', 'data-type': 'animal'}}]
>>> print annotate(text, elements)
'The quick brown <a href="/wiki/fox" data-type="animal">fox</a> jumps over the lazy dog.'

Installation

To install Anchorman, simply:

pip install anchorman

Credits and contributions

We published this at github and pypi to provide our solution to you. Pleased for feedback and contributions.

Thanks [@tarnacious](https://github.com/tarnacious) for inspiration and first steps.

Todo

  • check if position exist in input and save extra processing
  • html.parser vs lxml in bs4 - benchmarks and drawbacks

<img src="https://raw.githubusercontent.com/rebeling/anchorman/master/docs/anchorman.png" width="200">

Stay tuned.

anchorman's People

Contributors

bitdeli-chef avatar rebeling avatar tarnacious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sahemmen doc22940

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.