Hello,
You are already on a track that will work. You asked my opinion, but remember, there are often several ways to get to where you want to go.
My opinion isn't going to be any better than anybody else's opinion if both methods work!
Suppose we say this is the goal: Infer user's and Hal's genders, to turn on and off extra databases.
With this as the goal, the first thing I would think of would be to make a routine or a file look-up to infer gender from name. The username and Halname are both readable as variables in the script. So, you could make something like this:
If ComputerName = Linda Then HalFemale = True
If ComputerName = Mildred Then HalFemale = True
'Etc., etc., for every female name you can think of.
If you wanted to get fancier, you could use a file to hold the data.
Now if you still want to infer gender from context rather than name, you pose the problem of modifiers interfering with phrases such as "my brown beard," since "my brown beard" has an adjective in the way between "my" and "brown" and you don't want to have to imagine every possible adjective.
In this case (again, this is only my opinion), I would take a chance and detect "my" and "beard" separately. There would be a slight risk of being wrong, but if both words tested as present, and the male word tested as later in the sentence than the word "my," you could make a pretty good guess. Remember, "Instring" returns a number of 0 if the character string is not found, and it returns the number of the character position in the sentence if it IS found. Here is how this would look:
'------------------------
'Make a good guess about Hal's gender based on context:
'Let's start with our variants at zero just in case we decide to use them in an earlier routine someday:
MyWordPosition = 0
MaleWordPosition = 0
'Now we change the variants to the positions of our desired words, if the words are present:
MyWordPosition = Instr(Usersentence, " my ")
If Instr(Usersentence, " beard ") > 0 Then MaleWordPosition = Instr(Usersentence, " beard ")
If Instr(Usersentence, " manhood ") > 0 Then MaleWordPosition = Instr(Usersentence, " manhood ")
'Etc., etc. for all the words you want to look for...
'Now we do a logical "and" test; if all the right conditions are satisfied, we conclude that Hal is a male:
If MyWordPosition > 0 And MaleWordPosition > 0 And MyWordPosition < MaleWordPosition Then HalMale = True
'---------------------
Again, I know that you are on the right track, and these are only options and opinions, but if it was me, that's how I would approach the problem.
Another reminder: Write code in little blocks in one window, while running Hal in the other window. Toggle back and forth and talk to Hal after writing and saving a little block of code. If you make a syntax error, Hal will "lock up" and give you an error code right away. Then you can go back and find your error while the trail is hot. Some syntax errors can be nearly impossible to find after the trail is cold; it could be just one comma or parenthesis out of place somewhere!
Sincerely,
Don