Message Boards Message Boards

Writing letters (of alphabet) with kids

Posted 9 years ago
Attachments:
POSTED BY: Todd Rowland
4 Replies

Cool. Let me know how it goes.

POSTED BY: Todd Rowland

Right, I forgot about that. It's neat how one can go from making basic Graphics to machine learning even with kids who don't even know how to read yet.

It could be that doing numbers is better than letters because there is an example just sitting around for classifying digits at the end of the documentation of Classify (which is just a small line of code).

One tangent here is that I hope to hear more from Jesse about his classifier project (but at this stage maybe email is a better medium) and another tangent is that at last year's summer school to model brain diseases Laura Sainz Villalba used that digit classifier.

I am not sure what the optimal syntax is for Wolfram Alpha but close to making letters with graphics is this geometrical query "line from 1,1 to 1,6 and circle at 2,5 of radius 1" Maybe someone else knows of something better?

POSTED BY: Todd Rowland

Here's an updated version using GrammarRules:

natlanggraphics = 
 CloudDeploy[
  GrammarRules[{DelimitedSequence[
     GrammarToken["GraphicsObject"]]}, {"Coordinate" -> 
     FixedOrder["{", x : GrammarToken["SemanticNumber"], ",", 
       y : GrammarToken["SemanticNumber"], "}"] :> {x, y},
    "PointSet" -> 
     DelimitedSequence[GrammarToken["Coordinate"], {"{", ",", "}"}],

    "Line" -> 
     FixedOrder["line from", a : GrammarToken["Coordinate"], "to", 
       b : GrammarToken["Coordinate"]] :> Line[{a, b}],

    "Point" -> 
     FixedOrder["point at", a : GrammarToken["Coordinate"]] :> 
      Point[a],

    "Square" -> 
     FixedOrder["square at", a : GrammarToken["Coordinate"]] :> 
      Rectangle[a],

    "Rectangle" -> 
     FixedOrder["rectangle from", a : GrammarToken["Coordinate"], 
       "to", b : GrammarToken["Coordinate"]] :> Rectangle[a, b],

    "Polygon" -> 
     FixedOrder["polygon with points", 
       p : GrammarToken["PointSet"]] :> Polygon[p],

    "Circle" -> 
     FixedOrder["circle at", o : GrammarToken["Coordinate"], 
       "with radius", r : GrammarToken["SemanticNumber"]] :> 
      Circle[o, r],

    "Disk" -> 
     FixedOrder["disk at", o : GrammarToken["Coordinate"], 
       "with radius", r : GrammarToken["SemanticNumber"]] :> 
      Disk[o, r],



    "GraphicsObject" -> 
     GrammarToken["Line"] | GrammarToken["Circle"] | 
      GrammarToken["Disk"] | GrammarToken["Point"] | 
      GrammarToken["Square"] | GrammarToken["Rectangle"] | 
      GrammarToken["Polygon"]}
   , AllowLooseGrammar -> True
   ]]


Graphics[Join@{Orange, Thickness[.01], 
   GrammarApply[natlanggraphics, 
    "circle at {3,3} with radius 2; line from {4.5,0.5} to {3,2}"]}, Axes -> True, GridLines -> Automatic, 
 PlotRange -> {{0, 7}, {0, 7}}, ImageSize -> 200]

rudimentary letter Q on coordinate grid

I hadn't really gotten a chance to try out the new grammar construction functions until now, and I'm really impressed. The syntax takes a bit of getting used to, but it seems really powerful. The one peeve I have is that it has to be deployed to the cloud. It's really fairly simple work, and there's no reason other than Interpreter token classification that it couldn't be done locally. And I'm not a huge fan of getting this notification:

out of cloud credits

POSTED BY: Jesse Friedman

You could probably automate the letter verification if you rasterized them and used a small Classify. Then you'd have a whole letter-learning program in just a few dozen lines of code!

On the subject of natural language processing, here's a very simple parser for a series of lines specified in string form:

d = "line from {1,1} to {3,6}; line from {3,6} to {5,1}; line from {1,3} to {5,3}";
Graphics[Join@{Orange, Thickness[.01], 
   Line /@ (ToExpression /@ 
      StringSplit[StringSplit[d, {"; line from ", "line from ",";"}], 
       " to "])}, Axes -> True, GridLines -> Automatic, 
 PlotRange -> {{0, 7}, {0, 7}}, ImageSize -> 200]

capital letter A made with simple natural language processing

I seem to recall that Wolfram|Alpha integration can take some simple graphics instructions and return a Graphics object, but I don't remember the correct syntax.

POSTED BY: Jesse Friedman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract