I'm having a lot of difficulty working with URL inputs from FormFunction[]. I'm trying to write a program that will compose a title for an article or text from a given webpage. The first step is to gather information about the text by counting the usage of words. I use Tally[] to count the words, but the words must be normalized. I've gotten normalization and deployment to work, but not all together. Here is what I have so far:
NormalizeInput = Function[
site,
inputStrings = StringSplit[
Import[site, "Plaintext" ],
Except[
WordCharacter] ..
];(*Imports plaintext from the webpage,
then splits words into strings*)
loweredStrings = ToLowerCase[
inputStrings
];(*Normalizes the input data*)
sortedFreq = Sort[
Tally[loweredStrings],
#1[[2]] > #2[[2]] &
];(*Counts occurances of words then sorts*)
shortedFreq = Cases[
sortedFreq,
{a_, b_} /; b > 3
](*Lists words that occur more than twice*)
];
CloudDeploy @ FormFunction[{
"Website" -> <| "Interpreter" -> "SemanticURL",
"Input" -> "https://en.wikipedia.org/wiki/Main_Page"|>
},
inputNormed = NormalizeInput[#Website] &;
PieChart[
inputNormed[[[All, 2]]],
ChartLegends -> inputNormed[[[All, 1]]],
ChartStyle -> ColorData[ "WebSafe"]
],
"HTML",
AppearanceRules -> <|
"Title" -> "Word Counter",
"Description" -> "Counts how often words repeat on a webpage."
|>
]
To be more specific, this is the section that I feel is causing me trouble:
CloudDeploy @ FormFunction[{
"Website" -> <| "Interpreter" -> "SemanticURL",
"Input" -> "https://en.wikipedia.org/wiki/Main_Page"|>
},
inputNormed = NormalizeInput[#Website] &;
By the way, I am new to Wolfram Programming. I just started this week, so please feel free to point out any of my stupidity or give helpful suggestions toward my writing techniques!