Mirage Source http://miragesource.net/forums/ |
|
[Annoyance] Correct Grammar http://miragesource.net/forums/viewtopic.php?f=183&t=6073 |
Page 1 of 49 |
Author: | Robin [ Fri Jul 31, 2009 10:58 am ] |
Post subject: | [Annoyance] Correct Grammar |
Function which automatically checks the first letter of what's fed into it. Will see if it's correct to use 'An' or 'A'. Supports capitalisation and proper nouns. If the item, npc etc. has $ as the first character of it's name, it'll be read as a proper noun. Of course, you'll have to remove this when rendering item names and stuff on the map. Code: Public Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = NO) As String Dim FirstLetter As String * 1 FirstLetter = LCase$(Left$(Word, 1)) If FirstLetter = "$" Then CheckGrammar = (Mid$(Word, 2, Len(Word) - 1)) Exit Function End If If Caps Then CheckGrammar = "A " & Word Else CheckGrammar = "a " & Word If FirstLetter = "a" Or FirstLetter = "e" Or FirstLetter = "i" Or FirstLetter = "o" Or FirstLetter = "u" Then If Caps Then CheckGrammar = "An " & Word Else CheckGrammar = "an " & Word End If End Function Example: Code: msg = "You picked up " & CheckGrammar(Trim(Item(GetPlayerInvItemNum(index, n)).Name)) & "."
|
Author: | Robin [ Fri Jul 31, 2009 11:42 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
DFA wrote: its fail it wont work on words like hour and others It's for nouns only you fucking retard. <3 |
Author: | JokeofWeek [ Fri Jul 31, 2009 3:06 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Just for the fun of it, since we're fixing grammar mistakes. I before E except after C Code: Dim Loc As Integer If InStr(1, Word, "ei") <> 0 Or InStr(1, Word, "ie") <> 0 Then For Loc = 2 To Len(Word) If Mid(Word, Loc, 2) = "ie" And Mid(Word, Loc - 1, 1) = "c" Then Word = Left(Word, Loc - 1) & "ei" & Right(Word, Len(Word) - Loc - 1) ElseIf Mid(Word, Loc, 2) = "ei" And Mid(Word, Loc - 1, 1) <> "c" Then Word = Left(Word, Loc - 1) & "ie" & Right(Word, Len(Word) - Loc - 1) End If Next Loc End If (I know there are exceptions, but eh ) Btw Robin, hourglass is a noun, but it's one of the few exceptions that use an that doesn't start by a vowel. <3 |
Author: | Robin [ Fri Jul 31, 2009 3:39 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
JokeofWeek wrote: Btw Robin, hourglass is a noun, but it's one of the few exceptions that use an that doesn't start by a vowel. <3 Well, feel free to add in all the special words which you want to use as a custom check. Personally, I have no need for an item called Hourglass ;D |
Author: | GIAKEN [ Fri Jul 31, 2009 11:50 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Pfft I already did this. |
Author: | Robin [ Fri Jul 31, 2009 11:50 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
GIAKEN wrote: Pfft I already did this. Holy fucking shit you're alive. |
Author: | Matt [ Fri Jul 31, 2009 11:58 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
If it sounds like it starts with a vowel, it's possed to use an, not a. I used to know a LOT of those words, but I can't remember them anymore. Lol. This is something that's been needed in MS for awhile. It seems like it's simple and would have no real change, but it makes a big difference imo. |
Author: | GIAKEN [ Sat Aug 01, 2009 12:01 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Robin wrote: GIAKEN wrote: Pfft I already did this. Holy fucking shit you're alive. I just moved out of my parents house. Anyways, I did this check grammar thing in Elysium Diamond 3 a long ass time ago. Here's my function: Code: Public Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = NO) As String
Dim FirstLetter As String * 1 FirstLetter = LCase$(Left$(Word, 1)) If Caps Then CheckGrammar = "A" Else CheckGrammar = "a" If FirstLetter = "a" Or FirstLetter = "e" Or FirstLetter = "i" Or FirstLetter = "o" Or FirstLetter = "u" Then If Caps Then CheckGrammar = "An" Else CheckGrammar = "an" End If End Function |
Author: | GIAKEN [ Sat Aug 01, 2009 12:03 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Oh haha I see what you did thar Robin. Anybody notice how much alike they are? |
Author: | Robin [ Sat Aug 01, 2009 10:19 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
GIAKEN wrote: Oh haha I see what you did thar Robin. Anybody notice how much alike they are? Probably your code. I just found it in Essence. |
Author: | Jacob [ Sat Aug 01, 2009 12:06 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Here's a tiny improvement: using "ass" Quote: %Faster 185.7| 71.4| 71.4| 64.3| 71.4| 64.3| 71.4| 64.3| 84.6| 71.4 Test1 40| 24| 24| 23| 24| 23| 24| 23| 24| 24 Test2 14| 14| 14| 14| 14| 14| 14| 14| 13| 14 using "test" Quote: %Faster 46.7| 46.7| 64.3| 53.3| 53.3| 33.3| 33.3| 33.3| 53.3| 33.3 Test1 22| 22| 23| 23| 23| 20| 20| 20| 23| 20 Test2 15| 15| 14| 15| 15| 15| 15| 15| 15| 15 Test1 was using the original code. Test2 is: Code: Private Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = 0) As String
Dim FirstLetter As String * 1 FirstLetter = LCase$(Left$(Word, 1)) If FirstLetter = "$" Then CheckGrammar = (Mid$(Word, 2, Len(Word) - 1)) Exit Function End If If FirstLetter Like "*[aeiou]*" Then If Caps Then CheckGrammar = "An " & Word Else CheckGrammar = "an " & Word Else If Caps Then CheckGrammar = "A " & Word Else CheckGrammar = "a " & Word End If End Function |
Author: | GIAKEN [ Sat Aug 01, 2009 5:21 pm ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Something less repetitive. Not sure if it's any faster. Also this function is made to be faster for words that need "An" because statements in an Else are always slower than statements in the actual If. I'm not sure which would come up more often (needing an An or just A), but to change it just add If Not FirstLetter and switched the statements around. Code: Private Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = 0) As String
Dim FirstLetter As String * 1 FirstLetter = LCase$(Left$(Word, 1)) If FirstLetter = "$" Then CheckGrammar = (Mid$(Word, 2, Len(Word) - 1)) Exit Function End If If FirstLetter Like "*[aeiou]*" Then If Caps Then CheckGrammar = "An " Else CheckGrammar = "an " Else If Caps Then CheckGrammar = "A " Else CheckGrammar = "a " End If CheckGrammar = CheckGrammar & Word End Function |
Author: | wanai [ Fri Jan 07, 2022 10:27 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Econ |
Author: | wanai [ Fri Jan 07, 2022 10:28 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
115.9 |
Author: | wanai [ Fri Jan 07, 2022 10:29 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Bett |
Author: | wanai [ Fri Jan 07, 2022 10:30 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Bett |
Author: | wanai [ Fri Jan 07, 2022 10:31 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Thom |
Author: | wanai [ Fri Jan 07, 2022 10:32 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Mohi |
Author: | wanai [ Fri Jan 07, 2022 10:33 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Shop |
Author: | wanai [ Fri Jan 07, 2022 10:35 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Gera |
Author: | wanai [ Fri Jan 07, 2022 10:36 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Robe |
Author: | wanai [ Fri Jan 07, 2022 10:37 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Vide |
Author: | wanai [ Fri Jan 07, 2022 10:38 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
EyeT |
Author: | wanai [ Fri Jan 07, 2022 10:39 am ] |
Post subject: | Re: [Annoyance] Correct Grammar |
Fisk |
Page 1 of 49 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |