Skip to main content

Installation from pip3

pip3 install --verbose phrase_detective 
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf
python -m spacy download de_dep_news_trf

Usage

Please refer to api docs

Detect noun phrases

import spacy
from spacy import Language
from phrase_detective import NounPhraseRecognizer, PKG_INDICES

@Language.factory("nprecog")
def create_np_parser(nlp: Language, name: str):
  return NounPhraseRecognizer(nlp) 

def noun_phrase(lang, sentence):
  nlp = spacy.load(PKG_INDICES[lang])
  nlp.add_pipe("nprecog")
  doc = nlp(sentence)
  for np in doc._.noun_phrases:
    print(np.text)

Detect verb phrases

import spacy
from spacy import Language
from phrase_detective import VerbKnowledgeRecognizer, PKG_INDICES

@Language.factory("vkbrecog")
def create_vkb_parser(nlp: Language, name: str):
  return VerbKnowledgeRecognizer(nlp) 

def verb_knowledge(lang, sentence):
  nlp = spacy.load(PKG_INDICES[lang])
  nlp.add_pipe("vkbrecog")
  doc = nlp(sentence)
  for v in doc._.verbs:
    print("TEXT: {}, TAG: {}, FORM: {}, ORIGNAL: {}".format(v.text, v.tag_, spacy.explain(v.tag_), v.lemma_))
  for pp in doc._.passive_phrases:
    print(pp.text)
  for vp in doc._.verb_phrases:
    print(vp)

Development

Clone project

git clone https://github.com/qishe-nlp/phrase-detective.git

Install poetry

Install dependencies

poetry update

Test and Issue

poetry run pytest -rP

which run tests under tests/*

Create sphinx docs

poetry shell
cd apidocs
sphinx-apidoc -f -o source ../phrase_detective
make html
python -m http.server -d build/html

Hose docs on github pages

cp -rf apidocs/build/html/* docs/

Build

  • Change version in pyproject.toml and phrase_detective/__init__.py
  • Build python package by poetry build

Git commit and push

Publish from local dev env

  • Set pypi test environment variables in poetry, refer to poetry doc
  • Publish to pypi test by poetry publish -r test

Publish through CI

git tag [x.x.x]
git push origin master

Release files for phrase-detective 0.1.35

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phrase-detective 0.1.35
File Size Uploaded
phrase_detective-0.1.35.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for phrase-detective 0.1.35
File Interpreter ABI Platform
phrase_detective-0.1.35-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / phrase_detective-0.1.35.tar.gz

Download URL phrase_detective-0.1.35.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b02fab8104253b694574ed5f1191e26b8decc892d38932577c26154389f52f02
BLAKE2b-256 checksum
How to use checksums
1152a4d0a9f32b9473fbc37c8edb4eeca621d76784f8ce72d847802d374dcfde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.0 Linux/6.5.0-1025-azure

Release files / phrase_detective-0.1.35-py3-none-any.whl

Download URL phrase_detective-0.1.35-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
743a48f8e4bda4e8a410cbfa9c72fd583fa62e7cbdc863fbd2fbcc3ef6a1734f
BLAKE2b-256 checksum
How to use checksums
3079210dc784c273564b6bbf2d1405a3bf0b8cefff2efea120b1a58a697597b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.0 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

0.1.35 This release

2 release files

0.1.34

2 release files

0.1.33

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page