Feature requests: allow for more than one example.
Input:
{"class": "101", "students": 101}
{"class": "201", "students": 80}
{"class": "202", "students": 50}
{"class": "301", "students": 120}
Example:
Class 101 has 101 students
Output:
Class 101 has 101 students
Class 201 has 201 students
Class 202 has 202 students
Class 301 has 301 students
Right now the first line cannot have any ambiguity. This is fixable by reordering, but with large enough data sets I may have some ambiguity in all lines, at different places. Multiple examples would fix that.Again, loved the tool. I can see this going very far, specially with non-technical people.
It's one of many missing features.
Excel is to finance people as terminals are to developers. When getting bug reports from end users, we've even had them delivered to us as screenshots embedded in Excel files.
Same for Kagawa -- the Japanese use surnames in a different way, might be simpler to replace him.
http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-17...
edit: see below
http://en.wikipedia.org/wiki/Programming_by_example
Sketching means to provide a partial specification, of which details are filled in by the system. But in this case, the user is providing a full description of a single concrete example. These are different concepts.
Also, your instructions makes it seem like the example is editable:
SUPER EASY TO USE 1. Paste your source data in the white box on the left.
2. Type in the green box on the right how you would like the first line of your data to look.
3. Transformy will look at your example and transform every line from your source data into the same format.
http://example1.org/path/index.html
http://www.example2.org/path/index.html
http://www.example3.org/
https://www.example4.org/a/b/c/d/e/f/g/hijklmnop
The pattern I gave was: example1.org, path/index.html
So I expected to get: example1.org, path/index.html
www.example2.org, path/index.html
www.example3.org,
www.example4.org, a/b/c/d/e/f/g/hijklmnop
Instead, I got: example1.org, path/index.html
wwwexample.2, org/path.index
wwwexample.3, org/.
wwwexample.4, org/a.b
A few feature requests: allow downloading the output as a text file; show a pseudo-code formula of how transformy interpreted the transformation, like "s/.+:\/\/(.+?)\/(.*)/\1, \2/"; and add support for common arbitrary transformations like "November"↔"NOV"↔"11", or "2"↔"2nd".For example, if the rules were: example content must be contained within braces, and any braces within the example content need to be escaped, it's clear. At that point, your example becomes:
{example1.org}, {path/index.html}
It would still probably just return "wwwexample.4, g/hijklmnop" for the last example though, because it's ambiguous as to whether you want just the end of the url, or the whole thing. Allowing regex markup for more explicit matching would make it clearer still, but your example still causes problems until you go all the way to positive lookbehind assertions. At that point I need to learn all that, I might as well just use perl: # perl -pe 's{.*https?://([^/]+)(/\S*).*}{$1, $2}' /tmp/foo
example1.org, /path/index.html
www.example2.org, /path/index.html
www.example3.org, /
www.example4.org, /a/b/c/d/e/f/g/hijklmnop @(repeat)
@proto://@domain/@path
@(do (put-line `@domain, @path`))
@(end)Feedback and suggestions are very much welcome! We plan on adding a few more features soon as right now it is fairly basic but would like to hear some opinions and see if there's people out there that have a use for this.
It doesn't seem to play will with something like this as an input:
3, Roberto/Carlos, soccer, Brazil
35, Roberto/Carlos Michael Jordan, baseball, USA
6, Roberto/Carlos James Lebron, basketball, USA
10, Roberto/Carlos Shinji Kagawa, soccer, Japan
Format: 3, ROBERTO/CARLOS, soccer, Brazil
Gives me: 3, ROBERTO/CARLOS, soccer, Brazil
35, ROBERTO/CARLOS, Michael, Jordan
6, ROBERTO/CARLOS, James, Lebron
10, ROBERTO/CARLOS, Shinji, Kagawa
I can't seem to find a way to get it to parse that out properly (playing with the ROBERTO/CARLOS part.I even tried this as an input:
3, Roberto Carlos, soccer, Brazil
35, Roberto Carlos Michael Jordan, baseball, USA
6, Roberto Carlos James Lebron, basketball, USA
10, Roberto Carlos Shinji Kagawa, soccer, Japan
Format: 3, ROBERTO CARLOS, soccer, Brazil
Gives me: 3, ROBERTO CARLOS, soccer, Brazil
35, ROBERTO CARLOS, Michael, Jordan
6, ROBERTO CARLOS, James, Lebron
10, ROBERTO CARLOS, Shinji, Kagawa
Edit: formathttp://linux.die.net/abs-guide/x19673.html
It took me about a year of use before I could figure out how to munge lines in it, so it's definitely not for the faint of heart. I use it for things like transforming excel spreadsheets into C struct arrays.
On the first line, you have "Roberto Carlos" followed immediately by a comma. On subsequent lines you have Roberto Carlos followed by two other names.
Also your example works fine if you use a different delimiter for your format vs for your input, e.g.
3 | ROBERTO CARLOS | SOCCER | BrazilThat difference would change the kind of examples I would try it with, knowing in advance when they're too complex to work.
1 Microsoft Way Apt 43, Redmond, WA 98065, U.S.A.
1-1/4 Palm Hwy, Colino, MA 87009, USA
500 Potasium Cloride, Sunshite-Big Blow City, PA 30000, United States of America
First line output should look like: 1 Redmond 98065 U.S.A.
Also having country-specific obscure sports terminology on landing page example can cause lot of confusion.https://www.mjt.me.uk/posts/falsehoods-programmers-believe-a...
In:
3, Roberto Carlos, soccer, Brazil
35, Michael Jordan, baseball, USA
6, James Dean Lebron, basketball, USA
10, Shinji Kagawa, soccer, Japan
Ex: Carlos is number 3 playing soccer
Out:
Carlos is number 3 playing soccer
Jordan is number 35 playing baseball
Dean is number 6 playing Lebron (what??)
Kagawa is number 10 playing soccer
I guess you can't really solve the ambiguity of Carlos meaning the second word on the second column versus the last word of the second column; but the commas should at least hint a tabular pattern, no?We often process messages with hundreds of fields. So I will have a class from specs (usually excel) with a number of properties, then I need a method to populate each of those from some other object, then I need a method that does the reverse - populates some other object from the properties.
This happens over and over for us. Typically I just use a Notepad++ macro. But I could probably use this as it stands, just having it in visual studio would be really incredible.
Input:
Feature: 37, threshold: 4386, +
Feature: 11, threshold: 1, +
Feature: 10, threshold: 13, +
Feature: 0, threshold: 34, +
Feature: 39, threshold: 44, +
Example:
x[37] >= 4386
Output:
x[37] 4386
x[11] 1
x[10] 13
x[0] 34
x[39] 44We'll fix this soon.
I have a small piece of feedback on the site. You could make it a tiny bit clearer that this is a free, registration free, service which people can start using with just one click.
When I first visited the site, I looked it over, noticed the email box and the "get started" and just assumed it was a library I'd need to buy. It wasn't until I came back to the comments here that I realised the site was a service (which is actually extremely useful to me, and it has been bookmarked).
Why not just make http://www.transformy.io/#/app your homepage instead?
But you are right that we should make it more clear that it's free. Thanks!
For example, I added some information in the example below about which pronoun to use based on gender. Would be really neat to have this sort of information built into the tool.
Input:
{name: "James", age:"30", hobby: "running", genderWord: "his"}
{name: "Erin", age:"28, hobby: "cooking", genderWord: "her"}
{name: "Owen", age:"3", hobby: "playing chase", genderWord: "his"}
{name: "Luke", age:"1", hobby: "reading", genderWord: "his"}
Example:
James is 30 years old and his favorite hobby is runningOutput:
James is 30 years old and his favorite hobby is running
Erin is 28 years old and her favorite hobby is cooking
Owen is 3 years old and his favorite hobby is playing chase
Luke is 1 years old and his favorite hobby is reading Input:
{"message":"hello there","id":1}
{"message":"why hello there","id":2}
Example:
{"id":1,"message":"hello there"}
Output:
{"id":1,"message":"hello there"}
{"there":id,"message":"why hello"}But it doesn't seems to look properly at the meaning of content though.
I mean, I think it just finds the first presence of what the given pattern is and generates the result.
For example, I attempted this, with input data as date/time.
input data:
2015-09-15T09:15:17-05:00
1998-11-05T08:15:21-05:00
1999-01-03T04:33:30-05:00
2000-11-05T09:16:00-05:00
pattern: 09:15 on 09-15
result: 09:15 on 09-15
11:05 on 11-05
01:03 on 01-03
11:05 on 11-05
What I was expecting: 09:15 on 09-15
08:15 on 11-05
04:33 on 01-03
09:16 on 11-05
Although I helped it at certain level by using the same special character pattern the input data has.And as I was afraid, it doesn't handle special characters, neither uses them in the process either, as @j2kun has mentioned in a comment.
But, it is promising at some point and have nice use cases too. :)
@(collect)
@year-@month-@{day}T@hh:@mm:@ss-@tzh:@tzm
@(end)
@(output)
@ (repeat)
@hh:@mm on @month-@day
@ (end)
@(end)
Or: @(repeat)
@year-@month-@{day}T@hh:@mm:@ss-@tzh:@tzm
@(do
(put-line `@hh:@mm on @month-@day`))
@(end)
On the command line: $ txr -c '@(repeat)
blah
...
@(end)' - # dash for stdin or file name
From a file: $ txr script.txr file
I see we have a mistake in the handling of time zones; the minus sign is part of the time zone offset. Perhaps a small dash of regex, maybe: @year-@month-@{day}T@hh:@mm:@ss@{tzh /[+-]\d\d/}:@tzmFor those of you who are wondering what sublime text can do, do give a visit to a sublime text video series on tutsplus, its awesome and teaches you the power of sublime text
But I wouldn't necessarily call emacs "great for non tech people".
(I suppose it's tiring for people to keep pointing out "yeah, emacs can do this too". Sorry.)
USA, Barack
Germany, Angela
to
USA, Obama
Germany, Merkel
based on a single example. Do this please. :)
Input:
Bogdan, "Yucca"
Josy, "Orange County"
Bill, "San Diego"
Example:
Bogdan lives in Yucca
Output:
Bogdan lives in Yucca
Josy lives in Orange
Bill lives in SanIt didn't infer that C. meant to truncate the last name, so everything ended up "John C." No biggie, but trying to figure out what does and doesn't work aside from tokenized string formatting was a bummer. Having the uppercase example led me to believe it could do more types of transformation.
Possible the right answer is hinting of some kind. "Roberto {C.} from Brazil" to hint that the C. should be matched with -something-, and since . naturally means abbreviation would mean "starts with C".
Input:
taco bell 1
mcdonalds 2
wendys 3
bojangles 4
dairy queen 5
Ex: 1. Taco BellOutput:
1. Taco Bell
. Mcdonalds 2
. Wendys 3
. Bojangles 4
5. Dairy Queen
? When I take the spaces out of the restaurants I get:New Input:
tacobell 1
mcdonalds 2
wendys 3
bojangles 4
dairyqueen 5
Ex: 1. TacoBellNew Output:
1. Tacobell
2. Mcdonalds
3. Wendys
4. Bojangles
5. DairyqueenI wish I knew which paper he was referring to - it's a great feature :).
Here's the corresponding perl program using the same data and output as on the transformy home page:
pbpaste | perl -p -e 's/(\d+), (\w+) (\w+), (\w+), (\w+)/@{[uc($3)]}, jersey number $1/'
To use that (pbpaste I think is a mac only feature) first copy / paste that into your terminal, then copy the list, then hit enter in the terminal.Thanks!!!
Does not seem to handle my main use case however (transforming a schema entry in Rails to a list of symbols).
Eg:
Input:
t.integer "Id"
t.integer "Active"
t.string "Email", null: false
t.string "CryptedPassword", null: false
t.datetime "created_at"
t.datetime "updated_at"
Example:
:Id
Output:
:Id
:Active
:CryptedPassword
:created
:updated
An example (converting C++ to C):
Input:
void FileStream::write(char* , int);
void VirtualMachine::cycle(int);
Example:
void FileStream_write(char* , int);
Output:
void FileStream_write(char* , int);
void VirtualMachine_cycle(int* , );
Also, is it open-source? @(repeat)
@type @class::@ident(@params);
@ (output)
@type @{class}_@ident(@params);
@ (end)
@(end)
Do this kind of thing regularly over C code, when it's too much for Vim macros.I do it out of Vim. That is: first, select a range of text, then pipe it out:
!txr some_transform_script.txr -
Done. For example, when adding functions to TXR Lisp's library, I start with a declaration like: static val foo(val x, val y);
I pipe this through a script which will produce this: reg_fun(intern(lit("foo"), user_package), func_n2(foo));
("Intern a symbol called "foo" in the user_package, and register a two-argument function object with this symbol, hosted from the C function foo.")It's a little complicated:
@(deffilter sym ("_" "-"))
@(collect)
@ (cases)
@/(static )?/val @fun(void);@(bind arg nil)
@ (or)
@/(static )?/val @fun(@(coll)@{type /[^ ,]+/} @{arg /[^ ,)]+/}@(until))@(end));
@ (end)
@(output)
reg_fun(intern(lit("@{fun :filter sym}"), user_package), func_n@(length arg)(@fun));
@(end)
@(end)
I filter underscores to dashes, because I want a C function like foo_bar to look like foo-bar in the Lisp dialect. The (void) argument list is handled as a special case.I need to parse the arguments because the output part needs to know how many there are. Note how "func_n2" is generated, where the 2 comes from the argument count.
Output javascript/python/regex/whatever that performs the transformation between the two lists.
I found that it doesn't like "=" in the transformation result.
foo, bar
baz, bog
first="foo", second="bar"
first"foo", second"bar"
first"baz", second"bog"Do you need to use some fancy AI or machine learning algorithm ?
Looks pretty mind blowing.
Mad respect.
It's pretty basic at the moment, but we'll be launching smarter and smarter versions as we go.
11/1/2008, 12/1/2008, 6/1/2009
transformed to this:
November 1, 2008, November 1, 2008, November 1, 2009
Adding a middle initial to the first player (Carlos), but no other lines, and I typed in "Carlos plays soccer" results in:
Carlos plays soccer
baseball plays USA
basketball plays USA
soccer plays Japan
Cool idea though.
abc, The Institue of
xyz, The school of
nbc2, The college of
jor5, School of
and if I try to extract just the name of the person it gives me the following
abc
xyz
nbc
jor
It's missing the numbers
PS: A very nice tool!
tennis 3 4 5
wilson 1 2 3
robert 5 6 7
some patterns that didn't work:tennis nis
tennis 12
tennis 12 even
Start by improving your proofreading :)
I mean, you can replicate the core functionality of this fairly easily using awk, and if you're happy doing a bit of piping to perl or whatever, the fancier time re-formatting stuff is also easy.
In essence, the complexity in this tool (and what makes it cool) is the figuring out what you are trying to do without telling it - if you can run a command line tool you can tokenise the input yourself and you're most of the way there already.