Thursday, March 10, 2016

This is not a Poem

No, seriously. This is not a poem. (Unlike this, arguably). This is a tutorial. A tutorial which will show you how to do something that is really cool using some slick new features of Infinite Monkeys v3.5.

Oh YAY! What can I now do?

You can now create dynamic dictionaries from texts like Edgar Allen Poe's Black Cat. You can import the dictionaries into IM.3.5.0, save those dictionaries as a JSON object, and export them as HTML for use in a web based program.

Please note that it helps to have some familiarity with HTML and JavaScript, to use these features since you will be editing webpages in order to tailor this to your liking.

K. What does that mean?

Well. That means

  1. IM3 will create a dictionary using only the words in a given text.
  2. You can save that file as a JavaScript readable object.
  3. You can create a web page which dynamically accesses this dictionary object

Wowee! That's the best! How do I get started?

Step 1: Download Infinite Monkeys v3.5.0 here

Step 2: Download the dictionary wrapper here

Now that you have all the files you need. Find yourself some nice raw text. A good place to look would be

Ok.. I've done all that! Now what?

Step 3: Double click on im3.exe and click over to the In Text tab. Copy whatever selected text you please, and then paste it into the text buffer.

Step 4: From the WORDS menu, select Build Dictionary From Text.

Step 5: It will then ask you which context you want to copy it to. Pick a context. It doesn't matter which.

Step 6: It will then inform you that the words highlighted in blue have not been added to the dictionary context. You must manually add them yourself to the master dictionary, then build the dictionary again from the remaining text. You can do this easily by clicking the Add All Unadded option from the WORDS menu.

Step 7: Click over to the Dictionary Editor tab. And then choose the context which you copied the imported words into.

Step 8: From the FILE menu: Save the dictionary as a JSON file. Be sure to include dictionary.json as the file's extension. In this case I've chosen to name the file "black cat poe.dictionary.json".

Step 9: Then from the FILE menu: Choose Save as HTML. Choose your dictionary.json file.

IM3 has no begun the process of spitting a functional HTML file. This process takes some time because string concatenation can be a slow process. I will look into optimizing in the future, but for now what I have works, so we're sticking with that.

If you click over to the console window it will let you know how far the process has progressed.

You now have a functioning HTML file and a JSON object which can be used in a browser.

That's great! Now what?

Remember the dictionary.html file you downloaded? It's about to come in handy.

But first, IM3 has generated an HTML file which is currently stashed in the /Data folder. So double click on that, find it, and load it into an editor of some kind. A simple text editor like notepad is fine.

Step 1: Find the JSON line.

It should look something like this:

var jsonTxt = "[{    \"txt\": \"for\",    \"tag_tkns\": [\"IN\"], ...

Once you've found it copy it.

Step 2: Find the JSON line again.

Now, you want to find the similar line in dictionary.html. Then you'll delete the text in quotes and copy quoted text from the exported file in place of the original text in dictionary.html.

Am I done yet?

 Yes and no.

In order to work with the dictionary functions you will need to familiarize yourself with the Part of Speech tagging conventions and phonetic translations used in IM3. This information can be found in the IM3 Documentation.

An example can be found here.

1 comment:

  1. Cool idea and nice work! I can envision some really interesting applications of this. And thanks for the link, too. Much appreciated!