Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Software to transform sentences

  1. Dec 14, 2013 #1
    I want to build some software that will transform a formal language from one set of symbols to another. What would be the best software to do that with. Here is one example of what I want to do:

    Say we have

    (x'Hy) BC (x'Hz)

    I need an algorithm to transform that into:

    ((w'Hp) IDx'-z) A ((w'Hp) IDx'-y)

    What that means is: x becomes y means something identifies x with z after something identifies x with y.

    where x' y z w' and p are variables - the apostrophe mark is a part of the variable.

    Here's how I explain the algorithm:

    That which comes before a capital letter is the subject and that which comes after is the object, so in xHy, x is the subject and y is the object. In (xHy) CA (zHw) x is the object of H which is the subject of CA and z is the subject of H which is the object of CA.

    Change BC to A
    replace the subject of BC with its object and replace its object with its subject, in other words:
    (xHy) BC (zHw) would become
    (zHw) BC (xHy)
    replace H with -
    place an ID before the old subject of H, in other words:
    xHy would become IDx-y
    insert a subject before the ID on both sides of the A and the subject must be the same on both sides of the A. The subject must an H and the subject and object can be any variable so long as it is not used. And it also must come between the left parenthesis and the ID
  2. jcsd
  3. Jan 13, 2014 #2
    I remember I used Perl when I wanted to play around with strings a few years ago. C++ is more elegant, but back then I found Perl's handling of strings easier to work with (for the purposes of what I was trying to do, at any rate, which was comparing two strings and pointing out the differences and calculating the degree of similarity).

    Sorry I can't be more helpful.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook