Skip to content

Commit d2c2059

Browse files
Merge pull request #43 from tkuebler/master
Documentation editing and addition of 'Using Chatscript on a Mac' doc.
2 parents 70037cf + 4392b4a commit d2c2059

File tree

3 files changed

+136
-6
lines changed

3 files changed

+136
-6
lines changed

WIKI/ChatScript-Json.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,30 @@ Representing JSON in CS facts is more than just a bunch of subject-verb-object f
525525
The facts have typing bits on them that describe the structure and arrays have index values that must
526526
remain consistent. Therefore you should not create and alter JSON fact structures using ordinary CS
527527
fact routines like `^createfact` and `^delete`. Instead use the JSON routines provided.
528+
529+
530+
## Practical Examples
531+
532+
The write jsonwrite and json tree print out different views of the same data..
533+
534+
u: (-testcase1) $$jsonObject = ^jsoncreate(object)
535+
ˆjsonobjectinsert( $$jsonObject name “some name” )
536+
ˆjsonobjectinsert( $$jsonObject phone “some number” )
537+
ˆjsonwrite ( $$jsonObject ) \n
538+
^jsontree ( $$jsonObject )\n
539+
540+
Note in this next example how to escpe a json string with ^''. This makes creating json objects from static data very intuitive and clear.
541+
542+
u: (-testcase2) $$tmp = ^jsonparse( ^'{name: "Todd Kuebler", phone: "555.1212"}' )
543+
^jsonwrite( $$tmp ) \n
544+
^jsontree( $$tmp ) \n
545+
name: $$tmp.name, phone: $$tmp.phone
546+
547+
This example shows the . notation access of data inside an json object in chatscript. This is probably the most intuitive way of interacting with the data.
548+
549+
u: (-testcase3) $$tmp = ^jsoncreate(object)
550+
$$tmp.name = "Todd Kuebler"
551+
$$tmp.phone = "555-1212"
552+
^jsonwrite( $$tmp ) \n
553+
^jsontree( $$tmp ) \n
554+
name: $$tmp.name, phone: $$tmp.phone

WIKI/Installing-and-Updating-ChatScript.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ make file in SRC. And you have to install curl and optionally postgres. If you d
2424
or want them you can in your build file do defines of: DISCARDDATABASE and
2525
DISCARDJSON.
2626

27+
Alternatively you can use the binary in `BINARIES/MacChatScript`, but it is at least one version behind unless you are grabbing chatscript directly from github.
28+
29+
There is also an Xcode project in the `NON-WINDOWS NON-C/Xcode` directory that you can launch and build your own binary with. This is probably the prefered method for advanced users.
30+
31+
See the `Chatscript on a Mac` in `Overviews and Tutorials` directory of the docs for a more indepth discusion of compiling and using ChatScript on a mac.
32+
2733

2834
## Installing Linux
2935

@@ -57,18 +63,39 @@ whatever. That's not the ideal way however.
5763

5864
The ideal way to do ChatScript is to have a folder that somehow contains your bot data
5965
AND contains CS as a subfolder. Like this:
60-
```
61-
MYFOLDER
62-
BOTDATA
63-
filesmybot.txt
64-
ChatScript
65-
```
66+
67+
MYFOLDER/
68+
startserver.sh
69+
BOTDATA/
70+
Smooth/
71+
smoothcontrol.top
72+
Fuzzy/
73+
fuzzycontrol.top
74+
flea.top
75+
AllBots/
76+
shopping.top
77+
filesmybot.txt
78+
ChatScript/
6679

6780
In your `filesmybot.txt` you name the path to your `BOTDATA` files and folders
6881
appropriately. Then, to update ChatScript, you remove the ChatScript folder and drop in
6982
the new one. ChatScript automatically looks above itself to find your `filesxxx.txt` file if it
7083
can't find it within.
7184

85+
Example filesmybot.txt for the directory structure above:
86+
87+
# multibot example
88+
../BOTDATA/Smooth/
89+
../BOTDATA/Fuzzy/
90+
../BOTDATA/AllBots/
91+
# load in standard chatscript quibbles
92+
RAWDATA/QUIBBLE/
93+
94+
You then start the server in the 'MYFOLDER' directory with a script like this on Mac or Linux, windows is similar:
95+
96+
#!/bin/sh
97+
cd ChatScript && BINARIES/MacChatScript livedata=../LIVEDATA english=LIVEDATA/ENGLISH system=LIVEDATA/SYSTEM local
98+
7299
Similarly, if you have your own `LIVEDATA` files, you can give a reference to your copy
73100
of files in `MYDATA/LIVEDATA` so you don't have to worry that CS copies may have
74101
changed. You want to allow CS to use its own copy of `LIVEDATA/SYSTEM` and
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#Chatscript on a Mac
2+
3+
> © Bruce Wilcox, [email protected] brilligunderstanding.com
4+
5+
> Revision 1 - 7/16/2017 - [email protected]
6+
7+
8+
## Installing
9+
10+
Life is not as easy for Mac users since Bruce doesn't have a mac - therefore a build of the mac binary is not part of every release.
11+
12+
However ChatScript builds and runs just fine on any version of OSX ( now called MacOs ) and there are many of us using ChatScript on macs with no problem. The unix underpinnings of MacOS make it a great development environment and ChatScript generally works the same way as under Linux.
13+
14+
### Method 1 - build from command line
15+
16+
After unzipping into a folder
17+
(typically called ChatScript), you need to compile the src in SRC. The alternate
18+
technology is to beg in the ChatScript forum on ChatBots.org for a mac user to send you
19+
their executable copy of the latest build.
20+
To compile means using XCODE and making an appropriate make file for it based on the
21+
make file in SRC. And you have to install curl and optionally postgres. If you don't have
22+
or want them you can in your build file do defines of: DISCARDDATABASE and
23+
DISCARDJSON.
24+
25+
The example/default command line compile is located in NON-WINDOWS NON-C/MAC/MacCompile.sh. Read the readme in that directory for more instructions.
26+
27+
### Method 2 - use outdated binary in the BINARIES folder
28+
Alternatively you can use the binary in BINARIES/MacChatScript, but it is at least one version behind unless you are grabbing chatscript directly from github.
29+
30+
### Method 3 - use the included Xcode project to build
31+
There is also an Xcode project in the 'NON-WINDOWS NON-C/Xcode' directory that you can launch and build your own binary with. This is probably the prefered method for advanced users.
32+
33+
## Prerequisites for compiling via Xcode
34+
35+
####(included) curl library
36+
This is actually part of the default mac ecosystem and is already included in the Xcode project under 'TARGETS/MacChatScript/Build Phases/Link Binary with Libaries' ( navigation path in xcode editor )
37+
38+
#### (optional) mongodb libraries
39+
These can be aquired via brew ( http://brew.sh ) The command is:
40+
41+
brew install mongodb mongo-c-driver
42+
#### (optional) postgress libraries
43+
These can also be aquired via brew. The command is:
44+
45+
brew install postgresql
46+
47+
## brew errata
48+
49+
Follow the instructions at http://brew.sh to install and use brew.
50+
51+
In general you can find the packages talked about in the is document with:
52+
53+
brew search mongo
54+
brew search postgres
55+
56+
You need the mongodb, mongo-c-driver and postgresql modules.
57+
58+
***Important:*** The version of MacOS/OSX you are running determines what version of brew you run and what packages are available. The packages for your particular macos version might be different than above.
59+
60+
## Configuring Xcode for Mongo and/or Postgres
61+
62+
More details coming Soon - essentially it involves installing the libraries then adding them to the list of libs that get included. The setting is under build phases.
63+
64+
## Running
65+
66+
Running Chatscript is as simple as executing the binary you have from the instructions above. Follow the same instructions as the main manual similar to Linux. It boils down to:
67+
68+
* Launch the `Terminal` application. It's found in /Applications/Utilities. note: ⌘[space] launches spotlight, just type terminal in the window that pops up to find it and click on it to launch it.
69+
* In `Terminal` `cd` to the directory that contains chatscript. example: `cd src/Chatscript`
70+
* Run your binary using the linux instructions, ie
71+
72+
BINARIES/MacChatScript local
73+
74+
## Getting Mac specific Help
75+
76+
The best place for getting help is probably http://chatbots.org in the Chatscript forum. There are a number of friendly and helpful users there that answer mac specific question. The github project is primarily for people contributing to chatscript code, documentation or reporting bugs.

0 commit comments

Comments
 (0)