package Punctuation
{
function NMH_Type::send(%this)
{
%txt = %this.GetValue();
%txt = StrReplace(%txt,"cant","can't");
%txt = StrReplace(%txt,"dont","don't");
%txt = addMissingEndPunctuation(%txt);
%this.SetValue(%txt);
}
};
ActivatePackage(Punctuation);
function addMissingEndPunctuation(%flag)
{
%endingPunct = ".?!:;"
%questionWords = " who what where when why how ";
%len = strLen(%flag)
if(%len > 1)
{
%lastChar = getSubStr(%flag,%len-1,1);
if(strPos(%endingPunct,%lastChar) < 0)
{
%firstWord = firstWord(%flag);
if(striPos(%questionWords," " @ %firstWord @ " ") >= 0)
{
%flag = %flag @ "?";
}
else
{
%flag = %flag @ ".";
}
}
}
return %flag;
}
All set up and ready to go!