NLTK python scripts in Power Bi

Hi Experts,
I have a survey data which consist of text and there are almost 15,000 records. Can someone plz help and guide me how can i run NLTK key phrase extraction in power bi using python scripts.

I dont want to use Microsoft text analytics as my office dont want the data to go on ther ther server.

Answer:
Hi @EnanBahadur,

Using EDNA AI within the Enterprise DNA platform. Please see below.

Running NLTK Key Phrase Extraction in Power BI using Python Scripts

To run NLTK key phrase extraction in Power BI using Python scripts, you can follow these steps:

Load Your Survey Data into Power BI
    Import your survey data into Power BI. Ensure that the text data is accessible in your Power BI report.

Set Up Python Environment in Power BI
    Go to File -> Options and settings -> Options -> Python scripting.
    Enable Python scripting by providing the path to your Python executable file.

Write Python Script for NLTK Key Phrase Extraction
    Write a Python script that utilizes NLTK for key phrase extraction. Make sure your script includes the necessary NLTK libraries.
    Here is a general outline of how your script might look:

    import nltk
    from nltk import word_tokenize
    from nltk.util import ngrams

    def extract_keyphrases(text):
        # Tokenize the text
        tokens = word_tokenize(text)
        
        # Extract key phrases using NLTK ngrams
        key_phrases = []
        for i in range(1, 4):  # Extract n-grams up to trigrams
            key_phrases.extend([' '.join(ng) for ng in ngrams(tokens, i)])
        
        return key_phrases

    # Apply key phrase extraction function to each row of data
    df['KeyPhrases'] = df['TextColumn'].apply(extract_keyphrases)

Integrate Python Script into Power BI

In Power BI, go to Transform Data -> Run Python Script.
Paste your Python script into the script editor and modify it to fit your data source and requirements.

Visualize Key Phrases in Power BI

Once the Python script runs successfully, you will have a new column in your dataset containing the extracted key phrases.
You can then create visuals in Power BI to analyze and visualize these key phrases as needed.

DataMentor is good tool to help you in your solution.

I hope this helps.
Keith

1 Like

@EnanBahadur ,

You can check Gaellim’s training Advanced Python for Power BI in Data Cleaning and NLP

Available at Enteprise DNA platform

aftrer basic NLP and Clean Text and Word Frequency session with different NLTK options

at the end you can find Final Dashboard part so you can see how it can be combined with Power BI.

Enjoy the training.

Best regards

Thank you so much for the detailed answer and apologies for the late reply as i was not at work. I truly appreciate your time to reply to my post that gives me a starting point for my analysis.

Thank you for the update.
Yes i am currently doing this training.

Hi,
can you please guide me the name of the course where python setup in power bi is done. I have done the NLP which states to do the python - part 1 but cant find it.

Appreciate your help.

Hi @EnanBahadur

All python courses are on the learning platform

all you need to do is search by typing in python in the

results of the python

Happy Learning.

Thanks
Keith