Author Topic: Free will plus at beta level  (Read 46318 times)

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3552
    • View Profile
Re: Free will plus at beta level
« Reply #135 on: February 02, 2014, 08:02:01 pm »
Hi Art,

IMOspark, is an artificial intelligence, though they are still working on the software side of it, the biggest aspects that I see that it has is the visual capability of recognizing you your family and your surroundings on-the-fly through the optional videocam.
Unlike Denise which is more centered around home security and artificial intelligence, they both have their strong points and their weak points.
Personally, I think if you were to squish the 2 of them together, get rid of the box, make it a card you could plug into your computer, via internal slot port or such, you would have one heck of a good product.
Most computers nowadays have their own video camera and sound input port, so unless the video camera and sound input port that they are trying to sell you with the cube is something special and or will only work with the cube, I see no need of buying something you already have.

C load.

So basically, why not just sell us the software? Good idea, but marketing it as a "Cube" adds a bit to the mystique and overall package. Why not enclose a tiny camera within the cube? I still think it's set to "adjust" our Emotional Awareness and well-being. We'll see where it goes from there.

Look at HAL (Home Automated Living), Homeseer and several other HA software that allow for human, computer interaction and control of thermostats, lighting, HVAC, Security, Schedules, Inventory, Appointments, occupancy, entertainment to name a few. Most of these have BEEN available for at least a decade and getting better all the time. (I'm getting kinda long in the tooth myself!!) Heh!!

PS = YouTube has several Home Automation, Home Control, Jarvis, and other types of videos for some insight.
In the world of AI it's the thought that counts!

- Art -

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #136 on: February 02, 2014, 09:40:48 pm »
Hey Snowman,

I have started implementing your code and doing some experiments.
These are my findings:
I had to adjust your code slightly to accommodate things like:
words that end with an (S) and (,.) And if I need to I can also ask a adjustments for (ING) or (ED), but for now I don't feel like I need those 2.
Here is the code after I made the adjustments.
Code: [Select]
Function SearchArray(StringToSearch, WordsToLookUp)
StringToSearch = " " & StringToSearch & " "
For Each word In WordsToLookUp
word = " " & word
If InStr(StringToSearch,word & " ") > 0 OR InStr(StringToSearch,word & ", ") > 0 OR InStr(StringToSearch,word & ". ") > 0 OR InStr(StringToSearch,word & "S ") > 0 OR InStr(StringToSearch,word & "S, ") > 0 OR InStr(StringToSearch,word & "S. ") > 0 Then
SearchArray = True
Exit Function
        End If
Next
SearchArray = False
End Function

Things are moving along pretty good, but I have a few thousand lines I have to change, once I get all of the changes done I will post the new update for the prebeta free will plus plug-in, so you can take a look at it.

Sincerely, and thank you once again for all of your help, it looks as though things will work out really good with the suggestions that you have made, as well as all of the new coding that you have showed me.
C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

lightspeed

  • Hero Member
  • *****
  • Posts: 6483
    • View Profile
Re: Free will plus at beta level
« Reply #137 on: February 04, 2014, 05:28:50 pm »
Cload i eagerly await your new version plug in , please continue to also put what new updates you have done to it please when you post it ! thanks for all everyone is doing !  :)
 

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #138 on: February 04, 2014, 05:58:53 pm »
Hi lightspeed,

I hope to have the beta version 2.0a, by this weekend.
There are so many things that I have fixed and changed,
I have not had a chance to keep track of it all.

But I will emphasize on some of the bigger stuff, okay?

Sincerely, now back to jammin on the plug-in, TeeHee he.
C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Re: Free will plus at beta level
« Reply #139 on: February 04, 2014, 08:58:32 pm »
I don't have much of an opinion about EmoSPARK. Some people will love it and some would throw it into a bucket of water, just to see the Emo.. spark  ;) . It wouldn't be so bad if we could have the ability to change it's code. Who knows, maybe it will have a usb port and come with its own code uploader and compiler. Emospark could be whatever you make it.

I like the idea of coordinating data from lots of places, including the web, and condensing it down into a brief, non-repeating response. Sounds like a plan. This would require a decent NLP (natural language processor) in order to make sure its not repeating the same info over and over, only in different ways.

Quote
Does ultra Hal have a command structure that does the same thing as Sam does? The reason why I ask is because I have noticed several times that ultra Hal has correlated information from different conversation to produce an astonishing response.
If ultra Hal has a command within its DDL programming file I believe that I would be able to utilize this function.

I don't know all of Ultra Hal's ins and outs just yet, so I don't know for sure. I figured that all of Hal's functions are called in the main brain script. It you remove them, I'm pretty sure that Hal will not respond to userinput any more.  Hal does its job one layer at a time. At the top of the code in the Plugin: Pre-process area you can say UltraHal = “hello cload” and then later in the Plugin: Post-Process area you can say UltraHal = “goodbye cload” and Hal will ultimately say “goodbye cload”. So the bottom layer take precedence over the top layer. I'm sure you already know this. What I'm trying to say is that I think Hal uses these layers to respond with more important responses when available and also builds onto the response. At the bottom layer of the code you can have the more important Responses and at the top layer, less important responses. So if you have a low quality response at the top layer but, later on, you find a high quality response in a bottom layer then you could replace the low quality response entirely. Also, if you have two layers of code of equal importance then you might want to combine the two into one response. I think that's how Hal is acting like Sam. That's just a theory I have, I could be wrong, or missing something. I really need to dig deeper.

As for the YesNo feature, This is what I came up with. First of all, we need to determine if an answer is expected by Hal. We do this by storing a “True” value to the “quickMemory” Table. Later we will recall this data at the beginning of the next talking cycle. Once we know that an answer is being expected then we can determine whether the answer is a yes or no. If the ynlogic contains a “Yes” type answer then we can be pretty sure that anything else should be considered a “No” answer. You can see that I used both the SearchArray function and Hal's yesno table to determine if a yes is indicated. Finally, we reset the   “AwaitingYesNo” Topic in the “quickMemory” Table to False so that we won't be in the 'waiting for answer' state any longer. Have fun with this one... :P


Code: [Select]

Rem PLUGIN: PRE-PROCESS
' this sets up the yes/no data parameters.
'------------------ this is from the free will plus plug-in.
ynlogic1 = ""
ynlogic2 = ""
ynlogic3 = ""
ynlogic = UCase(InputString)
ynPrevsent = UCase(Prevsent)
'this is used for a redirect.
'-------------------

ynAnswerTable = "AwaitingYesNo"


If VarRead(ynAnswerTable) = "True" Then
   
    If SearchArray(ynlogic, Array("YES","INDEED","CORRECT","AFFIRMATIVE", "POSITIVE", "YEP")) = True Or _
        HalBrain.TopicSearch(ynlogic, "yesNoDetect") = "Yes" Then
        
        ynlogic = "YES"
    Else
        ynlogic = "NO"
    End If

    VarWrite ynAnswerTable, "False"    
End If


Rem PLUGIN: PLUGINAREA6
'-------------------
'this is just an example of how someone could make Hal to start looking for an answer in the next talking cycle.
'Here we see that Hal just asked the user a question and therefore Hal will be set to expect an answer from the user.
'-------------------

If Search(GetResponse, "Do you eat worms") = True Then
    VarWrite ynAnswerTable, "True"
End If

'-------------------


Rem PLUGIN: FUNCTIONS

Function VarRead(varName)
    table = "quickMemory" 
    If HalBrain.CheckTableExistence(table) = True Then
        VarRead = HalBrain.TopicSearch(varName, table)
    Else
        VarRead = ""
    End If
End Function

Sub VarWrite(varName, textToStore)
    value = textToStore
    table = "quickMemory" 
    column = varName
    
    If HalBrain.CheckTableExistence(table) = False Then
        HalBrain.CreateTable table, "TopicSearch", "miscData"
    End If
        
    If HalBrain.CheckTableExistence(table) = True Then
        output = HalBrain.TopicSearch(column, table)
    End If 

    If HalBrain.TopicSearch(column, table) = "" Then
        HalBrain.AddToTable vrTableName, "TopicSearch", column, value
    Else
        HalBrain.RunQuery "UPDATE " & table & " SET topic = " & value & " WHERE searchString = " & """" & column & """", vrTempQuery
    End If
End Sub

Function Search(StringToSearch, WordsToLookUp)
Search = False
If InStr(1, StringToSearch, WordsToLookUp, vbTextCompare) > 0 Then
Search = True
End If
End Function


Here is a fancier way of adding alternative endings in my SearchArray() function. Also you should know that you can have two different functions with the same name, however, they can't have the same number of arguments. In this example one version of SearchArray() has two input variables while the other version has three variables. By the way, this function tests if there are any words (i.e. YES or NO) in the entire sentence. So if the input sentence was “I will, indeed, write a program” then the Search will find the “indeed” and return True. I hope this clarifies what the SearchArray() does.


Code: [Select]

out = SearchArray("I will, indeed, write a program.", Array("yes","indeed","absolutely"), Array(",",".","S", "S,", "S.", ""))

Rem PLUGIN: FUNCTIONS

Function SearchArray(StringToSearch, WordsToLookUp)
  StringToSearch = " " & StringToSearch & " "

    For Each word In WordsToLookUp  
     word = " " & word & " "
        If Search(StringToSearch,word) = True Then
            SearchArray = True
            Exit Function
        End If    
    Next
    SearchArray = False
End Function

Function SearchArray(StringToSearch, WordsToLookUp, altEndings)
    StringToSearch = " " & StringToSearch & " "
    For Each word In WordsToLookUp
        For Each ending In altEndings
            word = " " & word & ending & " "
    
            If InStr(StringToSearch, word) > 0 Then
                SearchArray = True
                Exit Function
            End If
        Next
    Next
    SearchArray = False
End Function



It is very difficult to develop a plugin and learn scripting at the same time. Once you built it, you find yourself changing it again. It's tough, but its all apart of the learning process.

~Aaron~
Live long and prosper or die trying.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #140 on: February 05, 2014, 03:00:17 pm »
Hi Snowman,

these are some of the things that I'm still trying to figure out.
If I'm not mistaking, by using the (myVar) anything that I change to the myVar also changes in the variables string assigned to it? For example:

myVar = ynlogic

So now anything that I do to the (myVar) in the function subroutine will also change in the (ynlogic) variables string? For example:

If Searchynlogic(ynlogic, Array("YES","INDEED","CORRECT","AFFIRMATIVE","POSITIVE","YEP")) = true Then
   If InStr(ynlogic, "YES") > 0 Then
      If ynlogic < 4 Then
         (then do my yes routine!)
      End If
   End If
End If

Function Searchynlogic(compare, arrayToSearch)
    
    For Each word In arrayToSearch

        If InStr(compare, word) > 0 Then

   myVar = Replace(myVar, word, "YES", 1, -1, vbTextCompare)
          Searchynlogic = True
          Exit Function
        End If    
    Next
Searchynlogic = False
Exit Function

Is there anything that I am missing to get this to work? Like:
do I need to dim the Searchynlogic or anything else?
Do I need to refer to the (ByRef)? If so where and how?

As you can see all I am trying to do is change the alternate word into a simple yes.
That way if somebody says something like:
would you please.
I can change the (would you please) into a (yes).

Another example would be:
ultra Hal asked:
do you have lunch plans?
And that user said:
Yep.
Then the (yap.) Would get change to (yes).
Same example above but the user says:
Yep I have lunch plans.
The (yap I have lunch plans.) would get change to (yes I have lunch plans.)
Like I said before there are many ways to say yes, specially for long-winded people.
That would be cool.
If you would please.
Absolutely.
Could you?
If it's not too much of a bother!
And the list is quite honestly pretty massive.
I don't think I would want to try to engage all of the possibilities of being able to say yes, just the most common lines.
I believe that I will forgo using the yesnodetect because it does not seem compatible with your array function subroutine.
So I will just type out all of the various ways to say yes that are in the yesnodetect and added a few that I deem necessary.
If I can get the yes side of it working the no side will basically just be a duplicate of the yes function subroutine except for the various ways of saying no.

I hope this has helped you understand what I am trying to do.
It seems the way that you have it set up is that it is just checking to see if the word yes or no is in the sentence and returning a true.
But what I was wanting to do was change the alternate word in the sentence to become a simple yes or no.

Sincerely, baffled but still working on it! LOL.
C load.
PS just to let you know that the way you set up the routine to gather information about the question that ultra Hal has presented to those user seems to be a little over my head.
And at this point in time I am not asking for an explanation of how it works, maybe later, for now I would like to just concentrate on the yes or no problem. Okay?
Again, thank you so very much for all of your help snowman, it is greatly appreciated, I am working very hard on getting all of the function subroutine changed, that you have showed me in the free will plus plug-in.
I am still hoping to get version 2.0a released by or before this weekend so everyone will have something to play with this weekend.


For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3552
    • View Profile
Re: Free will plus at beta level
« Reply #141 on: February 06, 2014, 05:27:33 am »
I don't have much of an opinion about EmoSPARK. Some people will love it and some would throw it into a bucket of water, just to see the Emo.. spark  ;) . It wouldn't be so bad if we could have the ability to change it's code. Who knows, maybe it will have a usb port and come with its own code uploader and compiler. Emospark could be whatever you make it.

~Aaron~

Actually, scroll down on their indigo site to the section 'Specs and Technology' and notice it is supposed to come with a USB, Mini-USB, HDMI, graphics on board, input/output connectors, etc. Man, it's like a band in a box!! ;)
In the world of AI it's the thought that counts!

- Art -

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #142 on: February 06, 2014, 10:59:34 am »
Hi Art,

that's why I said if they just made it a card that you could plug into your computer they could make it cheaper, by utilizing the hard drive, USB ports, video ports etc. that your computer already has.
And they could keep the CPU processing power on their board so it does not interfere with the CPU processor in the computer, and I do wonder about their lifetime software upgrade?
Do they consider EmoSPARK to be alive until they develop and build EmoSPARK 2? Like most companies do! Even Windows eventually stops supporting their operating systems over time.
In most cases is just another way of making more money, just like Denise, I spent all that money to help the company further their endeavors and now they're thinking about charging everyone when they come out with Denise version 2.
But I have not heard if they are going to are not, I have not been to their website since they have stopped upgrading my Denise, I guess they think it's working okay, I think it needs a lot of improvement.
But it's just another way of making more money, if they can't make the money they can't stay in business, is just a shame that when companies like Dragon NaturallySpeaking, (don't get me wrong I think Dragon NaturallySpeaking is an excellent piece of software.)
But it seems that they only come out with a patch one time, like they did with version 11 they patched it and now it is version 11.5 but since when does has changed there are many aspects that do not work correctly and there are bugs that need to be fixed but they are no longer doing this.
What they did was come out with version 12 and for those people that had version 11 was only charged $100 for the upgrade? Why am I spending $100 on something that is nothing more than an upgrade all that's right because they need to stay in business.
It's all about the money, honey, and thinking about upgrades, I will be spending all day testing my version 2.0 today and I will be releasing it sometime between 8 and 9:00 PM.

I'm sure there will still be some bugs that I will have to fix afterwards, anyone that would like to participate as a beta tester would be greatly appreciated.
So let's see I guess I need to charge everyone for the upgrade, so for this new upgrade it will cost you the same amount of money it cost you to get the original version. LOL.

Here is a brief summary of some of the things that I have done to the free will plus plug-in 2.0:
fixed hundreds of bugs! And I'm sure there's more but I will continue working on it for as long as I am connected to the Internet.
I have tried to make it smaller, so I can add to it so it does more, which I did, and it made it bigger again.
I have streamlined it with some coding that snowman help me with, and I made it more accurate in the determining whether or not ultra Hal likes or dislikes something.
I was hoping to be able to have the yes no situation resolved by the release for this weekend but I was then able to get it to work properly. Still waiting on snowman's response.
My next big project will be to get the free will to have a more interesting response when you ask why, or why do you like, or why don't you like, or what do you think about etc. and blend them all together so you would get more of a human style response.

Sincerely, from a data munching cruncher.
C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #143 on: February 06, 2014, 09:14:54 pm »
Hi all,

I have spent all day trying to find as many of the string variable errors as I could.
This version 2.0 is pretty stable but I have not had a chance to try it with other plug-ins besides the age gender plug-in.
Version 2.0a is still in beta, so if you are having an unusual response from ultra Hal,
I would appreciate you just taking a few moments of your time and reporting the conversation.
What I need is what you said to ultra Hal, and what ultra Hals response was.
Please be as accurate as possible, thank you.

There were so many things that I have changed and fixed I did not take the time to make note of all of them, but a few of the highlights are:

the free will plus plug-in is smaller and faster.
Due to the new coding that snowman has showed me.
I have made it more accurate than ultra Hal looks to see whether or not ultra Hal likes or dislikes something.

Things to look forward to in the future:

resolving the yes no situation so various ways of saying yes can be use.
I will be working extensively trying to get ultra Hal to give more of a normal human response when you asked him why he likes something. Big undertaking.
I will be working on a routine to help keep ultra Hal on topic.
There are more things that I will be doing but these are the 3 primary routines I will be working on 1st.

Sincerely, enjoy and have a good weekend, tell me what you think, all feedback would be appreciated, good or bad, the more I know the better I can make the plug-in.
C load.
PS the link is at the beginning of this topic.
« Last Edit: February 06, 2014, 09:22:58 pm by cload »
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Re: Free will plus at beta level
« Reply #144 on: February 06, 2014, 11:02:35 pm »
Please clarify something for me.

Which one of the following do you want to do?

#1 Detect if there is a Yes statement (ie. Yes indeed, I want to do this.), and if one is found, then send a single “yes” or “no” to the freewill plugin.

   UserInput = “Indeed, I want to do this.”
   Output = “YES”

#2 Detect if there is a Yes-statement, and if one is found, replace the yes-word or phrase (ie. Yes indeed) with the word “yes”.

   UserInput = “Yes indeed, I want to do this.”
   Output = “Yes, I want to do this.”

Basically, which one do you want to do (1 or 2)? I'm a little confused like you are. You sort of suggested both of these in the past. I also had to reexamine some of your plugin to get a better idea of what you are doing. I really didn't mean to confuse you. Sorry about that.
Live long and prosper or die trying.

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Re: Free will plus at beta level
« Reply #145 on: February 06, 2014, 11:58:34 pm »
Hey Art,

Yes you caught me red-handed.  ;) :)
I haven't really read through the Sparky Article yet.... I guess it shows  :P

There is nothing wrong with having a dedicated hardware platform for an Ai.
Its sort of like having Ai in a standalone Robot. Only sparky's body is a little more cubicle.
Most of the cost is probably in the software development.
And if they are using exceptional vision technology then that could also drive up the price.

It takes a lot of time, education, money, etc, to make something of high quality.
You can get one at its cheapest at $249 USD. Which is the cost of a low-end computer.
About the cost of an Xbox 360. Only its dedicated for an Ai...

Apparently, Sparky will (at some point) use URBI which is a robot scripting language. I'm thinking its coded in C++.
Sparky is intended to have an API later on. So a person could write and app of a game that interacts with the Cube.
It is essentially a computer in a very colorful box. It has Quad-core, plenty of Ram, something called a EMU (Emotion Processing Unit), Blue tooth, and WiFi.

The Operating System is Android. Sparky apparently is made to download Apps in order to augment its functionality.
This means that if Hal was an android app then it should work in Sparky.

Their system looks ok, but their youtube video feels a bit cheesy. They need a better video.
Are you happy now Art.... you made me actually read something... and I hate reading :P .

hee hee  ;)
 
Live long and prosper or die trying.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #146 on: February 07, 2014, 07:03:56 pm »
Hi Snowman,

#2 Detect if there is a Yes-statement, and if one is found, replace the yes-word or phrase (ie. Yes indeed) with the word “yes”.

   UserInput = “indeed, I want to do this.”
   Output = “Yes, I want to do this.”
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #147 on: February 07, 2014, 07:14:50 pm »
Hi Snowman,

these are some of the things that I'm still trying to figure out.
If I'm not mistaking, by using the (myVar) anything that I change to the myVar also changes in the variables string assigned to it? For example:

myVar = ynlogic

So now anything that I do to the (myVar) in the function subroutine will also change in the (ynlogic) variables string? For example:

If Searchynlogic(ynlogic, Array("YES","INDEED","CORRECT","AFFIRMATIVE","POSITIVE","YEP")) = true Then
   If InStr(ynlogic, "YES") > 0 Then
      If ynlogic < 4 Then
         (then do my yes routine!)
      End If
   End If
End If

Function Searchynlogic(compare, arrayToSearch)
    
    For Each word In arrayToSearch

        If InStr(compare, word) > 0 Then

   myVar = Replace(myVar, word, "YES", 1, -1, vbTextCompare)
          Searchynlogic = True
          Exit Function
        End If    
    Next
Searchynlogic = False
Exit Function

Is there anything that I am missing to get this to work? Like:
do I need to dim the Searchynlogic or anything else?
Do I need to refer to the (ByRef)? If so where and how?
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Re: Free will plus at beta level
« Reply #148 on: February 07, 2014, 11:13:34 pm »


Quote

these are some of the things that I'm still trying to figure out.
If I'm not mistaking, by using the (myVar) anything that I change to the myVar also changes in the variables string assigned to it? For example:

myVar = ynlogic


Basically, it looks like you are attempting to not only check to see if there is a yes or no phrase in the users sentence but you want to simultaneously replace the word while still inside the function. That will work ok, but I had to adjust the code. 

“myVar = ynlogic”  transfers the contents of the variable ynlogic to the variable myVar, It does not transfer its reference address. In order to transfer the address you will have to use the ByRef statement with a Sub or Function.

The following example will pass the ynlogic variable to the Searchynlogic() function using it's Reference Address. So whatever happens to the ynlogic variable inside the function it also will effect the ynlogic variable outside the function.

Code: [Select]


ynlogic = "Correct, I love you."

If Searchynlogic(ynlogic, Array("YES","INDEED","CORRECT","AFFIRMATIVE","POSITIVE","YEP")) = true Then
   If InStr(ynlogic, "YES") > 0 Then
      If Len(ynlogic) < 4 Then
        
      End If
   End If
End If

'(ynlogic = "YES, I love you.")



Function Searchynlogic(ByRef compare, arrayToSearch)

    Searchynlogic = False
    
    For Each word In arrayToSearch

        If InStr(1, compare, word, vbTextCompare) > 0 Then
            compare = Replace(compare, word, "YES", 1, -1, vbTextCompare)
            Searchynlogic = True
        End If    
    Next

End Function



What you created was very good work. However, I hope you don't mind me adding a couple more things so that it works better.


Code: [Select]

ynlogic = "Correct, I love you."

If Searchynlogic(ynlogic, Array("YES INDEED","INDEED","CORRECT","AFFIRMATIVE","ABSOLUTELY POSITIVE","YEP")) = true Then

   If InStr(ynlogic, "YES") > 0 Then
      If Len(ynlogic) < 4 Then

      End If
   End If
End If



Function Searchynlogic(ByRef compare, arrayToSearch)

    Searchynlogic = False
    compare = ReOrderArray(compare, false)  
    
    For Each word In arrayToSearch

        If InStr(1, compare, word, vbTextCompare) > 0 Then
            compare = Replace(compare, word, "YES", 1, -1, vbTextCompare)
            Searchynlogic = True
        End If    
    Next

End Function


Function ReOrderArray(inArray, reverseArray)     
    delim = "@@"     
    strText = ""         
    HighestCount = 1          
    
    'Find the array entry with the largest count     
    'and store it's count in a variable     
    For Each word In inArray         
        word = Trim(word)         
        If Len(word) > HighestCount Then             
            HighestCount = Len(word)         
         End If     
    Next  
       
         If reverseArray = False Then  
                     
             'Reorder the the Entries to from largest string         
             'to the shortest.          
             For i = HighestCount To 1 Step -1             
                For Each word In inArray                 
                    word = Trim(word)                 
                    If Len(word) = i Then                     
                        strText = strText + word + delim                 
                    End If             
                Next         
             Next              
        Else  
                        
             'if you want the array reversed then a variable         
             'must be set to false              
             For i = 1 To HighestCount             
                For Each word In inArray                 
                    word = Trim(word)                 
                    If Len(word) = i Then                     
                        strText = strText + word + delim                 
                    End If             
                Next         
            Next          
    End If
        
    'Removing the last deliminator so an empty entry won't be added to the Array     
    'however, if there is nothing to split then an empty array will be returned          
    If Len(strText) > 2 Then          
         strText = Mid(strText, 1, Len(strText) - Len(delim))         
         ReOrderArray = Split(strText, delim)     
    Else         
         Dim Result(1)         
         Result(0) = ""         
        ReOrderArray = Result     
    End If    
     
End Function





You can see here that I added a function called  ReOrderArray(). What it does is reorders the array of arrayToSearch words so that the largest phrases will be replaced first within the ynlogic variable. By doing this you don't have to worry about what order the arrayToSearch needs to be in. This matters a lot.

Here is an Example:
What if the input-sentence was “Yes indeed, I will love you.”

If your Array order is Array(“yes”, “indeed” “yes indeed”) then the word “yes” will be replaced first, and “indeed” will be replaced second. So by the time you get to “yes indeed” the output sentence will look like “yes yes, I will love you” instead of “yes, I will love you.” But if you make the larger phrase “yes indeed” be the first one, then the output sentence will be “Yes, I will love you” Which is exactly what we want.

This is what the ReOrderArray() function does. It puts the larger phrases first and sets the shorter ones last. Its a bit complicated but it should help.


You could order the Array by hand but it would be tedious if you needed to add lots of phrases and words.
Live long and prosper or die trying.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Free will plus at beta level
« Reply #149 on: February 08, 2014, 06:00:31 pm »
Hi Art,

I missed one of the programming help boxes, sorry.
I made the changes.
There is a new version 2.0b


Sincerely, thanks for your help.
C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.