Forum Discussion
NBR_22
2 years agoFrequent Visitor
Spell Check PowerBI
Hello, I want to do spell check for each row in a column, is there a function or something that I can use to check spell check and return a false or true if the word is correctly spell? Regar...
AmiraBedh
2 years agoSuper User
While I strongly believe that DAX first purpose isn't dedicated for such operation but here is an example :
The most simple way (especially of your data isn't huge) :
You'd need a reference list (dictionary) of correctly spelled words. Create a relationship between your data table and this dictionary.
SpellCheck =
IF(
ISBLANK(RELATED('Dictionary'[Word])),
"False",
"True"
)
This will return "False" if the word does not exist in the dictionary, and "True" otherwise.Eventhough being easy, this approach only works for individual words and not phrases. Handling multi-word phrases or sentences would be much more complex.
Or you can use this API Spell Check (this is a thread about it https://stackoverflow.com/a/59588277)
You can also use a Python script :
import pandas as pd
from spellchecker import SpellChecker
data = dataset
spell = SpellChecker()
data['IsCorrectlySpelled'] = data['YourColumnName'].apply(lambda x: x not in spell.unknown([x]))
output = data
or using R you may need to install the hunspell package :
library(hunspell)
data <- dataset
# This will return a list where each element corresponds to a word from the input.
# TRUE means the word is correct, FALSE means it's not recognized.
correctly_spelled <- hunspell_check(data$YourColumnName)
data$IsCorrectlySpelled <- correctly_spelled
output <- data