Author Topic: Client_Punctuation Help  (Read 1335 times)

Code: [Select]
package Punctuation
{
    function NMH_Type::send(%this)
    {
        %txt = %this.GetValue();
        %txt = StrReplace(%txt,"cant","can't");
        %txt = StrReplace(%txt,"dont","don't");
        %txt = GivePeriod(%txt);
        %this.SetValue(%txt);
    }
};
ActivatePackage(Punctuation);

function GivePeriod(%txt)
{
%word = GetWord(%txt,GetWordCount(%txt));
%asdf = StrLen(%word) =- 1;
%asd = StrLen(%word);
%end = GetSubStr(%txt,%asdf,%asd);
        if(%end != ".")
                {
                        return %txt @ ".";
                }
}

Untested. But pretty sure it will work.

You guys might find this useful. It adds punctuation to the end of a string of text, assuming the string is only one sentence.

Code: [Select]
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;
}
« Last Edit: May 22, 2012, 07:11:59 PM by Greek2me »

T_T.
Is it really that bad? If it is then my friend sucks at scripting T_T
Your friend sucks at scripting

Untested. But pretty sure it will work.
"I'm going to an orthodon'tist to get braces"
"Acrodon'ts make horrible pets!"
"I'm going to a prosthodon'tist to get a new arm"

Similarly;

"He's uttering an incan'tation!"
"Make that horse can'ter"
"Make sure you use desiccan't in that package"
"Mercan'tilism is an economic system developing during the decay of feudalism to unify and increase the power and especially the monetary wealth of a nation by a strict governmental regulation of the entire national economy usually through policies designed to secure an accumulation of bullion, a favorable balance of trade, the development of agriculture and manufactures, and the establishment of foreign trading monopolies"

"I'm going to an orthodon'tist to get braces"
"Acrodon'ts make horrible pets!"
"I'm going to a prosthodon'tist to get a new arm"

Similarly;

"He's uttering an incan'tation!"
"Make that horse can'ter"
"Make sure you use desiccan't in that package"
"Mercan'tilism is an economic system developing during the decay of feudalism to unify and increase the power and especially the monetary wealth of a nation by a strict governmental regulation of the entire national economy usually through policies designed to secure an accumulation of bullion, a favorable balance of trade, the development of agriculture and manufactures, and the establishment of foreign trading monopolies"
Person: What is your Blockland I'd?
Person: Sorry I meant Blockland I'd?
Person: wtf?

Person: Is this guy I'll?
Person: wtf, I'll as in sick

Person: The robot cannot see it's feet
Person: wtf I said it's

Person: see is my favorite country
Person: SWEDEN


Yea, but I was talking about adam's and his only checks don't and can't

Code: [Select]
package Punctuation
{
    function NMH_Type::send(%this)
    {
        %txt = %this.GetValue();
        %txt = StrReplace(%txt,"cant","can't");
        %txt = StrReplace(%txt,"dont","don't");
        //GIVEPERIOD DOES NOT WORK YET
        //%txt = GivePeriod(%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;
}

Untested. But pretty sure it will work.

Found an error, but fixed
« Last Edit: May 24, 2012, 08:19:08 AM by adam savage »

Code: [Select]
//GIVEPERIOD DOES NOT WORK YET
Use the function that I posted above instead of your givePeriod function.

Code: [Select]
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!

Code: [Select]
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!
Lol you took Greek2Me's function and didn't even fix his syntax errors.

Lol you took Greek2Me's function and didn't even fix his syntax errors.
Oops, fixed.