synonym-custom


Namesynonym-custom JSON
Version 0.1.3 PyPI version JSON
download
home_page
Summary
upload_time2023-06-23 20:56:04
maintainer
docs_urlNone
authorSandeep Chataut
requires_python>=3.8
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **KEYWORD AND SYNONYM EXTRACTION PACKAGE**
 The "synonym_custom" package is a versatile tool designed to extract keywords from a given sentence and generate synonyms for those keywords. It combines various modules and libraries to provide multiple approaches for keyword extraction and synonym generation. The package includes the following functionalities:

1. Dictionary-based synonym generation: Utilizes web scraping techniques to extract synonyms from online thesaurus websites.

2. Spacy-based synonym generation: Relies on the Spacy library and its WordNet annotator to generate synonyms using a lexical database.

3. OpenAI-based synonym generation: Leverages OpenAI's language model to generate synonyms by providing a prompt and extracting choices from the model's response.

4. OpenAI-based keyword extraction: Uses OpenAI's language model to extract keywords from a given text by specifying a prompt and processing the model's response.

5. Spacy-based keyword extraction: Implements keyword extraction using Spacy's natural language processing capabilities. It identifies relevant keywords based on part-of-speech (POS) tagging and filters out stopwords and punctuation.

6. NLTK-based keyword extraction: Utilizes the NLTK library for keyword extraction. It applies tokenization, POS tagging, and filtering techniques to identify meaningful keywords.

7. Transformer-based keyword extraction: Employs transformer models for keyphrase extraction. It uses a pre-trained model and tokenizer to identify and format keyphrases from the input text.

# **Installation and Prerequisites for the "synonym_custom" package:**
- To install the "synonym_custom" package and use its functionalities, you need to follow these steps:
- Prerequisites:

- Python: Ensure that Python is installed on your system. The package is compatible with Python 3.8 or higher.
- Pip: Check if you have pip installed, which is the package installer for Python. Pip comes bundled with Python - versions 3.4 and above, so it should already be available.

## Installation:

- Open a command prompt or terminal.
- Run the following command to install the package from the Python Package Index (PyPI): 
```pip install synonym_custom```
- Wait for the installation to complete. The required dependencies will be automatically installed

## Prerequisites:

API Keys: Depending on the functionalities you want to use, you may need to obtain API keys or set up accounts with specific services. The package requires the following API keys:
OpenAI API Key: To use the OpenAI-based synonym generation and keyword extraction functionalities, you need to have an OpenAI API key. If you don't have one, you can sign up for an account and obtain the API key from the [OpenAI](https://openai.com/) website. 
Optional: Some functionalities, such as dictionary-based synonym generation, do not require API keys.

## Usage:

Once you have installed the package and obtained the necessary API keys, you can import it in your Python script or interactive session:

```from synonym_custom.synonym_custom import Synonym_Generator```

1. Using openai to extract keywords : 

```syn_gen = Synonym_Generator(os.getenv('OPENAI_API_KEY'))```

```extracted_keywords = syn_gen.extract_keywords_openai(text)```

2. Using nltk to extract keywords: 

```syn_gen = Synonym_Generator()```

```extracted_keywords = syn_gen.extract_keywords_nltk(text)```

3. Using transformers to extract keywords: 

```syn_gen = Synonym_Generator()```

```extracted_keywords = syn_gen.extract_keywords_trans(text)```

4. Using spacy to extract keywords: 

```syn_gen = Synonym_Generator()```

```extracted_keywords = syn_gen.extract_keywords_spacy(text)```

5. Using dictionary to generate synonyms: 

```synonym_list = syn_gen.dictionary_syn(keyword)```

6. Using openai to generate synonyms: 

```synonym_list = syn_gen.openai_api(keyword)```

7. Using spacy to generate synonyms: 

```synonym_list = syn_gen.spacy_syn(keyword)```
 
By following these steps and providing the necessary API keys, you will be able to install and utilize the "synonym_custom" package to extract keywords from sentences and generate synonyms using multiple modules and libraries.

## Example:

text = "Machine learning is a subfield of artificial intelligence (AI) that focuses on developing algorithms and models that enable computers to learn and make predictions or decisions without being explicitly programmed. It involves the study of statistical and computational models and algorithms that allow machines to learn from and analyze data, recognize patterns, and make data-driven predictions or decisions."

```python
from synonym_custom.synonym_custom import Synonym_Generator

syn_gen = Synonym_Generator(os.getenv('OPENAI_API_KEY'))  ##when using openai_api
syn_gen = Synonym_Generator()
extracted_keywords = syn_gen.extract_keywords_spacy(text) #using sapcy to generate keywords
print("Extracted Keywords:", extracted_keywords)
synonyms_dict = {}
for keyword in extracted_keywords:

    synonym_list = syn_gen.dictionary_syn(keyword) #using dictionary to generate synonyms
    synonyms_dict[keyword] = synonym_list

print("Synonyms of extracted keywords:")
for keyword, synonyms in synonyms_dict.items():
    print(f"{keyword}: {synonyms}")
```






            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "synonym-custom",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Sandeep Chataut",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/74/9e/6387e39057fb6600f0405b4b29ef7f10304c47efcc65d23c548ea97a5879/synonym_custom-0.1.3.tar.gz",
    "platform": null,
    "description": "# **KEYWORD AND SYNONYM EXTRACTION PACKAGE**\n The \"synonym_custom\" package is a versatile tool designed to extract keywords from a given sentence and generate synonyms for those keywords. It combines various modules and libraries to provide multiple approaches for keyword extraction and synonym generation. The package includes the following functionalities:\n\n1. Dictionary-based synonym generation: Utilizes web scraping techniques to extract synonyms from online thesaurus websites.\n\n2. Spacy-based synonym generation: Relies on the Spacy library and its WordNet annotator to generate synonyms using a lexical database.\n\n3. OpenAI-based synonym generation: Leverages OpenAI's language model to generate synonyms by providing a prompt and extracting choices from the model's response.\n\n4. OpenAI-based keyword extraction: Uses OpenAI's language model to extract keywords from a given text by specifying a prompt and processing the model's response.\n\n5. Spacy-based keyword extraction: Implements keyword extraction using Spacy's natural language processing capabilities. It identifies relevant keywords based on part-of-speech (POS) tagging and filters out stopwords and punctuation.\n\n6. NLTK-based keyword extraction: Utilizes the NLTK library for keyword extraction. It applies tokenization, POS tagging, and filtering techniques to identify meaningful keywords.\n\n7. Transformer-based keyword extraction: Employs transformer models for keyphrase extraction. It uses a pre-trained model and tokenizer to identify and format keyphrases from the input text.\n\n# **Installation and Prerequisites for the \"synonym_custom\" package:**\n- To install the \"synonym_custom\" package and use its functionalities, you need to follow these steps:\n- Prerequisites:\n\n- Python: Ensure that Python is installed on your system. The package is compatible with Python 3.8 or higher.\n- Pip: Check if you have pip installed, which is the package installer for Python. Pip comes bundled with Python - versions 3.4 and above, so it should already be available.\n\n## Installation:\n\n- Open a command prompt or terminal.\n- Run the following command to install the package from the Python Package Index (PyPI): \n```pip install synonym_custom```\n- Wait for the installation to complete. The required dependencies will be automatically installed\n\n## Prerequisites:\n\nAPI Keys: Depending on the functionalities you want to use, you may need to obtain API keys or set up accounts with specific services. The package requires the following API keys:\nOpenAI API Key: To use the OpenAI-based synonym generation and keyword extraction functionalities, you need to have an OpenAI API key. If you don't have one, you can sign up for an account and obtain the API key from the [OpenAI](https://openai.com/) website. \nOptional: Some functionalities, such as dictionary-based synonym generation, do not require API keys.\n\n## Usage:\n\nOnce you have installed the package and obtained the necessary API keys, you can import it in your Python script or interactive session:\n\n```from synonym_custom.synonym_custom import Synonym_Generator```\n\n1. Using openai to extract keywords : \n\n```syn_gen = Synonym_Generator(os.getenv('OPENAI_API_KEY'))```\n\n```extracted_keywords = syn_gen.extract_keywords_openai(text)```\n\n2. Using nltk to extract keywords: \n\n```syn_gen = Synonym_Generator()```\n\n```extracted_keywords = syn_gen.extract_keywords_nltk(text)```\n\n3. Using transformers to extract keywords: \n\n```syn_gen = Synonym_Generator()```\n\n```extracted_keywords = syn_gen.extract_keywords_trans(text)```\n\n4. Using spacy to extract keywords: \n\n```syn_gen = Synonym_Generator()```\n\n```extracted_keywords = syn_gen.extract_keywords_spacy(text)```\n\n5. Using dictionary to generate synonyms: \n\n```synonym_list = syn_gen.dictionary_syn(keyword)```\n\n6. Using openai to generate synonyms: \n\n```synonym_list = syn_gen.openai_api(keyword)```\n\n7. Using spacy to generate synonyms: \n\n```synonym_list = syn_gen.spacy_syn(keyword)```\n \nBy following these steps and providing the necessary API keys, you will be able to install and utilize the \"synonym_custom\" package to extract keywords from sentences and generate synonyms using multiple modules and libraries.\n\n## Example:\n\ntext = \"Machine learning is a subfield of artificial intelligence (AI) that focuses on developing algorithms and models that enable computers to learn and make predictions or decisions without being explicitly programmed. It involves the study of statistical and computational models and algorithms that allow machines to learn from and analyze data, recognize patterns, and make data-driven predictions or decisions.\"\n\n```python\nfrom synonym_custom.synonym_custom import Synonym_Generator\n\nsyn_gen = Synonym_Generator(os.getenv('OPENAI_API_KEY'))  ##when using openai_api\nsyn_gen = Synonym_Generator()\nextracted_keywords = syn_gen.extract_keywords_spacy(text) #using sapcy to generate keywords\nprint(\"Extracted Keywords:\", extracted_keywords)\nsynonyms_dict = {}\nfor keyword in extracted_keywords:\n\n    synonym_list = syn_gen.dictionary_syn(keyword) #using dictionary to generate synonyms\n    synonyms_dict[keyword] = synonym_list\n\nprint(\"Synonyms of extracted keywords:\")\nfor keyword, synonyms in synonyms_dict.items():\n    print(f\"{keyword}: {synonyms}\")\n```\n\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4258e785dd0d6621d403bfb36aea57dd18191332c83e50181b156b05d892391a",
                "md5": "2de0deb3c4c9b3ea3b21fbea62de0a44",
                "sha256": "dae3edcb1d00ec253bdfc4218ddd31345981e36f81fc97da1a0fe646348aef03"
            },
            "downloads": -1,
            "filename": "synonym_custom-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2de0deb3c4c9b3ea3b21fbea62de0a44",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5323,
            "upload_time": "2023-06-23T20:56:02",
            "upload_time_iso_8601": "2023-06-23T20:56:02.701652Z",
            "url": "https://files.pythonhosted.org/packages/42/58/e785dd0d6621d403bfb36aea57dd18191332c83e50181b156b05d892391a/synonym_custom-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "749e6387e39057fb6600f0405b4b29ef7f10304c47efcc65d23c548ea97a5879",
                "md5": "dae5cd1740954ac5906faa98d9f834b0",
                "sha256": "892f8c51eefc879600c5bea9500ee2476bf8be000d5382010f9b4b5baf7ef74f"
            },
            "downloads": -1,
            "filename": "synonym_custom-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "dae5cd1740954ac5906faa98d9f834b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5038,
            "upload_time": "2023-06-23T20:56:04",
            "upload_time_iso_8601": "2023-06-23T20:56:04.342715Z",
            "url": "https://files.pythonhosted.org/packages/74/9e/6387e39057fb6600f0405b4b29ef7f10304c47efcc65d23c548ea97a5879/synonym_custom-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-23 20:56:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "synonym-custom"
}
        
Elapsed time: 0.08378s