semvec/pypi-packages huggingface dataset:
spacy-pattern-builder 0.0.7
Reverse engineer patterns for use with the SpaCy DependencyTreeMatcher
License: MIT
Keywords: spacy-pattern-builder

# SpaCy Pattern Builder

Use training examples to build and refine patterns for use with SpaCy's DependencyMatcher.

## Motivation

Generating patterns programmatically from training data is more efficient than creating them manually.

## Installation

With pip:

```bash
pip install spacy-pattern-builder
```

## Usage

```python
# Import a SpaCy model, parse a string to create a Doc object
import en_core_web_sm

text = 'We introduce efficient methods for fitting Boolean models to molecular data.'
nlp = en_core_web_sm.load()
doc = nlp(text)

from spacy_pattern_builder import build_dependency_pattern

# Provide a list of tokens we want to match.
match_tokens = [doc[i] for i in [0, 1, 3]]  # [We, introduce, methods]

''' Note that these tokens must be fully connected. That is,
all tokens must have a path to all other tokens in the list,
without needing to traverse tokens outside of the list.
Otherwise, spacy-pattern-builder will raise a TokensNotFullyConnectedError.
You can get a connected set that includes your tokens with the following: '''
from spacy_pattern_builder import util
connected_tokens = util.smallest_connected_subgraph(match_tokens, doc)
assert match_tokens == connected_tokens  # In this case, the tokens we provided are already fully connected

# Specify the token attributes / features to use
feature_dict = {  # This is equal to the default feature_dict
    'DEP': 'dep_',
    'TAG': 'tag_'
}

# Build the pattern
pattern = build_dependency_pattern(doc, match_tokens, feature_dict=feature_dict)

from pprint import pprint
pprint(pattern)  # In the format consumed by SpaCy's DependencyMatcher:
'''
[{'PATTERN': {'DEP': 'ROOT', 'TAG': 'VBP'}, 'SPEC': {'NODE_NAME': 'node1'}},
 {'PATTERN': {'DEP': 'nsubj', 'TAG': 'PRP'},
  'SPEC': {'NBOR_NAME': 'node1', 'NBOR_RELOP': '>', 'NODE_NAME': 'node0'}},
 {'PATTERN': {'DEP': 'dobj', 'TAG': 'NNS'},
  'SPEC': {'NBOR_NAME': 'node1', 'NBOR_RELOP': '>', 'NODE_NAME': 'node3'}}]
'''

# Create a matcher and add the newly generated pattern
from spacy.matcher import DependencyMatcher

matcher = DependencyTreeMatcher(doc.vocab)
matcher.add('pattern', None, pattern)

# And get matches
matches = matcher(doc)
for match_id, token_idxs in matches:
    tokens = [doc[i] for i in token_idxs]
    tokens = sorted(tokens, key=lambda w: w.i)  # Make sure tokens are in their original order
    print(tokens)  # [We, introduce, methods]

```

## Acknowledgements

Uses:

- [SpaCy](https://spacy.io)
- [networkx](https://github.com/networkx/networkx)
ignorio 0.2.4
Manage your .gitignore with ease!
License: MIT
Requires Python: >=3.4,<4.0
Keywords: git,gitignore,exclusion,vcs

# Ignorio
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ignorio.svg) ![PyPI](https://img.shields.io/pypi/v/ignorio.svg) [![Build Status](https://travis-ci.org/franccesco/ignorio.svg?branch=master)](https://travis-ci.org/franccesco/ignorio) [![Coverage Status](https://coveralls.io/repos/github/franccesco/ignorio/badge.svg?branch=master)](https://coveralls.io/github/franccesco/ignorio?branch=master) ![GitHub](https://img.shields.io/github/license/franccesco/ignorio.svg) [![Twitter](https://img.shields.io/twitter/url/https/github.com/franccesco/ignorio.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Ffranccesco%2Fignorio)

**Ignorio** is a simple package to manage your [git exclusions](https://git-scm.com/docs/gitignore). This command line application helps you to download a template from [gitignore.io](http://gitignore.io/) without going to the site using the site's [API](https://www.gitignore.io/api/) 

# Usage

## Add a language exclusion list
* You can add multiple languages to the exclusions list, just make sure they're listed on the supported list.

![](assets/add_lang.png)

## Append a language to the exclusion list
* You don't have to overwrite your current exclusion list, if you have added Python and SublimeText before then you can go right ahead and append Ruby to it.

![](assets/append_lang.png)

## Show supported languages
* Supported list of languages by gitignore.io, you can easily grep this data if you need to find a determined language.

![](assets/show_supported.png)

## Verbose for the paranoids
* And if you're paranoid enough or just like to see more data displayed on your terminal, well, check the `-v` flag.

![](assets/verbosity.png)

# How to contribute
* Fork it
* Make changes
* Make a pull request to the **develop** branch.

# Like the project?
If you like the project and would like to chip in a dolar or two, go ahead and do it here.

<a href="https://www.paypal.me/orozcofranccesco">
  <img height="32" src="assets/paypal_badge.png" />
</a> <a href="https://www.buymeacoffee.com/franccesco" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/white_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a> <a href='https://ko-fi.com/V7V8AXFE' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi2.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>