Category: Apps

Django!

So, I reached a milestone without ever blogging about it: I ‘perfected’ the desktop version of my software.

Note the quotes. Obviously, there’s a lot more it could do, and the interface couldbe a little less clunky (you can tell I just tacked things on as I made them), but the software does what I wanted it to do when I started writing it: It creates PDFs of vocabulary workhsheets for English learners, entirely using hand-made material, but re-using material that’s been used before.

In fact, someone had the idea to add crosswords and wordsearches, and that wasn’t difficult at all. In addition, it will make a nice, alphabetized vocabulary list for the vocab a group has learned.

Arguably, it does more than I had intended for it to do when I got started. And that can only mean one thing:

It’s time to do the django. Since I got about halfway into the desktop version, I realized that it made more sense as a service than anything else, and that the web was the right vehicle for distribution. Imagine if material that I made for my classes could be used in other classes. Imagine if material that my friends and colleagues create for their classes could be leveraged in my classes?

The goal, pure and simple: make it seem like I’m working harder for my students than I am. And the web is the way to do that.

So, I’ve started trying to create a web interface using django. And I’ve been mostly successful. It seems as though very little that I wrote for tkinter can be directly ported without extensive re-writing, but, since I already know how it ‘works,’ I don’t have to figure out how to do it, I just have to adjust it.

Right now, a lot of basic functions have been taken care of, and I have to do a lot of the ‘filler’ work that isn’t so much difficult as… plentiful.

So, look for me to write a bit more about that as time progresses. As well as my insecurities as I go from the pride of working with software that I created myself, to the insecurity of asking my friends to take my software for a spin.

Advertisements

A quick and dirty grammar check in NLTK

So, while working on my app to generate worksheets (update: I’m using it! Like, in practice!) I’ve wanted a way to identify the grammar in a sentence. A quick Google search on doing this in NLTK came up mostly with diagramming sentences and looked more complicated than I am ready to tackle. (Though I will learn!)

So, with a bit of poking around, I found a method that I liked. It works with NLTK’s pos_tag function. And that, in turn, works like this:

>>> import nltk
>>> t = "This is a test."
>>> tokens = nltk.word_tokenize(t)
>>> nltk.pos_tag(tokens)
[('This', 'DT'), ('is', 'VBZ'), ('a', 'DT'), ('test', 'NN'), ('.', '.')]

NLTK actually includes a help interface to help with the ‘DT’ and ‘VBZ’ tags. It didn’t take me long to put together a few ‘patterns’ that basically represented the grammars I was looking for:

self.grammar_lookup = {
            'SIMPLE_PAST': ['VBD', "VBD-did/RB-n't/VB", "VBD-did/VB", "VBD-did/RB-not/VB"],
            'SIMPLE_PRESENT': ['VBZ', 'VBP', "VBP-do/RB-n't/VB", "VBP-do/RB-not/VB", "VBZ-does/RB-n't/VB",
                               "VBZ-does/RB-not/VB"],
            'SIMPLE_FUTURE': ['MD-will/VB', "MD-wo/RB/VB", "MD-will/RB/VB"],
            'COMPARISON_AS': ["RB-not/RB-as/JJ/IN-as", "RB-n't/RB-as/JJ/IN-as", 'RB-as/JJ/IN-as',
                              "RB-not/RB-as/RB/IN-as", "RB-n't/RB-as/RB/IN-as", 'RB-as/RB/IN-as'],
            'COMPARISON_THAN': ["JJR/IN-than", "RBR/IN-than"]
        }

As an explanatory note, the ones with a hyphen in them represent the part of speech tag and the specific word. I did that because I want to reduce the chance of false positives.

From there, it was a fairly straightforward process to start iterating over sentences and looking for these patterns. I’m not especially proud of the code that does this and I think that any serious coder could do it more elegantly, so I’m not going to post that. Still, I’m proud of myself for finding a solution to my problem that works…

…for now. (As you can see, I’ve only tested it on five grammars. I’ll add more as I need them.)

We’re not there yet

There are times when I fantasize about volunteering to help kids learn to make apps. Each time the thought crosses my mind, I’m torn. The shy, insecure part of me says “You need to get more experience, first!” But, another, more idealistic part of me, says “Bah! It would be good for kids to see you learning the same way they are.”

I think that second voice is probably right. But, recently, I’ve been glad that I haven’t volunteered. After all, with the magic of kivy and python, it does seem as though app development is something that you can quickly learn.

Case in point: I was talking to a friend (when the best ideas happen) and had the idea for a different kind of GPS running / biking app. A quick search revealed that Plyer allows access to the device’s GPS hardware. It was literally the work of an hour — including extensive Googling, as I’d fogotten some syntax for individual widgets — to get a first draft done.

With the GPS app, however, I didn’t have any GPS hardware on the notebook I was coding on, so I’d have to do the testing on my phone.

No problem.

Or, so I thought.

First, I was able to compile an APK (that’s apparently what we call the file that you can send to an Android phone to install an app), but it didn’t want to install on my phone. Hmm. That’s the kind of problem enough ‘Google research’ can almost always fix.

Then, it was installing, but not opening. Right. Time to connect my phone to the notebook to run the logcat utility. You’d be amazed at the amount of stuff your phone will output — while it’s just doing nothing — to the logcat. Eventually, though, I found it: Plyer wasn’t included in the APK.

Okey-doke. A bit of searching and an edit to the buildozer.spec file and things were fine.

Fire it up again and. . . it just didn’t compile.

That’s where things were stuck for a while — me looking for terminal commands to update individual pieces of software, installing things, removing and re-installing software, trying again — until today.

Today, I went thermonuclear. I deleted the virtual machine I’d been using to compile APKs and I’m in the (very long) process of installing a new one. If that doesn’t work, I’ll be forced to post a question of stackoverflow (something I’m scared of, because almost every question ever posted seems to be considered a duplicate).

To return to the point of this ramble: sometimes, it feels like we’ve (I mean humanity, not that I had any part of it) made software development so accessible that we must be on the cusp of some sort of revolution. And then, you run up against one of the potholes that hasn’t been filled in yet.

This is not a complaint, by the way. This is all by way of “Gosh, aren’t we lucky that not every step in the process is like this?”

Writing For An App

So, as I move towards a sort of beta (at what point does software become beta?) of the app, I’m becoming more and more frightfully aware of the fact that I’m going to need content to display my idea.

And isn’t that where so many great ideas die?

The idea for the app is great. And, to be perfectly objective, the very general idea I have for content is great: a child talking about how his father goes to work when the child would rather he stayed home, followed by work described by a child who’s only ever been able to ask his Papa about it. And, at the end, the child asks the Papa “Why do you go to work if it’s so bad?” And the Papa can say, “Well, I don’t really like the work. But, I get money if I go, and there are a lot of things I like to do with you — from simple things like eating, to more fun things like going to the swimming pool — that I can only do with money.”

And, yeah, that long last sentence is currently how it goes. I’m not crazy about it (translation: I know it’s bad).

That’s what I’m talking about. As I write, I try my hardest to not think about the need to illustrate everything, but it’s not working. I write three sentences and think “I don’t know what should be happening on the screen during this time.” And the story suffers, because I seem to feel a need to work in as many things that I can get a doodle for as possible.

It’s not good writing. And it’s not going to make it into the app. What I’m wondering is whether it’s an inevitable step in the development process.

The To-Do List

This seems like a pretty big project to me. So big, in fact, that I’m ready to bring in outside help: I’ve already contacted an illustrator and asked if she would be willing to do the illustrations, should I send her a proof-of-concept that she finds convincing. The answer was a “yes,” but a tentative one.

So, outside of the ‘simple’ act of coding, I see several things for me to be working on:

  • Defining what a ‘success’ will be in this project. It has to be more than just a working app, as I don’t think I can afford to pay an illustrator just to prove that I can make the app. And I certainly can’t expect her to work without some sort of reward. What are we working towards?
  • Deciding if this thing is going to cost money? That’s obviously a subset of whether or not I want it to make me money, or if I’m doing all this just to prove that I’m cooler than the next guy. (Still a worthwhile goal, but is it enough?)
  • Researching how to get my app in front of a few eyeballs. I get that it can get lost in the Play Store, but how do I get the people who would be interested in it to see it?

I genuinely love the idea of seeing an idea that I had realized. Sure, it’s not something physical in the traditional sense, that I can frame and put up on the wall. But, nonetheless, it would be something I could point to and say “See that? I had that idea and I made it happen.”

On the other hand, I sense that success is going to require more than just a finished project. And the idea of marketing my idea, of being forced to try and convince people to look at what I made, well, that’s the part of this project that I’m looking forward to the least. Forget the tedium of trying to figure out why my code isn’t doing what I think it should be doing, this will be the hardest part of the project for me.

And that means it’s the part that I need to work the hardest on.