I am trying to implement a spell check for room names in Autodesk Revit using the LanguageTool API. However, Revit freezes as soon as I run the script. It seems like the problem starts when executing the following part of the code.
Questions:
Why is Revit freezing when I run this script? Are there any better ways to implement spell checking in Revit for room names? Any suggestions on getting Hunspell to work with the de_CH locale?
I appreciate any help or suggestions!
private async Task<(bool isCorrect, List<string> suggestions)> CheckSpelling(string word)
{
string url = $"https://api.languagetool.org/v2/check?text={word}&language=de-CH";
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
JObject json = JObject.Parse(responseBody);
var matches = json["matches"];
if (matches != null && matches.HasValues)
{
List<string> suggestions = new List<string>();
foreach (var match in matches)
{
var replacements = match["replacements"];
if (replacements != null && replacements.HasValues)
{
suggestions.AddRange(replacements.Select(r => r["value"].ToString()));
}
}
return (false, suggestions);
}
else
{
return (true, new List<string>());
}
}
}
A more complete version of the question including sample code providing the necessary context is shared in the Revit API discussion forum thread on Spell Check for Room Names, and, therefore, a more complete answer is provided there as well.