Example #1
0
        private void populateFromCyc()
        {
            TheBot.AddExcuteHandler("cycl", ExecCycQuery);
            TheBot.AddExcuteHandler("subl", EvalSubLHandler);

            int        id = 1;
            FileStream f  = HostSystem.Open("nodes.txt", FileMode.Create);
            TextWriter tw = new StreamWriter(f);

            foreach (var item in cycAccess.converseList("(ask-template '?R '(#$and (#$genls ?R #$Communicating)(#$not (#$isa ?R #$NonVerbalCommunicating))) #$EverythingPSC)"))
            {
                string text = item.ToString();
                string s    =
                    "<Shape ID='" + id++ +
                    "' NameU='Decision' Type='Shape' Master='0'><XForm><PinX>0.984251968503937</PinX><PinY>11.02362204724409</PinY><Width Unit='MM' F='Inh'>0.984251968503937</Width><Height Unit='MM' F='Inh'>0.5905511811023623</Height><LocPinX Unit='MM' F='Inh'>0.4921259842519685</LocPinX><LocPinY Unit='MM' F='Inh'>0.2952755905511811</LocPinY><Angle F='Inh'>0</Angle><FlipX F='Inh'>0</FlipX><FlipY F='Inh'>0</FlipY><ResizeMode F='Inh'>0</ResizeMode></XForm><Event><TheData F='No Formula'>0</TheData><TheText F='No Formula'>0</TheText><EventDblClick F='Inh'>0</EventDblClick><EventXFMod F='No Formula'>0</EventXFMod><EventDrop F='No Formula'>0</EventDrop></Event><vx:Event xmlns:vx='http://schemas.microsoft.com/visio/2006/extension'><vx:EventMultiDrop F='No Formula'>0</vx:EventMultiDrop></vx:Event><LayerMem><LayerMember>0</LayerMember></LayerMem><Text>" +
                    text + "</Text></Shape>";
                tw.WriteLine(s);
            }
            tw.Close();
            try
            {
                f.Close();
            }
            catch (Exception)
            {
            }
            AltBot.writeDebugLine("!NonVerbalCommunicating = " + id);
            //cycAccess.setCyclist("CycAdministrator");
        }
Example #2
0
 public static void MakeLex(string infile, string outfile)
 {
     try
     {
         Hashtable hash = new Hashtable();
         //int count = 0;
         StreamReader reader = HostSystem.GetStreamReader(infile);
         string       line;
         do
         {
             line = reader.ReadLine();
             if (line == null)
             {
                 break;
             }
             int index = line.IndexOf(" ");
             //Console.WriteLine("line: " + line + " index: " + index);
             string word = line.Substring(0, index).Trim();
             string tags = line.Substring(index).Trim();
             //Console.WriteLine("word: " + word + ", tags: " + tags);
             //count++;
             if (hash[word] == null)
             {
                 hash.Add(word, tags);
             }
             // ReSharper disable ConditionIsAlwaysTrueOrFalse
         } while (line != null);
         // ReSharper restore ConditionIsAlwaysTrueOrFalse
         reader.Close();
         Stream     file      = HostSystem.Open(outfile, FileMode.Create);
         IFormatter formatter = (IFormatter) new BinaryFormatter();
         // Serialize the object hashto stream
         formatter.Serialize(file, hash);
         file.Close();
     }
     catch (Exception e2)
     {
         DLRConsole.DebugWriteLine("Error: " + e2);
     }
 }
Example #3
0
        static void initNatLangDb()
        {
            if (lexHash != null)
            {
                if (lexHash.Contains("OK"))
                {
                    var typef = lexHash["OK"];
                }
                return; // singleton pattern
            }

            try
            {
                StringCachePOSWORD["hello"]  =
                    StringCachePOSWORD["hi"] = " # Interjection-SpeechPart # Hi-TheWord # Hello-TheWord ";
                lexHash = new Hashtable();

                string outfile = MakeLex(LEXICON);
                Stream file    = HostSystem.Open(outfile, FileMode.Open);
                try
                {
                    var formatter = (IFormatter) new BinaryFormatter();
                    lexHash = formatter.Deserialize(file) as Hashtable;
                }
                finally
                {
                    file.Close();
                }
                DLRConsole.DebugWriteLine("Initialized lexHash from serialized data.");
            }
            catch (Exception exception)
            {
                DLRConsole.DebugWriteLine("ERROR: " + exception);
            }
            NLPLibTest();
        }