Code Monkey home page Code Monkey logo

sentency's Introduction

sentency

PYPI Status Documentation Status

A small spaCy pipeline component for matching within document sentences using regular expressions.

Features

  • spaCy component for sentence-by-sentence pattern matching
  • Find matches with complex patterns using the power of regular expressions
  • Easily convert simple keywords into valid regular expressions
  • Specify matching patterns as well as patterns to ignore
  • Annotate matches for NER (Named Entity Recognition) tasks

Installation

pip install sentency

Usage

The following minimally complex example showcases the features of sentenCy.

import spacy
from spacy import displacy

from sentency.regex import regexize_keywords
from sentency.sentency import Sentex

text = """
Screening for abdominal aortic aneurysm.
Impression: There is evidence of a fusiform
abdominal aortic aneurysm measuring 3.4 cm.
"""
aaa_keywords = "abdominal aortic aneurysm"
ignore_keywords = "screening aneurysm"

keyword_regex = regexize_keywords(aaa_keywords)
ignore_regex = regexize_keywords(ignore_keywords)

nlp = spacy.load("en_core_web_sm")
nlp.add_pipe(
"sentex", config={
        "sentence_regex": keyword_regex,
        "ignore_regex": ignore_regex,
        "annotate_ents": True,
        "label": "AAA"
        }
)

doc = nlp(text)

displacy.render(doc, style="ent", options = {"ents": ["AAA"]})

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

sentency's People

Contributors

g-delong 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.