AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Coding for Grammar: Switching “person”
 
 

One of the “technical issues” that I’m having with Morti right now is his inability to properly change his responses to correctly reflect which “person” he should be using. Unfortunately, I’m NOT an expert when it comes to this, as far as the actual “listing” of possible changes in person are concerned. What I’m asking here is for those who have a firmer grasp of this aspect of proper English grammar to look over what I already have, and tell me if I’m missing something. smile

Below is a table of “pronoun swaps” that I’ve come up with, showing the input word, the output word, and the type of conversion uesd (first to second, second to first, first to third):

Pronoun swapping:

from      to         conversion
_____________________________________________
I            
you            1>2
"I am"    "you are"    1>2
"I was"   "you were"  1>2
myself    
yourself      1>2

you           
me            2>1
"you are"   "I am"       2>1
"you were" "I was"      2>1
yourself     
myself       2>1

I            
he             1>(male)
I            she            1>(female)
I            they           1>(undefined)
"I am"    "he is"        1>(male)
"I am"    "she is"       1>(female)
"I am"    "they are"   1>(undefined)
myself    himself       1>(male)
myself    herself       1>(female)
myself    theirself     1>(undefined) - poor grammarbut better than what was currently being used

(I use “they”, rather than “it”, because we’re referring to people here, and not furniture)

Please note that the above isn’t what’s currently used for Morti. I’m trying to create a better, more efficient/correct function than what’s presently being used. Also, in the conversion from one “person” to another, can anyone tell me of any other actions besides switching pronouns that may need to be addressed? Thanks in advance for your input. smile

 

 

 
  [ # 1 ]

also:
my <-> your

 

 
  [ # 2 ]

To add to the confusion, that table will not always work. For example, “Do you like fish” will give “Yes, me like fish”.

 

 
  [ # 3 ]

Yeah, the problem is that second person doesn’t distinguish between nominative and accusative. Also: don’t know if your concerned about this yet, but when you switch pronouns, you sometimes have to change the verb conjugation. And if you include third person accusative (her/him), you run into more problems. “Her” can be a pronoun or a possessive.

I truly think building my bot in German would be easier to program considering how precisely each case is distinguished. Mixing up the word order in an English sentence could get you into trouble, but not so with German (although they are more strict about word order too!) I took a term of “New Testament Greek” in college. Now that’s a precise language. The declension of each word tells you precisely where it fits in the sentence, provided you can keep all the rules straight!

I wonder how easy it would be to rank natural languages based on how “context-free” they are. Languages that require knowledge about the objects/concepts involved in order to interpret the sentence would be ranked lower than languages for which rules encoded in the words and sentence order tell exactly how each word and phrase relates to the others. Has this been done?

 

 
  [ # 4 ]

@Jan: Thanks for the addition. smile

@Steve: While I hadn’t thought specifically about that particular problem, most of it is covered by a lot of other categories, so I think that the “I/me” scenario will be rather rare. Still, though, I think I’ll have to investigate it, and see if I can come up with a more elegant solution.

@CR: ACK! Unfamiliar word context! smile My last lessons in grammar were over 25 years ago, and the meanings of words like “nominative” and “accusative” have faded into the misty realm of forgetfulness. downer At least I (vaguely) remember the concept of “verb conjugation”, sort of. But this is exactly why I brought this matter before the community. If you don’t mind, CR, can you provide a simple example of what you’re referring to, so that I might study it, and expand? I’ll never ask someone to “do my homework” for me, but the occasional example doesn’t hurt. raspberry As to any other languages beyond English that I know, I’m afraid they’re not exactly “spoken” languages, per se. PHP, 6502 Assembly and Klingon don’t really count, though, do they? smile

 

 
  [ # 5 ]

Dave, I suggest you drop the third person stuff. If the user is talking about someone in the third person most of the time you can refer to the person the same way.

 

 
  [ # 6 ]

Dave, you’re not alone. The problem is twofold:

(1) Many grammatical distinctions aren’t actually represented in English. The subjunctive mood, for example is all but non-existent. You find it in phrases such as “If I were to…”. Ever wonder why we don’t say “If I was to…”? That’s subjunctive in action. Good luck finding many more examples where it makes a difference.

(2) Teaching grammar rules and sentence parsing comes in and out of fashion. When I was in school, it was on the out. Instead, students were taught how to recognize whether a sentence “sounds right” or not. The first lesson I had in sentence diagramming was when I took French! Our teacher was shocked that none of us knew how to do it. My junior year of high school, I had a great English teacher named Prof. Shively. He forced us to learn proper grammatical terms and sentence parsing, but prefaced the lesson with something like “Look, I know it’s not fashionable and you’re probably never going to use it, but this is something you should know.” I have to agree—understanding the basic building blocks of language structure informs how we construct our communication and a better grasp of these principles may just lead to a little more understanding in the world. One can hope, at any rate. smile

Okay maybe there are three problems: time! High school was too long ago. I had to go back through and re-learn my grammar as well when I started ALEX. Perhaps this is the most important factor. raspberry

On to examples.

Verb conjugation is what you did intuitively when you replaced “I am” with “you are”. Verbs are conjugated to match the case of the pronoun/noun. In most cases, the only conjugation you need to worry about in present tense is adding an “s” to 3rd person singular cases. For example, “I run” and “he runs”. (My boyfriend, whose first language is German, used to have a real problem with adding that “s”. He figured since English verbs “weren’t conjugated” for the most part, why bother? lol)

Nominative refers to the case in which a noun is used as the subject of the sentence. Accusative refers to the case when a noun acts as a direct object. For example, in the sentence “The dog ate the bone.”, “dog” is nominative and “bone” is accusative. The nouns look the same either way in English. Not true in Greek. All words have “declensions”, which are basically additional letters added onto the end to indicate which case they are. I believe this was partially because in writing, there originally were no spaces between words. The endings of each word let you know one word was ending and another was beginning!

There are two other cases one should be familiar with: dative and genitive. Dative is used for indirect objects. English doesn’t really distinguish an indirect object from a direct object. In the sentence “I gave the dog a bone.”, “the dog” is the indirect object (dative) and “the bone” is the direct object (accusative). In German, a dative noun would get a different article, but English just uses “the” for everything. The genitive case is the possessive case. Whenever you use ‘s or “of”, you are invoking the genitive case. In the sentence “Dave’s dog ate the bone.”, “Dave” is the genitive noun.

Blah, a lot going on there. It can be worse. Greek also has something called the “vocative” case. But I won’t even go there. smile

Edited to add: Klingon I hear actually is a fully-functioning language. Didn’t google used to offer to translate pages into Klingon? lol

 

 
  [ # 7 ]

Back in the late 80’s and early 90’s I got the opportunity to attend several SciFi conventions, and got the chance to meet Dr. Marc Okrand, a linguist, and the man directly responsible for the creation of the Klingon language. During that time, I had my audio books, “Conversational Klingon”, and “Power Klingon”, along with some scripts from a couple of the Star Trek movies, which I studied constantly (it’s amazing what we do when we have no social lives). Of course, now all I can do in Klingon is utter a few phrases, and count to three; which clearly illustrates the point that, if we don’t use it, we lose it. smile

Anyway, back to the discussion at hand. Thanks, CR, for the help in understanding what I need to do here. Your explanations have gone a long way towards “re-lighting the fires of learning”. I was in junior high when we learned “sentence-mapping”, as my teacher called it, for like your time in school, that sort of grammar education was becoming less than popular. I think I’ll take a trip over to the local primary/secondary schools, and try to purchase some used textbooks on grammar, so as to expand upon what I learned here.

Since the table I have now is already vastly superior to the list of pronoun swaps Morti’s current function uses, I’ll go ahead and re-build the function, and see how it goes. That doesn’t mean that I’ve stopped looking for suggestions, though. If anyone else has .02¢ to pitch in, by all means, please do! smile

 

 
  [ # 8 ]
Merlin - Feb 28, 2011:

Dave, I suggest you drop the third person stuff. If the user is talking about someone in the third person most of the time you can refer to the person the same way.

Almost forgot to respond to this. Oops?

Actually, Merlin, Morti’s GOSSIP tag pretty well requires the first to third person transformations, because his random gossip responses look something like, “Dave said he wants to try skydiving.”

The input that would cause Morti to store some gossip would look like, “I want to try skydiving.” - clearly this wouldn’t work if I didn’t have the third party transforms.

I’m also going to have to go through a great number of categories, and correct/replace/insert some <person> and <person2> tags, because in addition to the issues with the function itself, there are some issues with incorrect or missing tags. THAT’S going to be the fun part. raspberry

 

 
  [ # 9 ]

Another hurdle that I’m faced with is that the current function, while it has the means to transform from first person to second, and from second person to first, it has no provisions for preserving the first transformations that it made, so it ends up re-transforming everything from second person back to first. Thus, the example sentence below:

“I have a toolbox that looks just like the one you have”

ends up as:

“I have a toolbox that looks just like the one me have” (still have to work out the whole “I/me” thing)

when it should be:

“You have a toolbox that looks just the one I have”

I’m going to try out a method that transforms all first person pronouns/pronoun phrases into tokenized strings with unique “keys” (non alpha-numeric characters) added to the beginning and end of each instance. then I’ll do a second to first transform, and then de-tokenize the earlier transforms, resulting in them remaining in second person. Hopefully, this will prevent the earlier outlined problem. smile

This still leaves me with the problem of “you/me” vs. “you/I”, but I think that will have to include some sort of contextual branching, and I’ll have to research some methods of doing so. I suppose I could create a lot of RegEx patterns, like “you want” = “I want”, and “for you” = “for me”, and vice-versa., but that seems to be a lot of work. Maybe there’s another way. Who knows?

 

 
  [ # 10 ]
Dave Morton - Feb 28, 2011:

Another hurdle that I’m faced with is that the current function, while it has the means to transform from first person to second, and from second person to first, it has no provisions for preserving the first transformations that it made, so it ends up re-transforming everything from second person back to first. Thus, the example sentence below:

“I have a toolbox that looks just like the one you have”

ends up as:

“I have a toolbox that looks just like the one me have” (still have to work out the whole “I/me” thing)

when it should be:

“You have a toolbox that looks just the one I have”

I’m going to try out a method that transforms all first person pronouns/pronoun phrases into tokenized strings with unique “keys” (non alpha-numeric characters) added to the beginning and end of each instance. then I’ll do a second to first transform, and then de-tokenize the earlier transforms, resulting in them remaining in second person. Hopefully, this will prevent the earlier outlined problem. smile

I hit the same thing and for the longest time couldn’t figure why my function wasn’t actually swapping the two. I ended up putting a control character in the swap words and then just strip the control character as the last step.

 

 
  [ # 11 ]

Yup. That’s exactly the method I’m using. Except I’ve placed control characters at both ends, just to make sure. smile

 

 
  [ # 12 ]

For example, “Do you like fish” will give “Yes, me like fish”.

Is this correct English? I thought ‘me’ was always for the ‘object pronoun’ not the subject?

 

 
  [ # 13 ]

Well, according to The Arrogant Worms, “Me Like Hockey” is perfectly acceptable grammar. raspberry

I’ve also added “you like” = “I like” to my table of swaps, so that example is now a non-issue. smile

 

 
  [ # 14 ]
Jan Bogaerts - Feb 28, 2011:

Is this correct English? I thought ‘me’ was always for the ‘object pronoun’ not the subject?

I would say it wasn’t correct English. I used it as a way of showing that a simple table may not be sufficient. Ok now that “I like” is fixed, I present “Can you dance” which will give “No me can not dance”. and so on and so on.

 

 
  [ # 15 ]
Steve Worswick - Feb 28, 2011:

Ok now that “I like” is fixed, I present “Can you dance” which will give “No me can not dance”. and so on and so on.

Now that I have the function operating (locally, for now) the way I want it, it’s a simple matter of adding entries to a couple of arrays, and new “swaps” are then included. I think I’ll even take this a step further, and create a data file with coupled patterns/replacements, so that all I have to do is insert the new terms into the data file, and the script takes care of the rest. For now, though:

Daveaiml star test Can you dance
Morti
PERSONcan me dance
PERSON2
can me dance
GENDER
male 

As you can see, it needs another entry. smile

 

 1 2 3 > 
1 of 3
 
  login or register to react