Skip to main content

Extract phrase from English sentence such as noun, verb, preposition based on NLP task word chunking and HuggingFace library

Project description

Phrase extraction

Input: PennyLane went to the school

Output: [{'Noun Phrase': 'PennyLane'}, {'Verb Phrase': 'went'}, {'Preposition': 'to'}, {'Noun Phrase': 'the school'}]

I train a sequence tagging model based on RoBERTa of Huggingface. The training code is given in train.py.

How to use

from PhrExt import PhraseExtractor

if __name__ == "__main__":
    phrase_extractor = PhraseExtractor('transZ/phrext', 'roberta-base')
    sent = "PennyLane went to the school"
    res = phrase_extractor(sent)
    print(res)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PhrExt-0.1.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

PhrExt-0.1.0-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page