[Solved] "The first argument is expected to be a string, a valid..."

First day trying out cloud notebooks.

Unsure why this produces an error:

CloudDeploy[FormFunction[{{"input","Comma Separated Words or Phrases"}->"String"},Sort[WordFrequencyData[{#input}],Greater]]]

Hi Casey,

There are a couple of problems. A function needs to be passed to FormFunction and the function receives a single string, not a list of strings. Add a & to create a pure function and use StringSplit to generate the list of strings.

FormFunction[{{"input", "Comma Separated Words or Phrases"} -> "String"}, 
 Sort[WordFrequencyData[StringSplit[#input, ","]], Greater] &]

Thank you,

I found StringTrim helpful here to:

CloudDeploy[FormFunction[{
"input" -> <|"Label" -> "Synonyms","Hint" ->"Comma or Pipe Separated Words and Phrases"|>
},Sort[WordFrequencyData[StringTrim[StringSplit[#input, {",","|"}]]], Greater] &]]

Is there a ‘simple’ way to have the output of this appear tabular?

Here are a few ways

WordFrequencyData[{"cat", "dog", "mouse"}] // Dataset

WordFrequencyData[{"cat", "dog", "mouse"}] // 
  KeyValueMap[<|"Word" -> #, "Frequency" -> #2|> &] //
  Dataset

WordFrequencyData[{"cat", "dog", "mouse"}] // 
  KeyValueMap[{#, #2} &] //
  Prepend[Style[#, Bold] & /@ {"Word", "Frequency"}] // 
  Grid[#, Frame -> All, Background -> {None, {Yellow}}] &

Thank you, super helpful.

I’m happy with this for the moment:

CloudDeploy[FormFunction[
{"input" -> <|"Label" -> "Synonyms","Hint" ->"Comma or Pipe Separated Words and Phrases"|>},
Dataset[Sort[WordFrequencyData[StringTrim[StringSplit[#input, {",","|"}]]], Greater]] &,
"Table"]]