4 ms·
Ask HN: Transmoggit (aka "HTF is trim in Python?"); What next?
Hey all,
After inerte's post a few days ago: http://news.ycombinator.com/item?id=446507, I thought I'd use it as an excuse to fiddle with GAE and jQuery.
With props to Bill Watterson [1], I banged up "transmoggit": http://www.transmoggit.com/
(try something like "trim" from PHP -> Python, as an example chosen not-at-all-at-random)
It does the obvious mapping thing, and lets you add your own. That's all fine, I guess, but it's not super-useful, until the 2.0 bit kicks in and "people" start adding clever translations. Of course, no one will bother to amend translations until there's some reason to visit first.
So, my question for the wise crowd: any suggestions on how to automate getting sensible mappings for, say, the easy 50-80%?
(any other suggestions are quite welcome too :)
thanks,
scott
1. http://www.geocities.com/Hollywood/Theater/9876/transmog.html
- s3graham 18y agoAnd linkage for the lazy: http://news.ycombinator.com/item?id=446507 http://news.ycombinator.com/item?id=446507 http://www.transmoggit.com/ http://www.transmoggit.com/ http://www.geocities.com/Hollywood/Theater/9876/transmog.html http://www.geocities.com/Hollywood/Theater/9876/transmog.htm...
- jgfoot 18y agothis is awesome. Automating the first 50-80%? Try some very simple natural language processing, with a human being acting as a sanity check. If the PHP documentation for a function is "upper case" and the Python documentation for something also is "upper case," then the two might be similar...
- s3graham 18y agoHmm, sounds interesting. In practice, I'm not sure what it looks like. I wonder if something like "minimum number of edits" would work? Probably not, I guess since that's more like a "diff" and the docs are not likely to be similar in that way. Perhaps just "the function who's documentation uses the most same words", stripping common words? Perhaps that could be improved a bit via synonyms too.
- inerte 18y agoHey :) - A submit button; I typed "trim" and it did nothing :p Had to change language's dropdown or click a suggestion; - SEO! There's no unique url, with proper title, for the entries. None searching for "trim in python" will find... my blog post is getting 2 or 3 visits a day from people searching "python trim" and/or "trim in python". And I am not even on the first page. Aactually depending on my browser and language settings, I am (5th result). - Filter duplicates (I entered string.strip is PHP's trim twice) - Suggest the relationship the other way around. If you know that trim == strip, why not say "hey we think strip == trim"? How to automate? Do some similar text search thing. For example, you can get the function definition for trim() on PHP's manual, if you match against sections of Python's manual, you can offer your visitors suggestions, and let them one click away to approve the connection. Easy to do?... Anyway, it's soooo nice to see someone implemented HTFITIP... and I really liked the clean design! And the name!
- s3graham 18y agoOops, no "submit" wasn't well tested obviously. Dumb! I was always selecting an item from the autocomplete. SEO + filter, good ideas, will do. reversed mapping: it does try to do this a little, can you describe what didn't work for you? For example, "str.lstrip" as Python->PHP doesn't have the exact answer, but does look in the other direction and you get a suggestion.
- inerte 18y agoSo I just entered len() for PHP's sizeof(), and when I searched the other way, I got a suggestion... But I am pretty sure that when I searched strip in PHP, nothing came up. I don't remember if I clicked a suggestion item or I selected a language from the second dropdown. That might be the problem, since I think you're mapping string.strip() to trim(), and not strip() to trim(), which is understandable :) Maybe a LIKE %% search instead of =?
- s3graham 18y agoAh, that's probably it. Thanks, I'll look into it more carefully.
- mattmcknight 18y agoIt looks like a hard part is going to be method scoping. For things that aren't in the global namespace, it's sort of hard to give a single answer, because you are asking two questions (e.g., which object or module and which method or function?). It might be better to pick the object/module first, and then the method/function.
- s3graham 18y agoI felt like it was probably always method/function name that you would care about. That was mostly based on the assumption that similarly named methods on any object do similar things, at least in the language's standard libraries. Did you have a specific language/module/class/method (or set of them) in mind?
- jonursenbach 18y agoThis is pretty sick. Nice job.
- ctice 18y ago"Shucks, the transmogrifier doesn't know what PHP's count is in PHP." hehe
- s3graham 18y agoheh, I tried to fix that in the UI (the wrong place, obviously). There's some browser that doesn't do <option disabled> I guess? Perhaps a sarcastic answer is the best solution. ;)
- SapphireSun 18y agoAwesome! I couldn't figure out how to submit it though :( I know it's probably a bad idea, but I feel wistful for the original "How the fuck is ___ in ___?"
- andr 18y agoWhat about Scala?
- s3graham 18y agoSure, I'll try to add it. I don't personally use Scala: what reference would you like to see? http://scala-tools.org/scaladocs/scala-library/2.7.1/ http://scala-tools.org/scaladocs/scala-library/2.7.1/ or is there something better?
- tow21 18y agoAny chance of adding Javascript as an option? I spend half my life tripping up over Javascript/Python inconsistencies, this would be immensely useful. Also, I'm not convinced your google account sign in thing works right; I clicked on it to login to google, and then google didn't know where to redirect me to.
- s3graham 18y agoYeah, JS vs Py drives me crazy too. JavaScript is high on my todo list. Just need to find the "canonical" reference for it. I can't reproduce the login problems? Non-gmail.com acct? Browser/OS matter?
- revorad 18y agoThis is awesome. What about VB? :-P
- mseebach 18y agoFirst impression: Nowhere near enough swearwords :) Also, if I type "trim" and hit enter, I get imagick_trimimage. If there's an exact match, I very much probably want that.
- s3graham 18y agoThanks, will do (the second part anyway :). I'm using jQuery's autocomplete but it's maddeningly broken in those sorts of subtle ways.