Skip to content

Latest commit

 

History

History
72 lines (53 loc) · 2.04 KB

README.rst

File metadata and controls

72 lines (53 loc) · 2.04 KB

PyRXNLP - Text-mining tools for building intelligent data-driven applications.

Features:

  • Topics extraction
  • Sentence clustering - with cluster labels
  • Opinosis opinion summarization

Getting Started:

  1. Install pyrxnlp
pip install pyrxnlp
  1. If you are using the cloud APIs, get your API Key
  2. Start coding. Here's an example of Clustering Sentences
 apikey = "your_api_key"

# Cluster from a list of sentences
 list_of_sentences = [
     "the sky is so high",
     "the sky is blue",
     "fly high into the sky.",
     "the trees are really tall",
     "I love the trees",
     "trees make me happy",
     "the sun is shining really bright"]

 # initialize sentence clustering
 clustering = ClusterSentences (apikey)

 # generate clusters and print
 clusters = clustering.cluster_from_list (list_of_sentences)
 if clusters is not None:
     print ("------------------------------")
     print ("Clusters from a list of sentences")
     print ("------------------------------")
     clustering.print_clusters (clusters)

You should see output similar to:

------------------------------
Clusters from a list of sentences
------------------------------
Cluster label:  ['sky']
Cluster scores:  6.571693476432014
Cluster sentences:  ['fly high into the sky.', 'the sky is so high', 'the sky is blue']
===
Cluster label:  ['tree']
Cluster scores:  6.571693476432014
Cluster sentences:  ['I love the trees', 'trees make me happy', 'the trees are really tall']
===
Cluster label:  ['sentences_with_no_cluster_membership']
Cluster scores:  0.0
Cluster sentences:  ['0006:the sun is shining really bright']
===