Slashdot Mirror


Metafor: Translating Natural Language to Code

vivin writes "Computer programming is second nature to most of the Slashdot crowd. However, this is not true for the vast majority of people. Formal programming languages are not as expressive or flexible as natural languages. This becomes more evident when we try to translate user requirements into actual code. Researchers at MIT have come up with a program that bridges this gap. It's not so much a tool that turns English into code, as it is a program that translates requirements (in English) to code. When Metafor analyzes English, nouns phrases become objects, verbs become functions, and adjectives become object attributes (or properties). In addition to helping programmers visualize their program better, I think it also promotes writing concise (and therefore) requirements and descriptions. Metafor doesn't handle run-on sentences (or bad English) that well." Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement.

35 of 475 comments (clear)

  1. Usefulness by suso · · Score: 5, Insightful

    Well, I doubt something like this would be used to write the next version of Gimp, but I can see its use in helping people to convey what they want a computer to do. Few people need to write programs and I don't know whether I'd want people who don't
    understand computers to actually write them. But it would help when someone wants to make something like a 3D scene in Blender. It reminds me a lot of that episode of STTNG (Schizims) where Riker, Troy and Worf are telling the computer to replicate an alien room that they were in.

  2. Very Cute by AKAImBatman · · Score: 5, Insightful

    While this is a cute concept, I don't think you'll be seeing computer programmers disappearing any time soon. The natural language bent was the original point of high level languages. Early languages like COBOL, SNOBOL, and BASIC were all designed to abstract programming to a level of natural language. Save for BASIC's success as a beginner's language, none of them accomplished their goal. In fact, the "natural language" design of COBOL only served to complicate the language and cause a variety of errors due to missing periods, improper spacing, and other common typing mistakes.

    It wasn't long before it was reul languages actually broke away from English and relied more heavily on easily-parsable, special characters to define structure. We can see the results of this in today's C/C++, Java, LISP, PERL (bleh), and Python languages. This new interface does nothing but try to perform some of the structural thinking done by the programmer. (Although I have my doubts as to its current real world ability.)

    So the question that then comes to bear is, "Who would use this natural language interface?" Sadly, the answer is most likely "programmers". But why would a programmer use this interface if he has to be trained in computer logic in the first place? It would seem like an unnecessary level of abstraction that would only serve to hinder a programmer's natural abilities.

    Of course, there is the documentation issue. Supposedly this interface will be useful for producing requirements in addition to code. But who produces the requirements? Not the programmer. That's usually the job of the business analyst, someone who may not even have experience with coding logic. And for code documentation, nothing quite beats the JavaDoc style documentation that has become popular in the last few years.

    I think that research like this is interesting, but I doubt it will have many uses until AI and voice recognition improves to a level similar to that seen in Star Trek. Only about 300 more years and counting. ;-)

    1. Re:Very Cute by AKAImBatman · · Score: 4, Informative
      My guess is that if you're having trouble wrapping your head around OOP, then you're going to have trouble wrapping your head around the ins and outs of a natural language interface.

      For what it's worth, OOP is quite easy. The first thing you need to think is data encapsulation. Data encapsulation is simply the practice of bundling related data together. i.e. Color, make, year, and model are all attributes of a car. So you'd tend to put them together. You know, like structs. For example, a game sprite might have x, y, width, height, and direction variables.
      class Sprite
      {
      int x;
      int y;
      int width;
      int height;
      int direction;
      }
      Of course, we want to know what the direction stands for, so we add static constants:
      class Sprite
      {
      const RIGHT = 0;
      const LEFT = 1;
      const UP = 2;
      const DOWN = 3;

      int x;
      int y;
      int width;
      int height;
      int direction = RIGHT;
      }
      Now for the truly OOP part. We need a way of making the data operate on itself. For an example, I'll choose changing direction.
      class Sprite
      {
      const RIGHT = 0;
      const LEFT = 1;
      const UP = 2;
      const DOWN = 3;

      int x;
      int y;
      int width;
      int height;
      int direction = RIGHT;

      void changeDirection(int dir)
      {
      direction = dir;
      }
      }
      Doesn't seem like much, but what if we want to ignore improper directions?
      class Sprite
      {
      const RIGHT = 0;
      const LEFT = 1;
      const UP = 2;
      const DOWN = 3;

      int x;
      int y;
      int width;
      int height;
      int direction = RIGHT;

      void changeDirection(int dir)
      {
      if(dir < 0 || dir > 3) return;

      direction = dir;
      }
      }
      In a real OOP program, we'd probably throw an exception, but you get the idea I hope. Now that we have our Sprite class, it can be treated as a complete data type of its own:
      Sprite sprite = new Sprite();

      sprite.changeDirection(Sprite.DOWN);
      There you have it. A five minute introduction to OOP. Hopefully this will help unblock whatever mental issue is in your way. (Or badly written books as the case may be.) :-)

      (Stupid lameness filter. Recognize code will you? No, that would be too difficult wouldn't it? Stupid lameness filter. Did I mention how stupid the lameness filter is? Recognize code will you? Stupid lameness filter. Recognize code will you? Stupid lameness filter. Recognize code will you? Stupid lameness filter. Recognize code will you? Stupid lameness filter. Recognize code will you? Stupid lameness filter. Recognize code will you? Stupid lameness filter. Recognize code will you? Stupid lameness filter. Recognize code will you?)
  3. I can imagine... by JamesP · · Score: 4, Funny

    Verbs translated to functions?? Nouns to variables??

    int jerk_at_counter, hottie_in_accountancy, dork_at_it;

    kill(boss);
    send(intern,hell);

    Yeah, that will work...

    --
    how long until /. fixes commenting on Chrome?
  4. Great! by Eusebo · · Score: 5, Funny

    Now all we need is a tool that will take a user's brain and turn it into solid requirements.

    --
    It is quite simple
    Haiku should not be funny
    Try a Senryu
  5. of little value here! by hugesmile · · Score: 4, Funny
    Metafor doesn't handle run-on sentences (or bad English) that well."

    Forget it being a tool for this crowd then!

  6. Re:Dupe by Anonymous Coward · · Score: 5, Funny

    I'm about to write a program that stops dupes:

    "Don't allow dupes."

    There, now I have to decide whether it will be FOSS.

  7. It is coming to pass... by HaeMaker · · Score: 4, Funny

    "Make it possible for programmers to write programs in English, and you will find that programmers can not write in English."

    http://www.murphys-laws.com/murphy/murphy-comput er .html

  8. Because the average joe wants to be a programmer? by Proc6 · · Score: 5, Funny

    Yeah, I know my neighbor with an IQ of 7 would rather be writing code that parses XML work orders and turns them into statistical graphs than watching NASCAR. It's just that complicated Java syntax kicks his ass so he's kicking back with a 6 pack of Black Label waiting for this technology to come out.

    --

    I'm Rick James with mod points biatch!

  9. Doomed to failure by rde · · Score: 4, Insightful

    I don't mean to sound pessimistic, but remember who comes up with functional specs; managers. As a consequence, this poor program may well come up with a framework that matches exactly what was requested, but once it's put together, the suits will say "it doesn't do this". When it's pointed out that that wasn't in the spec, the inevitable response will be "but it was implied; it should be obvious that we'd need it to do that." This is just a core dump waiting to happen.

  10. you must be new here by avi33 · · Score: 5, Funny

    Computer programming is second nature to most of the Slashdot crowd.

    Maybe back in 1998, but haughty sniping is second nature to most of the Slashdot crowd now.

  11. With All Due Respect... by schestowitz · · Score: 4, Insightful

    I wish that people spoke mathematically rather than poor and ambiguous languages that can now (supposedly) turn into (ambiguous) code. Can one really rely on translated 'code' like this. That's like sending an E-mail from speech-to-text recognition without proof-reading.

    --
    My Linux - (L)ove (I)s (N)ever (U)tterly eXPensive
  12. Rules by igny · · Score: 4, Interesting

    How hard is it to change rules of treating the sentences? Can Metaphor learn Chinese, for example?

    --
    In theory there is no difference between theory and practice. In practice there is. - Yogi Berra
  13. Doomed to fail? by PissingInTheWind · · Score: 4, Interesting

    From Dijkstra's timeless "How do we tell truths that might hurt?":

    Projects promoting programming in "natural language" are intrinsically doomed to fail.

    He said that 30 years ago. People still don't listen.

    --

    A message from the system administrator: 'I've upped my priority. Now up yours.'
  14. Have Kylie stripped washed and brought to my tent by Timesprout · · Score: 4, Funny

    waiting...
    waiting...
    waiting...

    Stupid computer doesn't do anything I tell it

    --
    Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
    What truth?
    There is no dupe
  15. I don't think so by gowen · · Score: 4, Funny
    Computer programming is second nature to most of the Slashdot crowd
    Spoken like a man who's never looked at SlashCode.
    --
    Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
  16. the old is new again by dubl-u · · Score: 4, Insightful

    While the logic of the researchers' interpreter tackles only about 20 percent of the problem of full natural language programming, it achieves about 80 percent of the perceived rewards.

    Ah, this old thing again.

    The hard part about programming isn't turning basic English text in to half-assed code. If it were, then Google have built their company on just-out-of-college scripters and Visual Basic.

    [Liu says] "Many subjects immediately identified the simplistic interpretation of the interpreter, and wanted the opportunity to rephrase their original wording to fix the error."

    Yes, regular English is insufficient for programming. If a tool like this becomes popular, you'll need still need a special class of people to figure out what is needed and to figure out how to phrase the desire in the precise way that makes this guy's interpreter actually do what they want.

    In other words, he hasn't invented a way to eliminate programming or programmers. He's figured out a way to make a programming language that is slightly easier to learn at first. But because it's removed from what computers actually do, much harder to use for anything serious. The hard part about programming isn't the month you spend learning Java syntax, it's the many years you spend learning to write code well.

    Their theory appears to be that this will make programming easier to learn. I wish them the best of luck in that goal, but having seen over the years a number of graphical and natural-language programming tools vanish without a trace, I'm not holding my breath.

  17. Re:Ebonics? by Gzip+Christ · · Score: 5, Funny
    Hey brudda, how long beefo it be talkin ebonics yo?
    There is already a programming language for programming in Ebonics. Be sure to check out some of the sample programs - they are true masterpieces.
  18. Re:Other uses? by AKAImBatman · · Score: 4, Interesting
    Just a thought, but wouldn't it be easier to produce a specialized programming language for this? The instructions could then be pivoted into either a readable recipe, or commands for a robotic machine. Something like this:
    Ingredients
    {
    2 egg;
    1 tsp vanilla;
    4 cups flour;
    }

    Equipment
    {
    mixing bowl;
    oven;
    12x6 inch pan;
    }

    Directions
    {
    preheat oven 450 degrees farenheit;

    break 2 egg into mixing bowl;
    pour 1 tsp vanilla into mixing bowl;
    pour 4 cups flour into mixing bowl;

    mix mixing bowl;
    pour mixing bowl into 12x6 inch pan;
    place 12x6 inch pan into oven;

    bake 15 minutes;
    }
  19. What about the other way around by El+Cabri · · Score: 4, Insightful

    Firstly, people for whom programming is too complicated should not code at all. We need less programmers building better code, not more programmers adding to the crap heap that the software legacy is as of today.

    Secondly, I think that what is needed is the other way around : automated analysis of code and production of natural language reports that designers could browse more easily than the code itself looking for bugs or designing extensions and additionnal feature. They would then intervene directly on the code itself.
    Sort of a souped up version of Knuth's literate programming, only with a much more radical transformation of the code for its vizualisation, bringing up the essential and critical aspects.

    Think of how a reasonably complicated mathematical proof, say within the formal set theory, would look like in a math paper or book meant to be read. Compare with how it would be coded in a theorem prover. Different. Yet the former can be automatically generated from the later.

  20. Re:Dupe by FortKnox · · Score: 5, Insightful

    No fears, he's issued an update:

    Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement.

    Nice. Someone should go to customer service 101 and grow up a little. Yelling at the people who (indirectly) line your wallet. Not a good idea....

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  21. Update by Espectr0 · · Score: 5, Funny

    Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement.

    Ah, yes! Duping words next to each other, that is the new fad. Because duping articles is so yesterday's news

  22. Poor Taco by p3d0 · · Score: 5, Insightful
    Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement.
    All together now: "Aaawwwwwwwww".

    I've never been one to complain about dupes. I figure I already get way more than I pay for from this site (which is zero). But if people are frustrated about dupes, maybe it's because it's an exceedingly simple problem to solve, and the Slashdot editors give every appearance of not bothering to lift a finger to solve it.

    --
    Patrick Doyle
    I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
  23. Re:Dupe by FortKnox · · Score: 4, Insightful

    To actually add content to my content:

    How terribly difficult would it be to add a url checker. I can understand a dupe when its an article written differently by two publications, but a simple URL checker can state "this url was used in store XYZ [with link]," so the editor can determine if its a dupe story or just a url used in two different stories...

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  24. Time flies like an arrow by Viking+Coder · · Score: 5, Interesting

    When a Harvard natural language parser was given the phrase "Time flies like an arrow," in the 1960s it identified the following five parse trees in reponse.

    1) Time proceeds as quickly as an arrow proceeds.
    2) Measure the speed of flies in the same way that you measure the speed of an arrow.
    3) Measure the speed of flies in the same way that an arrow measures the speed of flies.
    4) Measure the speed of flies that resemble an arrow.
    5) Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    I would guess the source code for those five different interpretations would be, well, different. (The fifth one is my favorite.)

    --
    Education is the silver bullet.
  25. About your update, Taco by festers · · Score: 5, Insightful

    Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement.

    Taco, you asshole, you've been duping stories for years. You've known about them and yet you've done nothing to fix the problem. Don't pull this sentimental BS about not "encouraging" improvement. If the fact that if Slashdot is your creation, and is your job, isn't enough "encouragement" for you to fix the problem of dupes, I don't think anything will be. From all appearances, it looks like you've given up on /. years ago.

    --


    -------
    "Every artist is a cannibal, every poet is a thief."
    1. Re:About your update, Taco by exp(pi*sqrt(163)) · · Score: 5, Insightful

      Maybe he could just tell us what does encourage improvement. Sending fan mail every time a story that isn't a dupe is posted?

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    2. Re:About your update, Taco by Tim+C · · Score: 5, Interesting

      Seems to me that a slashdot employee has one or more of four duties:

      1) pick stories to post
      2) sell advertising
      3) maintain the servers
      4) design and implement additions, bug fixes, etc

      Now, I'm not a subscriber, but I don't see much in the way of 4), even for features that the readership is crying out for, or that make financial sense for slashdot (such as moving to CSS for layout). I thought that /. got most of its advertising through the OSDN network, so I'd imagine that 2) is more or less minimal (and with /.'s fame, shouldn't be too hard anyway). That leaves 3) and 1). I have no idea about the time requirements of 3), but I can imagine that it might keep a couple of people busy full time.

      That seems to me to leave an awful lot of time left over for 1), picking stories to post. And yet, it seems like every day or two there is a dupe, every week or so there is a downright inaccurate (or even lying) summary or headline posted, and every month or so something that's accurately summarised, but the source is just plain made up or wrong.

      I know that the FAQ states that the editors don't check the stories for factual correctness, but Taco (et al) I ask you this: what do you do all day?

  26. Re:Dupe by phasm42 · · Score: 4, Funny

    I like how he duped the word "for" in his comment: Update for for the dupe.

    --
    "No one likes working in a hamster wheel, and your shop smells of cedar shavings from here." - TaleSpinner
  27. Re:Dupe by 1u3hr · · Score: 5, Insightful

    Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement.

    Is he drunk or something (For for??) At least we know he reads the hate mail, so send more. Ignoring stupid avoidable fuckups certainly doesn't work.
    They can either
    1) implement a simple function that compares the main words in the article with recent ones, particularly URLs (ignoring some obvious generic ones, like the home page of newspapers). (For extra credit, spellcheck the fucking thing, and check that any URLS exist.)

    2)Read the mail that comes in from subscribers telling them they've duped (apparetly that's mostly ignored; when I send it in it often bounces, some editora apparently have invalid forwardnig addresses)

    3)Or use their own brains and just type one relevant word into the Slashdot search box:
    Search 'metafor'
    Metafor: Translating Natural Language to Code
    On March 30th, 2005 with 170 comments
    vivin writes "Computer programming is second nature to most of the Slashdot crowd. However, this is not true for the vast majority of people. Formal...

    English To Code Converter
    On March 26th, 2005 with 52 comments
    prostoalex writes "Metafor from MIT is a code visualization utility, capable of converting high-level descriptions into class and function (or method...

  28. Dupe checking is a not a technical problem. by Inoshiro · · Score: 4, Insightful

    "Update For for the dupe. Not going well. Appreciate all the hate mail. Really encourages improvement."

    At LWE in January, 2001, at a conference on Slashcode, someone asked us at Newsforge how our site had so few dupes compared to Slashdot. There were two reasons:
    1) We had a smaller audience of people to see the dupes we did accidently post.
    2) We searched our archives before posting any story. We searched by story URL, by story keyword. We also generally skimmed the site when we weren't working to be aware of what was being posted.

    Clearly, #1 is something Slashdot doesn't have working in its immediate favour, but #2 is something that shouldn't be too hard. Zonk, Timothy, Cliff, Simonker, etc, don't post dupes nearly as frequently as CmdrTaco. Hemos doesn't post often, but he also seems to be pretty dupey (understandable as he's not really associated with /. anymore, and wouldn't be familiar with what's been posted).

    The worst example is something like the PSP dupe story: Taco didn't even check out the games section, which had that story right at the top! A simple search for "PSP" and "Browser" would've shown it even if he never reads sections.

    CmdrTaco doesn't read his own site. What does this tell you about how he feels about it?

    I don't read Kuro5hin much anymore for the same reason. Complaining about dupes will just drive him further away, even though he still has to work on it by contract.

    --
    --
    Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.
  29. It's actually sorta important! by SPYvSPY · · Score: 5, Insightful

    It really bugs me that /. editors treat dupes as a sort of charming fact of life, as if dupes are among those imperfections that make life worth living. Dupes suck, if for no other reason, because they fork discussion, confuse the archive and make searches less precise.

    It's especially annoying when the dupe article proclaims that the /. crowd is able to code by second nature. How f-ing hard is it to have a dupe checker (even a simple on like what FortKnox is proposing). Why is it that a website that proclaims itself the bastion of all things FOSS has languished in mediocrity while thousands of competent coders are practically begging to write this feature into the site's backend? Of course, nothing will come of this, except more shoulder-shrugging and gee whiz, golly nonsense. I'm not trying to flame, but this sort of unprofessional, "friendly fuckup" attitude is what holds the public image of FOSS back.

    1. Re:It's actually sorta important! by dmd · · Score: 5, Insightful

      The point is that such patches have been submitted, by dozens of people - people who are very talented, and who have a great deal of experience running and modifying Slash.

      Slashdot is not interested in applying these patches, because dupes mean more angry posts, and angry posts mean more pageloads, and more pageloads mean more ads served.

    2. Re:It's actually sorta important! by A+beautiful+mind · · Score: 5, Interesting

      Dear CmdrTaco!

      Please state your requirements about a dupe checker, between realistic boundaries.
      Things like - integration into the accepting stories interface seamlessly, spamassassin style dupe detector with a point based system, or even coding bayesian algorithms - are possible.

      I'm willing to (help to) code it. With two conditions. You'll apply it and use it. If this happens i'm predicting a serious decline in dupe stories and posts.

      If you fail to do this or you're not interested in this offer, then STOP being pissed, put up with the hate mail, the accusations about ad revenues, and use the bloody search function.

      Just to make sure this offer reaches you i'm going to mail it to you, and continue to do so - in regular periods - until i get some kind of reply, either a yay or a nay.

      Yours, a beautiful mind

      --
      It takes a man to suffer ignorance and smile
      Be yourself no matter what they say
  30. Re:Dupe by snorklewacker · · Score: 5, Insightful

    > How terribly difficult would it be to add a url checker

    These are paid editors who can't be bothered to read their own website. The problem is not technological, and doesn't require a technological fix.

    --
    I am no longer wasting my time with slashdot