Datasets:
Sedweave real train/dev/frozen data with original and unselected candidate evaluations
Browse files- ATTRIBUTION.md +309 -0
- LICENSE +202 -0
- README.md +73 -0
- SO_DATASET_LICENSE.txt +9 -0
- build_v2_mix.py +82 -0
- candidate_training_config.json +38 -0
- convert_real_questions.py +176 -0
- data/test.jsonl +37 -0
- data/train.jsonl +0 -0
- data/validation.jsonl +42 -0
- evaluation/v1-dev.jsonl +42 -0
- evaluation/v1-dev.summary.json +20 -0
- evaluation/v1-test.jsonl +37 -0
- evaluation/v1-test.summary.json +20 -0
- evaluation/v2-dev.jsonl +42 -0
- evaluation/v2-dev.summary.json +20 -0
- evaluation/v2-test.jsonl +37 -0
- evaluation/v2-test.summary.json +20 -0
- fetch_real_questions.py +55 -0
- paraphrase_real_data.py +140 -0
- prepare_real_splits.py +39 -0
- real-source-splits.json +426 -0
- review_real_questions.py +50 -0
- review_v2_data.py +60 -0
- sedweave/__init__.py +3 -0
- sedweave/execution.py +83 -0
- train_sft.py +196 -0
- v2-mix-summary.json +15 -0
- validate_dataset.py +103 -0
- validation.json +49 -0
- vary_real_inputs.py +132 -0
ATTRIBUTION.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Source attribution
|
| 2 |
+
|
| 3 |
+
- [replace a unknown string between two known strings with sed](https://stackoverflow.com/questions/10613643/replace-a-unknown-string-between-two-known-strings-with-sed) — question: Camden S.; accepted answer: vyegorov (answer 10613688).
|
| 4 |
+
|
| 5 |
+
- [sed: Replace part of a line](https://stackoverflow.com/questions/1074450/sed-replace-part-of-a-line) — question: calvinkrishy; accepted answer: Jeremy Stein (answer 1074533).
|
| 6 |
+
|
| 7 |
+
- [How to insert a new line character after a fixed number of characters in a file](https://stackoverflow.com/questions/1187078/how-to-insert-a-new-line-character-after-a-fixed-number-of-characters-in-a-file) — question: rangalo; accepted answer: Kristian (answer 1187225).
|
| 8 |
+
|
| 9 |
+
- [excluding first and last lines from sed /START/,/END/](https://stackoverflow.com/questions/1187354/excluding-first-and-last-lines-from-sed-start-end) — question: Chen Levy; accepted answer: Ville Laurikari (answer 1187517).
|
| 10 |
+
|
| 11 |
+
- [Replace only if string exists in current line](https://stackoverflow.com/questions/11958369/replace-only-if-string-exists-in-current-line) — question: Anders Lind; accepted answer: Ihor Kaharlichenko (answer 11958566).
|
| 12 |
+
|
| 13 |
+
- [How to replace a path with another path in sed?](https://stackoverflow.com/questions/12061410/how-to-replace-a-path-with-another-path-in-sed) — question: Brian Postow; accepted answer: Lev Levitsky (answer 12061491).
|
| 14 |
+
|
| 15 |
+
- [Remove all text before colon](https://stackoverflow.com/questions/12297859/remove-all-text-before-colon) — question: NewUsr_stat; accepted answer: Sacha Epskamp (answer 12297934).
|
| 16 |
+
|
| 17 |
+
- [Extract numbers from a string using sed and regular expressions](https://stackoverflow.com/questions/12974162/extract-numbers-from-a-string-using-sed-and-regular-expressions) — question: Steven; accepted answer: Kent (answer 12974208).
|
| 18 |
+
|
| 19 |
+
- [Insert lines in a file starting from a specific line](https://stackoverflow.com/questions/13316437/insert-lines-in-a-file-starting-from-a-specific-line) — question: Sadiel; accepted answer: Chris Seymour (answer 13316554).
|
| 20 |
+
|
| 21 |
+
- [How to replace space with comma using sed?](https://stackoverflow.com/questions/13538772/how-to-replace-space-with-comma-using-sed) — question: Teja; accepted answer: mvp (answer 13538795).
|
| 22 |
+
|
| 23 |
+
- [How can I prepend a string to the beginning of each line in a file?](https://stackoverflow.com/questions/13586349/how-can-i-prepend-a-string-to-the-beginning-of-each-line-in-a-file) — question: bobbyrne01; accepted answer: nullrevolution (answer 13587466).
|
| 24 |
+
|
| 25 |
+
- [Regular Expression in sed for multiple replacements in one statement](https://stackoverflow.com/questions/14135027/regular-expression-in-sed-for-multiple-replacements-in-one-statement) — question: Jan; accepted answer: Anders Johansson (answer 14135068).
|
| 26 |
+
|
| 27 |
+
- [Using sed to replace beginning of line when match found](https://stackoverflow.com/questions/14137353/using-sed-to-replace-beginning-of-line-when-match-found) — question: dublintech; accepted answer: Chris Seymour (answer 14137448).
|
| 28 |
+
|
| 29 |
+
- [How to remove a character at the end of each line in UNIX](https://stackoverflow.com/questions/14840953/how-to-remove-a-character-at-the-end-of-each-line-in-unix) — question: Teja; accepted answer: jlliagre (answer 14840982).
|
| 30 |
+
|
| 31 |
+
- [How do I pair every two lines of a text file with Bash?](https://stackoverflow.com/questions/1513861/how-do-i-pair-every-two-lines-of-a-text-file-with-bash) — question: fwaechter; accepted answer: Tim (answer 1513918).
|
| 32 |
+
|
| 33 |
+
- [Uppercasing First Letter of Words Using SED](https://stackoverflow.com/questions/1538676/uppercasing-first-letter-of-words-using-sed) — question: neversaint; accepted answer: tangens (answer 1538818).
|
| 34 |
+
|
| 35 |
+
- [Replace all double quotes with single quotes](https://stackoverflow.com/questions/16154007/replace-all-double-quotes-with-single-quotes) — question: Zounadire; accepted answer: user142162 (answer 16154029).
|
| 36 |
+
|
| 37 |
+
- [Insert contents of a file after specific pattern match](https://stackoverflow.com/questions/16715373/insert-contents-of-a-file-after-specific-pattern-match) — question: Satish; accepted answer: Birei (answer 16715488).
|
| 38 |
+
|
| 39 |
+
- [how to use sed, awk, or gawk to print only what is matched?](https://stackoverflow.com/questions/1733692/how-to-use-sed-awk-or-gawk-to-print-only-what-is-matched) — question: Stéphane; accepted answer: mouviciel (answer 1733727).
|
| 40 |
+
|
| 41 |
+
- [Remove all lines before a match with sed](https://stackoverflow.com/questions/17364951/remove-all-lines-before-a-match-with-sed) — question: Fabio; accepted answer: Endoro (answer 17365103).
|
| 42 |
+
|
| 43 |
+
- [Delete using a different delimiter with Sed](https://stackoverflow.com/questions/1797906/delete-using-a-different-delimiter-with-sed) — question: calvinkrishy; accepted answer: Stobor (answer 1797967).
|
| 44 |
+
|
| 45 |
+
- [sed - Commenting a line matching a specific string AND that is not already commented out](https://stackoverflow.com/questions/17998763/sed-commenting-a-line-matching-a-specific-string-and-that-is-not-already-comme) — question: Jean-Francois Chevrette; accepted answer: aragaer (answer 17999003).
|
| 46 |
+
|
| 47 |
+
- ['grep +A': print everything after a match](https://stackoverflow.com/questions/18166552/grep-a-print-everything-after-a-match) — question: B.Mr.W.; accepted answer: Hai Vu (answer 18166628).
|
| 48 |
+
|
| 49 |
+
- [Using sed to split a string with a delimiter](https://stackoverflow.com/questions/18234378/using-sed-to-split-a-string-with-a-delimiter) — question: nullByteMe; accepted answer: fedorqui (answer 18234407).
|
| 50 |
+
|
| 51 |
+
- [How to cut a string after a specific character in unix](https://stackoverflow.com/questions/18397698/how-to-cut-a-string-after-a-specific-character-in-unix) — question: canecse; accepted answer: falsetru (answer 18397722).
|
| 52 |
+
|
| 53 |
+
- [Replace all whitespace with a line break/paragraph mark to make a word list](https://stackoverflow.com/questions/1853009/replace-all-whitespace-with-a-line-break-paragraph-mark-to-make-a-word-list) — question: DavidR; accepted answer: Greg Bacon (answer 1853040).
|
| 54 |
+
|
| 55 |
+
- [find matching text and replace next line](https://stackoverflow.com/questions/18620153/find-matching-text-and-replace-next-line) — question: bswinnerton; accepted answer: potong (answer 18622953).
|
| 56 |
+
|
| 57 |
+
- [Return a regex match in a Bash script, instead of replacing it](https://stackoverflow.com/questions/1898553/return-a-regex-match-in-a-bash-script-instead-of-replacing-it) — question: Mint; accepted answer: Dennis Williamson (answer 1898578).
|
| 58 |
+
|
| 59 |
+
- [remove white space from the end of line in linux](https://stackoverflow.com/questions/20521857/remove-white-space-from-the-end-of-line-in-linux) — question: aksg24; accepted answer: fedorqui (answer 20521915).
|
| 60 |
+
|
| 61 |
+
- [Concatenate in bash the output of two commands without newline character](https://stackoverflow.com/questions/20871534/concatenate-in-bash-the-output-of-two-commands-without-newline-character) — question: synaptik; accepted answer: anubhava (answer 20871567).
|
| 62 |
+
|
| 63 |
+
- [how can I get sed to quit after the first matching address range?](https://stackoverflow.com/questions/20943025/how-can-i-get-sed-to-quit-after-the-first-matching-address-range) — question: PonyEars; accepted answer: janos (answer 20943542).
|
| 64 |
+
|
| 65 |
+
- [Remove odd or even lines from a text file](https://stackoverflow.com/questions/21309020/remove-odd-or-even-lines-from-a-text-file) — question: SamuelNLP; accepted answer: Thor (answer 21309073).
|
| 66 |
+
|
| 67 |
+
- [Using sed to delete a case insensitive matched line](https://stackoverflow.com/questions/2157288/using-sed-to-delete-a-case-insensitive-matched-line) — question: eruina; accepted answer: Mark Byers (answer 2157363).
|
| 68 |
+
|
| 69 |
+
- [Insert multiple lines into a file after specified pattern using shell script](https://stackoverflow.com/questions/22497246/insert-multiple-lines-into-a-file-after-specified-pattern-using-shell-script) — question: user27; accepted answer: sat (answer 22497499).
|
| 70 |
+
|
| 71 |
+
- [How to remove leading whitespace from each line in a file](https://stackoverflow.com/questions/2310605/how-to-remove-leading-whitespace-from-each-line-in-a-file) — question: Lazer; accepted answer: shuvalov (answer 2310620).
|
| 72 |
+
|
| 73 |
+
- [Why does sed require 3 backslashes for a regular backslash?](https://stackoverflow.com/questions/2369314/why-does-sed-require-3-backslashes-for-a-regular-backslash) — question: Geo; accepted answer: Dennis Williamson (answer 2372693).
|
| 74 |
+
|
| 75 |
+
- [How to add a # before any line containing a matching pattern in BASH?](https://stackoverflow.com/questions/24230117/how-to-add-a-before-any-line-containing-a-matching-pattern-in-bash) — question: Village; accepted answer: potong (answer 24233771).
|
| 76 |
+
|
| 77 |
+
- [How to UNCOMMENT a line that contains a specific string using Sed?](https://stackoverflow.com/questions/24889346/how-to-uncomment-a-line-that-contains-a-specific-string-using-sed) — question: user3864928; accepted answer: Avinash Raj (answer 24889374).
|
| 78 |
+
|
| 79 |
+
- [How to remove every other line with sed?](https://stackoverflow.com/questions/2560411/how-to-remove-every-other-line-with-sed) — question: hhh; accepted answer: ghostdog74 (answer 2560448).
|
| 80 |
+
|
| 81 |
+
- [BSD sed: extra characters at the end of d command](https://stackoverflow.com/questions/26081375/bsd-sed-extra-characters-at-the-end-of-d-command) — question: lutaoact; accepted answer: Jonathan Leffler (answer 26081763).
|
| 82 |
+
|
| 83 |
+
- [Parsing the first column of a csv file to a new file](https://stackoverflow.com/questions/2652494/parsing-the-first-column-of-a-csv-file-to-a-new-file) — question: S1syphus; accepted answer: Thomas (answer 2652526).
|
| 84 |
+
|
| 85 |
+
- [How can I remove the last (non-newline) character of a file in unix?](https://stackoverflow.com/questions/27305177/how-can-i-remove-the-last-non-newline-character-of-a-file-in-unix) — question: MaxPRafferty; accepted answer: mklement0 (answer 27327973).
|
| 86 |
+
|
| 87 |
+
- [How to use awk to print lines where a field matches a specific string?](https://stackoverflow.com/questions/2957094/how-to-use-awk-to-print-lines-where-a-field-matches-a-specific-string) — question: yael; accepted answer: Hank Gay (answer 2957225).
|
| 88 |
+
|
| 89 |
+
- [Is it possible to escape regex metacharacters reliably with sed](https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed) — question: hek2mgl; accepted answer: mklement0 (answer 29613573).
|
| 90 |
+
|
| 91 |
+
- [Install Latest Stable Version of Ruby Using rbenv](https://stackoverflow.com/questions/30179484/install-latest-stable-version-of-ruby-using-rbenv) — question: user636044; accepted answer: NeronLeVelu (answer 30183040).
|
| 92 |
+
|
| 93 |
+
- [sed : how to print all lines after line with a match?](https://stackoverflow.com/questions/32569032/sed-how-to-print-all-lines-after-line-with-a-match) — question: hawarden_; accepted answer: tripleee (answer 32581300).
|
| 94 |
+
|
| 95 |
+
- [sed + remove "#" and empty lines with one sed command](https://stackoverflow.com/questions/3350223/sed-remove-and-empty-lines-with-one-sed-command) — question: lidia; accepted answer: paxdiablo (answer 3350246).
|
| 96 |
+
|
| 97 |
+
- [Print lines in file from the match line until end of file](https://stackoverflow.com/questions/3434462/print-lines-in-file-from-the-match-line-until-end-of-file) — question: lidia; accepted answer: ghostdog74 (answer 3434563).
|
| 98 |
+
|
| 99 |
+
- [How can I add a comma at the end of every line except the last line?](https://stackoverflow.com/questions/35021524/how-can-i-add-a-comma-at-the-end-of-every-line-except-the-last-line) — question: Joan Triay; accepted answer: tripleee (answer 35021663).
|
| 100 |
+
|
| 101 |
+
- [Delete the first five characters on any line of a text file in Linux with sed](https://stackoverflow.com/questions/3795512/delete-the-first-five-characters-on-any-line-of-a-text-file-in-linux-with-sed) — question: JBeg; accepted answer: PhilR (answer 3806107).
|
| 102 |
+
|
| 103 |
+
- ["sed" command in bash](https://stackoverflow.com/questions/3984824/sed-command-in-bash) — question: ajsie; accepted answer: Jack Kelly (answer 3984855).
|
| 104 |
+
|
| 105 |
+
- [Using ? with sed](https://stackoverflow.com/questions/4348166/using-with-sed) — question: User1; accepted answer: Laurence Gonsalves (answer 4348215).
|
| 106 |
+
|
| 107 |
+
- [Can I use the sed command to replace multiple empty line with one empty line?](https://stackoverflow.com/questions/4521162/can-i-use-the-sed-command-to-replace-multiple-empty-line-with-one-empty-line) — question: Just a learner; accepted answer: Dennis Williamson (answer 4522043).
|
| 108 |
+
|
| 109 |
+
- [How to globally replace strings in lines NOT starting with a certain pattern](https://stackoverflow.com/questions/4953738/how-to-globally-replace-strings-in-lines-not-starting-with-a-certain-pattern) — question: user438602; accepted answer: Dennis Williamson (answer 4953824).
|
| 110 |
+
|
| 111 |
+
- [Replacing from match to end-of-line](https://stackoverflow.com/questions/5047165/replacing-from-match-to-end-of-line) — question: GregH; accepted answer: Andrew Clark (answer 5047180).
|
| 112 |
+
|
| 113 |
+
- [Using different delimiters in sed commands and range addresses](https://stackoverflow.com/questions/5864146/using-different-delimiters-in-sed-commands-and-range-addresses) — question: DerZauberer; accepted answer: geekosaur (answer 5864155).
|
| 114 |
+
|
| 115 |
+
- [Insert linefeed in sed (Mac OS X)](https://stackoverflow.com/questions/6111679/insert-linefeed-in-sed-mac-os-x) — question: Tyilo; accepted answer: przemoc (answer 6112270).
|
| 116 |
+
|
| 117 |
+
- [Sed expression doesn't allow optional grouped string](https://stackoverflow.com/questions/6156259/sed-expression-doesnt-allow-optional-grouped-string) — question: Eduardo; accepted answer: Jonathan Leffler (answer 6157705).
|
| 118 |
+
|
| 119 |
+
- [How to enclose every line in a file in double quotes with sed?](https://stackoverflow.com/questions/6554066/how-to-enclose-every-line-in-a-file-in-double-quotes-with-sed) — question: nw.; accepted answer: Karoly Horvath (answer 6554082).
|
| 120 |
+
|
| 121 |
+
- [How do I add a line of text to the middle of a file using bash?](https://stackoverflow.com/questions/6739258/how-do-i-add-a-line-of-text-to-the-middle-of-a-file-using-bash) — question: PHLAK; accepted answer: brandizzi (answer 6739322).
|
| 122 |
+
|
| 123 |
+
- [Use sed to replace all backslashes with forward slashes](https://stackoverflow.com/questions/6852951/use-sed-to-replace-all-backslashes-with-forward-slashes) — question: Emily; accepted answer: Emiliano Poggi (answer 6853005).
|
| 124 |
+
|
| 125 |
+
- [Using sed to remove a block of text](https://stackoverflow.com/questions/6945621/using-sed-to-remove-a-block-of-text) — question: Scott C Wilson; accepted answer: Maxim Egorushkin (answer 6945788).
|
| 126 |
+
|
| 127 |
+
- [How to get ONLY Second line with SED](https://stackoverflow.com/questions/7103863/how-to-get-only-second-line-with-sed) — question: neversaint; accepted answer: Jonathan (answer 7103911).
|
| 128 |
+
|
| 129 |
+
- [Removing trailing / starting newlines with sed, awk, tr, and friends](https://stackoverflow.com/questions/7359527/removing-trailing-starting-newlines-with-sed-awk-tr-and-friends) — question: ELLIOTTCABLE; accepted answer: dogbane (answer 7359879).
|
| 130 |
+
|
| 131 |
+
- [How to use sed to remove all double quotes within a file](https://stackoverflow.com/questions/7635807/how-to-use-sed-to-remove-all-double-quotes-within-a-file) — question: MRTim2day; accepted answer: user104863 (answer 7635852).
|
| 132 |
+
|
| 133 |
+
- [Combining two sed commands](https://stackoverflow.com/questions/7657647/combining-two-sed-commands) — question: kanika; accepted answer: tripleee (answer 7657662).
|
| 134 |
+
|
| 135 |
+
- [sed substitution with Bash variables](https://stackoverflow.com/questions/7680504/sed-substitution-with-bash-variables) — question: csta; accepted answer: k.parnell (answer 7680548).
|
| 136 |
+
|
| 137 |
+
- [Remove the first word in a text stream](https://stackoverflow.com/questions/7814205/remove-the-first-word-in-a-text-stream) — question: Trcx; accepted answer: Kent (answer 7814456).
|
| 138 |
+
|
| 139 |
+
- [sed join lines together](https://stackoverflow.com/questions/7852132/sed-join-lines-together) — question: veilig; accepted answer: ninjalj (answer 7853846).
|
| 140 |
+
|
| 141 |
+
- [Remove a specific character using awk or sed](https://stackoverflow.com/questions/8008546/remove-a-specific-character-using-awk-or-sed) — question: AabinGunz; accepted answer: Piotr Praszmo (answer 8008729).
|
| 142 |
+
|
| 143 |
+
- [Deleting the first two lines of a file using BASH or awk or sed or whatever](https://stackoverflow.com/questions/8857705/deleting-the-first-two-lines-of-a-file-using-bash-or-awk-or-sed-or-whatever) — question: Amit; accepted answer: RobS (answer 8857734).
|
| 144 |
+
|
| 145 |
+
- [Sed regex and substring negation](https://stackoverflow.com/questions/9053100/sed-regex-and-substring-negation) — question: Anthony; accepted answer: Fred Foo (answer 9053163).
|
| 146 |
+
|
| 147 |
+
- [Using SED with wildcard](https://stackoverflow.com/questions/9189120/using-sed-with-wildcard) — question: mahmood; accepted answer: tom (answer 9189153).
|
| 148 |
+
|
| 149 |
+
- [sed find and replace with curly braces](https://stackoverflow.com/questions/9205669/sed-find-and-replace-with-curly-braces) — question: atdev; accepted answer: kev (answer 9205806).
|
| 150 |
+
|
| 151 |
+
- [How to add to the end of lines containing a pattern with sed or awk?](https://stackoverflow.com/questions/9591744/how-to-add-to-the-end-of-lines-containing-a-pattern-with-sed-or-awk) — question: yasar; accepted answer: user219882 (answer 9591835).
|
| 152 |
+
|
| 153 |
+
- [sed whole word search and replace](https://stackoverflow.com/questions/1032023/sed-whole-word-search-and-replace) — question: ksuralta; accepted answer: Joakim Lundborg (answer 1032039).
|
| 154 |
+
|
| 155 |
+
- [How to replace an entire line in a text file by line number](https://stackoverflow.com/questions/11145270/how-to-replace-an-entire-line-in-a-text-file-by-line-number) — question: user788171; accepted answer: chepner (answer 11145362).
|
| 156 |
+
|
| 157 |
+
- [Replace whole line containing a string using Sed](https://stackoverflow.com/questions/11245144/replace-whole-line-containing-a-string-using-sed) — question: Rahul; accepted answer: Todd A. Jacobs (answer 11245501).
|
| 158 |
+
|
| 159 |
+
- [How can I strip first X characters from string using sed?](https://stackoverflow.com/questions/11469989/how-can-i-strip-first-x-characters-from-string-using-sed) — question: Kokesh; accepted answer: Arnaud F. (answer 11470076).
|
| 160 |
+
|
| 161 |
+
- [How to extract text from a string using sed?](https://stackoverflow.com/questions/11568859/how-to-extract-text-from-a-string-using-sed) — question: RanRag; accepted answer: tripleee (answer 11568930).
|
| 162 |
+
|
| 163 |
+
- [sed with literal string--not input file](https://stackoverflow.com/questions/13055889/sed-with-literal-string-not-input-file) — question: amphibient; accepted answer: Gilles Quénot (answer 13055913).
|
| 164 |
+
|
| 165 |
+
- [How to use sed/grep to extract text between two words?](https://stackoverflow.com/questions/13242469/how-to-use-sed-grep-to-extract-text-between-two-words) — question: user1190650; accepted answer: Brian Campbell (answer 13242517).
|
| 166 |
+
|
| 167 |
+
- [Command to get nth line of STDOUT](https://stackoverflow.com/questions/1429556/command-to-get-nth-line-of-stdout) — question: Alana Storm; accepted answer: Jonathan Leffler (answer 1429628).
|
| 168 |
+
|
| 169 |
+
- [Why doesn't `\d` work in regular expressions in sed?](https://stackoverflow.com/questions/14671293/why-doesnt-d-work-in-regular-expressions-in-sed) — question: user2036880; accepted answer: Kamil (answer 14671415).
|
| 170 |
+
|
| 171 |
+
- [How to use sed to replace only the first occurrence in a file?](https://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file) — question: David Dibben; accepted answer: Ben Hoffstein (answer 148473).
|
| 172 |
+
|
| 173 |
+
- [Insert line after match using sed](https://stackoverflow.com/questions/15559359/insert-line-after-match-using-sed) — question: user2150250; accepted answer: Gilles Quénot (answer 15559399).
|
| 174 |
+
|
| 175 |
+
- [Why does sed not replace all occurrences?](https://stackoverflow.com/questions/15849119/why-does-sed-not-replace-all-occurrences) — question: Nishant George Agrwal; accepted answer: Bruno Reis (answer 15849152).
|
| 176 |
+
|
| 177 |
+
- [Delete empty lines using sed](https://stackoverflow.com/questions/16414410/delete-empty-lines-using-sed) — question: jonas; accepted answer: Kent (answer 16414489).
|
| 178 |
+
|
| 179 |
+
- [Have sed ignore non-matching lines](https://stackoverflow.com/questions/1665549/have-sed-ignore-non-matching-lines) — question: Paggas; accepted answer: liori (answer 1665662).
|
| 180 |
+
|
| 181 |
+
- [The easiest way to replace white spaces with (underscores) _ in bash](https://stackoverflow.com/questions/1706431/the-easiest-way-to-replace-white-spaces-with-underscores-in-bash) — question: flazzarini; accepted answer: ghostdog74 (answer 1706459).
|
| 182 |
+
|
| 183 |
+
- [sed: print only matching group](https://stackoverflow.com/questions/17511639/sed-print-only-matching-group) — question: mort; accepted answer: iruvar (answer 17511700).
|
| 184 |
+
|
| 185 |
+
- [sed insert line with leading spaces to a specific line](https://stackoverflow.com/questions/18439528/sed-insert-line-with-leading-spaces-to-a-specific-line) — question: Ggdw; accepted answer: Atropo (answer 18439749).
|
| 186 |
+
|
| 187 |
+
- [bash, extract string before a colon](https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon) — question: user788171; accepted answer: ray (answer 20348145).
|
| 188 |
+
|
| 189 |
+
- [Delete specific line number(s) from a text file using sed?](https://stackoverflow.com/questions/2112469/delete-specific-line-numbers-from-a-text-file-using-sed) — question: Justin Ethier; accepted answer: Brian Campbell (answer 2112496).
|
| 190 |
+
|
| 191 |
+
- [How to escape single quote in sed?](https://stackoverflow.com/questions/24509214/how-to-escape-single-quote-in-sed) — question: Thomas Bratt; accepted answer: Kent (answer 24509931).
|
| 192 |
+
|
| 193 |
+
- [Why is sed not recognizing \t as a tab?](https://stackoverflow.com/questions/2610115/why-is-sed-not-recognizing-t-as-a-tab) — question: sixtyfootersdude; accepted answer: Mark Byers (answer 2610121).
|
| 194 |
+
|
| 195 |
+
- [How to swap text based on patterns at once with sed?](https://stackoverflow.com/questions/26568952/how-to-swap-text-based-on-patterns-at-once-with-sed) — question: DaniloNC; accepted answer: ooga (answer 26568996).
|
| 196 |
+
|
| 197 |
+
- [How can I output only captured groups with sed?](https://stackoverflow.com/questions/2777579/how-can-i-output-only-captured-groups-with-sed) — question: Pablo; accepted answer: Dennis Williamson (answer 2778096).
|
| 198 |
+
|
| 199 |
+
- [In Bash, how do I add a string after each line in a file?](https://stackoverflow.com/questions/2869669/in-bash-how-do-i-add-a-string-after-each-line-in-a-file) — question: Jason Volkoz; accepted answer: Tom DeGisi (answer 2869736).
|
| 200 |
+
|
| 201 |
+
- [How do I remove newlines from a text file?](https://stackoverflow.com/questions/3134791/how-do-i-remove-newlines-from-a-text-file) — question: Alucard; accepted answer: Tyler McHenry (answer 3134827).
|
| 202 |
+
|
| 203 |
+
- [Replace newlines with literal \n](https://stackoverflow.com/questions/38672680/replace-newlines-with-literal-n) — question: Parze; accepted answer: anubhava (answer 38672741).
|
| 204 |
+
|
| 205 |
+
- [How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?](https://stackoverflow.com/questions/38972736/how-to-print-lines-between-two-patterns-inclusive-or-exclusive-in-sed-awk-or) — question: fedorqui; accepted answer: fedorqui (answer 38972737).
|
| 206 |
+
|
| 207 |
+
- [sed one-liner to convert all uppercase to lowercase?](https://stackoverflow.com/questions/4569825/sed-one-liner-to-convert-all-uppercase-to-lowercase) — question: magnetar; accepted answer: magnetar (answer 4581564).
|
| 208 |
+
|
| 209 |
+
- [How to extract string following a pattern with grep, regex or perl](https://stackoverflow.com/questions/5080988/how-to-extract-string-following-a-pattern-with-grep-regex-or-perl) — question: wrangler; accepted answer: sidyll (answer 5081519).
|
| 210 |
+
|
| 211 |
+
- [How do I delete all lines in a file starting from after a matching line?](https://stackoverflow.com/questions/5227295/how-do-i-delete-all-lines-in-a-file-starting-from-after-a-matching-line) — question: DocWiki; accepted answer: Dennis Williamson (answer 5227429).
|
| 212 |
+
|
| 213 |
+
- [Using sed, how do you print the first 'N' characters of a line?](https://stackoverflow.com/questions/538664/using-sed-how-do-you-print-the-first-n-characters-of-a-line) — question: Berlin Brown; accepted answer: Paul Tomblin (answer 538676).
|
| 214 |
+
|
| 215 |
+
- [How can I delete all lines that contain a specific string from a text file?](https://stackoverflow.com/questions/5410757/how-can-i-delete-all-lines-that-contain-a-specific-string-from-a-text-file) — question: A Clockwork Orange; accepted answer: SiegeX (answer 5410784).
|
| 216 |
+
|
| 217 |
+
- [Bash tool to get nth line from a file](https://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file) — question: Vlad Vivdovitch; accepted answer: anubhava (answer 6022431).
|
| 218 |
+
|
| 219 |
+
- [Using sed to delete all lines between two matching patterns](https://stackoverflow.com/questions/6287755/using-sed-to-delete-all-lines-between-two-matching-patterns) — question: Ken; accepted answer: anubhava (answer 6287940).
|
| 220 |
+
|
| 221 |
+
- [How to insert a newline in front of a pattern?](https://stackoverflow.com/questions/723157/how-to-insert-a-newline-in-front-of-a-pattern) — question: Dennis; accepted answer: Dennis (answer 723247).
|
| 222 |
+
|
| 223 |
+
- [How to show only next line after the matched one?](https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one) — question: facha; accepted answer: Michał Šrajer (answer 7451456).
|
| 224 |
+
|
| 225 |
+
- [How do I escape slashes and double and single quotes in sed?](https://stackoverflow.com/questions/7517632/how-do-i-escape-slashes-and-double-and-single-quotes-in-sed) — question: KRB; accepted answer: Kusalananda (answer 7517900).
|
| 226 |
+
|
| 227 |
+
- [Delete all lines beginning with a # from a file](https://stackoverflow.com/questions/8206280/delete-all-lines-beginning-with-a-from-a-file) — question: Village; accepted answer: Raymond Hettinger (answer 8206295).
|
| 228 |
+
|
| 229 |
+
- [How to replace a whole line with sed?](https://stackoverflow.com/questions/8822097/how-to-replace-a-whole-line-with-sed) — question: Michael; accepted answer: John Doyle (answer 8822211).
|
| 230 |
+
|
| 231 |
+
- [How to insert a text at the beginning of a file?](https://stackoverflow.com/questions/9533679/how-to-insert-a-text-at-the-beginning-of-a-file) — question: user219882; accepted answer: kev (answer 9533736).
|
| 232 |
+
|
| 233 |
+
- [How to merge every two lines into one from the command line?](https://stackoverflow.com/questions/9605232/how-to-merge-every-two-lines-into-one-from-the-command-line) — question: shantanuo; accepted answer: Kent (answer 9605559).
|
| 234 |
+
|
| 235 |
+
- [How to remove all white spaces from a given text file?](https://stackoverflow.com/questions/9953448/how-to-remove-all-white-spaces-from-a-given-text-file) — question: Lunar Mushrooms; accepted answer: Paulo Scardine (answer 9953487).
|
| 236 |
+
|
| 237 |
+
- [How to add double quotes to a line with SED or AWK?](https://stackoverflow.com/questions/10754682/how-to-add-double-quotes-to-a-line-with-sed-or-awk) — question: minerals; accepted answer: Dennis Williamson (answer 10755347).
|
| 238 |
+
|
| 239 |
+
- [Awk to skip the blank lines](https://stackoverflow.com/questions/11687216/awk-to-skip-the-blank-lines) — question: Gil; accepted answer: Levon (answer 11687266).
|
| 240 |
+
|
| 241 |
+
- [Sed: get lines beginning with some prefix](https://stackoverflow.com/questions/13202715/sed-get-lines-beginning-with-some-prefix) — question: CAMOBAP; accepted answer: John3136 (answer 13202727).
|
| 242 |
+
|
| 243 |
+
- [Using sed to match a pattern and deleting from the line to the end of the file](https://stackoverflow.com/questions/14046878/using-sed-to-match-a-pattern-and-deleting-from-the-line-to-the-end-of-the-file) — question: Albert H; accepted answer: shellter (answer 14046990).
|
| 244 |
+
|
| 245 |
+
- [Fastest way to print a single line in a file](https://stackoverflow.com/questions/15632691/fastest-way-to-print-a-single-line-in-a-file) — question: JBoy; accepted answer: Chris Seymour (answer 15632780).
|
| 246 |
+
|
| 247 |
+
- [How to replace newlines with tab characters?](https://stackoverflow.com/questions/1617724/how-to-replace-newlines-with-tab-characters) — question: Vijay; accepted answer: ghostdog74 (answer 1617769).
|
| 248 |
+
|
| 249 |
+
- [Using sed between specific lines only](https://stackoverflow.com/questions/16202900/using-sed-between-specific-lines-only) — question: hackio; accepted answer: anubhava (answer 16202932).
|
| 250 |
+
|
| 251 |
+
- [How to add new line using sed on MacOS?](https://stackoverflow.com/questions/16576197/how-to-add-new-line-using-sed-on-macos) — question: codereviewanskquestions; accepted answer: Kevin (answer 16576291).
|
| 252 |
+
|
| 253 |
+
- [Sed to remove everything after "." in file using * command?](https://stackoverflow.com/questions/18602234/sed-to-remove-everything-after-in-file-using-command) — question: Novice; accepted answer: Adam Rosenfield (answer 18602273).
|
| 254 |
+
|
| 255 |
+
- [How to use sed to replace a config file's variable?](https://stackoverflow.com/questions/20568515/how-to-use-sed-to-replace-a-config-files-variable) — question: SomeGuyOnAComputer; accepted answer: anubhava (answer 20568559).
|
| 256 |
+
|
| 257 |
+
- [How to append a string at end of a specific line in a file in bash](https://stackoverflow.com/questions/22159044/how-to-append-a-string-at-end-of-a-specific-line-in-a-file-in-bash) — question: Chris F; accepted answer: Steve (answer 22159086).
|
| 258 |
+
|
| 259 |
+
- [sed command to replace multiple spaces into single spaces](https://stackoverflow.com/questions/22939323/sed-command-to-replace-multiple-spaces-into-single-spaces) — question: logan; accepted answer: John Zwinck (answer 22939416).
|
| 260 |
+
|
| 261 |
+
- [Is there a cleaner way of getting the last N characters of every line?](https://stackoverflow.com/questions/24427009/is-there-a-cleaner-way-of-getting-the-last-n-characters-of-every-line) — question: merlin2011; accepted answer: Tiago Lopo (answer 24427087).
|
| 262 |
+
|
| 263 |
+
- [Extract The Second Word In A Line From A Text File](https://stackoverflow.com/questions/25491847/extract-the-second-word-in-a-line-from-a-text-file) — question: Aaron Perry; accepted answer: zedfoxus (answer 25491964).
|
| 264 |
+
|
| 265 |
+
- [Awk/sed script to convert a file from camelCase to underscores](https://stackoverflow.com/questions/28795479/awk-sed-script-to-convert-a-file-from-camelcase-to-underscores) — question: Corentin Peuvrel; accepted answer: Avinash Raj (answer 28795550).
|
| 266 |
+
|
| 267 |
+
- [Using sed to replace tab with spaces](https://stackoverflow.com/questions/31903432/using-sed-to-replace-tab-with-spaces) — question: manshuai; accepted answer: anubhava (answer 31903444).
|
| 268 |
+
|
| 269 |
+
- [Ignoring First line/Column header while reading a file in bash](https://stackoverflow.com/questions/31911179/ignoring-first-line-column-header-while-reading-a-file-in-bash) — question: Jai; accepted answer: chepner (answer 31911198).
|
| 270 |
+
|
| 271 |
+
- [Joining two consecutive lines using awk or sed](https://stackoverflow.com/questions/3194534/joining-two-consecutive-lines-using-awk-or-sed) — question: Vijay; accepted answer: Dimitre Radoulov (answer 3196948).
|
| 272 |
+
|
| 273 |
+
- [capturing groups in sed](https://stackoverflow.com/questions/3302434/capturing-groups-in-sed) — question: Mike Dewar; accepted answer: ninjalj (answer 3302593).
|
| 274 |
+
|
| 275 |
+
- [sed: unescaped newline inside substitute pattern?](https://stackoverflow.com/questions/34576667/sed-unescaped-newline-inside-substitute-pattern) — question: RocketNuts; accepted answer: anubhava (answer 34576684).
|
| 276 |
+
|
| 277 |
+
- [sed + remove string only in the last line of the file](https://stackoverflow.com/questions/3576139/sed-remove-string-only-in-the-last-line-of-the-file) — question: lidia; accepted answer: Scharron (answer 3576183).
|
| 278 |
+
|
| 279 |
+
- [Replace \n(new line) with space in bash](https://stackoverflow.com/questions/39198780/replace-nnew-line-with-space-in-bash) — question: Prometheus; accepted answer: Cyrus (answer 39198829).
|
| 280 |
+
|
| 281 |
+
- [Converting JSON pretty print to one line](https://stackoverflow.com/questions/39648222/converting-json-pretty-print-to-one-line) — question: h.b; accepted answer: P.... (answer 39653559).
|
| 282 |
+
|
| 283 |
+
- [Delete everyting preceding and including a certain substring from variable](https://stackoverflow.com/questions/40506782/delete-everyting-preceding-and-including-a-certain-substring-from-variable) — question: Anne K.; accepted answer: heemayl (answer 40506863).
|
| 284 |
+
|
| 285 |
+
- [Do a tail -F until matching a pattern](https://stackoverflow.com/questions/5024357/do-a-tail-f-until-matching-a-pattern) — question: Sam Alba; accepted answer: jpetazzo (answer 5033775).
|
| 286 |
+
|
| 287 |
+
- [sed - Get only the replaced string from a multiline input & omit unmatched lines!](https://stackoverflow.com/questions/5544322/sed-get-only-the-replaced-string-from-a-multiline-input-omit-unmatched-lines) — question: porg; accepted answer: anubhava (answer 5544539).
|
| 288 |
+
|
| 289 |
+
- [Grep. Line of text that does not end with "abcd"?](https://stackoverflow.com/questions/6006132/grep-line-of-text-that-does-not-end-with-abcd) — question: CCC; accepted answer: tobyodavies (answer 6006139).
|
| 290 |
+
|
| 291 |
+
- [regexp (sed) suppress "no match" output](https://stackoverflow.com/questions/6011661/regexp-sed-suppress-no-match-output) — question: yPhil; accepted answer: przemoc (answer 6011704).
|
| 292 |
+
|
| 293 |
+
- [Skipping the first n lines when using regex with sed?](https://stackoverflow.com/questions/6869449/skipping-the-first-n-lines-when-using-regex-with-sed) — question: Legend; accepted answer: a'r (answer 6869486).
|
| 294 |
+
|
| 295 |
+
- [upper- to lower-case using sed](https://stackoverflow.com/questions/689495/upper-to-lower-case-using-sed) — question: cadrian; accepted answer: strager (answer 689608).
|
| 296 |
+
|
| 297 |
+
- [How to make sed remove lines not matched by a substitution](https://stackoverflow.com/questions/8225822/how-to-make-sed-remove-lines-not-matched-by-a-substitution) — question: Ropez; accepted answer: jaypal singh (answer 8255627).
|
| 298 |
+
|
| 299 |
+
- [sed: just trying to remove a substring](https://stackoverflow.com/questions/8356958/sed-just-trying-to-remove-a-substring) — question: user1077220; accepted answer: aefxx (answer 8356980).
|
| 300 |
+
|
| 301 |
+
- [What is the proper way to insert tab in sed?](https://stackoverflow.com/questions/8394066/what-is-the-proper-way-to-insert-tab-in-sed) — question: dabest1; accepted answer: Jonathan Leffler (answer 8394150).
|
| 302 |
+
|
| 303 |
+
- [escaping newlines in sed replacement string](https://stackoverflow.com/questions/8991275/escaping-newlines-in-sed-replacement-string) — question: spraff; accepted answer: jaypal singh (answer 8991356).
|
| 304 |
+
|
| 305 |
+
- [Removing pattern at the end of a string using sed or other bash tools](https://stackoverflow.com/questions/9191030/removing-pattern-at-the-end-of-a-string-using-sed-or-other-bash-tools) — question: Kay Chan; accepted answer: Birei (answer 9191062).
|
| 306 |
+
|
| 307 |
+
- [sed extracting group of digits](https://stackoverflow.com/questions/9260625/sed-extracting-group-of-digits) — question: Uthman; accepted answer: codaddict (answer 9260734).
|
| 308 |
+
|
| 309 |
+
- [sed to insert on first match only](https://stackoverflow.com/questions/9970124/sed-to-insert-on-first-match-only) — question: SSS; accepted answer: Squazic (answer 9970467).
|
LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
| 178 |
+
|
| 179 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 180 |
+
|
| 181 |
+
To apply the Apache License to your work, attach the following
|
| 182 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 183 |
+
replaced with your own identifying information. (Don't include
|
| 184 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 185 |
+
comment syntax for the file format. We also recommend that a
|
| 186 |
+
file or class name and description of purpose be included on the
|
| 187 |
+
same "printed page" as the copyright notice for easier
|
| 188 |
+
identification within third-party archives.
|
| 189 |
+
|
| 190 |
+
Copyright [yyyy] [name of copyright owner]
|
| 191 |
+
|
| 192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 193 |
+
you may not use this file except in compliance with the License.
|
| 194 |
+
You may obtain a copy of the License at
|
| 195 |
+
|
| 196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 197 |
+
|
| 198 |
+
Unless required by applicable law or agreed to in writing, software
|
| 199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 201 |
+
See the License for the specific language governing permissions and
|
| 202 |
+
limitations under the License.
|
README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
language: en
|
| 4 |
+
pretty_name: Sedweave Real Data
|
| 5 |
+
size_categories:
|
| 6 |
+
- n<1K
|
| 7 |
+
task_categories:
|
| 8 |
+
- text-generation
|
| 9 |
+
tags:
|
| 10 |
+
- sed
|
| 11 |
+
- code-generation
|
| 12 |
+
- text-to-code
|
| 13 |
+
- execution-verified
|
| 14 |
+
- stackoverflow
|
| 15 |
+
configs:
|
| 16 |
+
- config_name: default
|
| 17 |
+
data_files:
|
| 18 |
+
- split: train
|
| 19 |
+
path: data/train.jsonl
|
| 20 |
+
- split: validation
|
| 21 |
+
path: data/validation.jsonl
|
| 22 |
+
- split: test
|
| 23 |
+
path: data/test.jsonl
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
# Sedweave Real Data
|
| 27 |
+
|
| 28 |
+
Natural-language-to-`sed` tasks derived from highly voted Stack Overflow questions and accepted answers, with disjoint training, development, and frozen-test questions. This dataset supports generalization-focused training and evaluation beyond Sedweave's synthetic task families.
|
| 29 |
+
|
| 30 |
+
## Splits
|
| 31 |
+
|
| 32 |
+
| Split | Rows | Purpose |
|
| 33 |
+
| --- | ---: | --- |
|
| 34 |
+
| Train | 157 | 75 unique reviewed tasks, 4 input variations, and 78 guarded paraphrases |
|
| 35 |
+
| Validation | 42 | Initial real-question development benchmark; never used for training |
|
| 36 |
+
| Test | 37 | Frozen questions from disjoint lower-vote sources |
|
| 37 |
+
|
| 38 |
+
The source questions are unique across all splits. There is zero input-text or request/command overlap between splits or with `asterbraid/sedweave-data`. The original 42-task `asterbraid/sedweave-so-data` benchmark is preserved separately and appears here as the validation split.
|
| 39 |
+
|
| 40 |
+
Every reference command was executed on two inputs with `/usr/bin/sed (GNU sed) 4.9`: **472 successful executions, 0 errors**. Commands start with `sed`, read one stream on stdin, and avoid filenames, in-place edits, file commands, pipelines, and shell execution. Some authentic solutions use GNU `sed` extensions.
|
| 41 |
+
|
| 42 |
+
## Source and attribution
|
| 43 |
+
|
| 44 |
+
Each row includes `question_url`, `question_title`, `question_owner`, `answer_owner`, and `answer_id`. `ATTRIBUTION.md` lists every source. Requests are self-contained instructions derived from questions and accepted answers; commands are executable solutions. Request-to-command intent was manually reviewed. Paraphrases and input variations were generated only for training rows and passed literal-preservation and execution checks.
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
from datasets import load_dataset
|
| 48 |
+
|
| 49 |
+
train = load_dataset("asterbraid/sedweave-real-data", split="train")
|
| 50 |
+
test = load_dataset("asterbraid/sedweave-real-data", split="test")
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Model evaluation
|
| 54 |
+
|
| 55 |
+
Greedy generation, one prediction per row. Valid means the command executes; correct requires exact output on both inputs. Only trailing special tokens are removed.
|
| 56 |
+
|
| 57 |
+
| Model | Validation valid | Validation correct | Frozen-test valid | Frozen-test correct |
|
| 58 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 59 |
+
| Original Sedweave 0.5B | 71.4% (30/42) | 23.8% (10/42) | 89.2% (33/37) | 18.9% (7/37) |
|
| 60 |
+
| Unselected generalization-tuned candidate | 76.2% (32/42) | 23.8% (10/42) | 83.8% (31/37) | 18.9% (7/37) |
|
| 61 |
+
|
| 62 |
+
Full predictions and summaries are included under `evaluation/`.
|
| 63 |
+
|
| 64 |
+
The generalization-tuned candidate was **not released**: frozen validity decreased and frozen correctness did not improve. The original Sedweave 0.5B remains the recommended model. The candidate's training settings are in `candidate_training_config.json`.
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
## Limitations
|
| 68 |
+
|
| 69 |
+
This is a small, high-vote sample, not a representative benchmark of all `sed` use. Tasks were selected for compatibility with single-stream input and the safety guard. Exact outputs on two representative inputs do not prove correctness on every possible input. Some requests or commands may be ambiguous outside their original context.
|
| 70 |
+
|
| 71 |
+
## License
|
| 72 |
+
|
| 73 |
+
Original Stack Overflow content and these derived rows are **CC BY-SA 4.0**. See `SO_DATASET_LICENSE.txt` and `ATTRIBUTION.md`. Included collection, conversion, review, expansion, and validation code is Apache-2.0.
|
SO_DATASET_LICENSE.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Awkweave Stack Overflow-derived rows are licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0).
|
| 2 |
+
|
| 3 |
+
The rows are derived from Stack Overflow questions and accepted answers. Each row includes the question URL, question title, question author, answer author, and answer ID. The original questions and answers remain the work of their respective authors. Listings and generated attribution files in this repository are provided by Asterbraid.
|
| 4 |
+
|
| 5 |
+
You must give appropriate credit, link to the license, indicate changes, and distribute adaptations under the same license.
|
| 6 |
+
|
| 7 |
+
License: https://creativecommons.org/licenses/by-sa/4.0/
|
| 8 |
+
Legal code: https://creativecommons.org/licenses/by-sa/4.0/legalcode
|
| 9 |
+
Stack Exchange content policy: https://stackoverflow.com/legal/terms-of-service/public
|
build_v2_mix.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import collections
|
| 5 |
+
import hashlib
|
| 6 |
+
import json
|
| 7 |
+
import random
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def main() -> None:
|
| 12 |
+
parser = argparse.ArgumentParser()
|
| 13 |
+
parser.add_argument("--seed-data", type=Path, required=True)
|
| 14 |
+
parser.add_argument("--real-data", type=Path, required=True)
|
| 15 |
+
parser.add_argument("--dev-data", type=Path, required=True)
|
| 16 |
+
parser.add_argument("--output", type=Path, required=True)
|
| 17 |
+
parser.add_argument("--summary", type=Path, required=True)
|
| 18 |
+
parser.add_argument("--replay-per-family", type=int, default=176)
|
| 19 |
+
parser.add_argument("--real-repeat", type=int, default=6)
|
| 20 |
+
parser.add_argument("--seed", type=int, default=42)
|
| 21 |
+
args = parser.parse_args()
|
| 22 |
+
seed_rows = [json.loads(line) for line in args.seed_data.open(encoding="utf-8")]
|
| 23 |
+
real_rows = [json.loads(line) for line in args.real_data.open(encoding="utf-8")]
|
| 24 |
+
dev_rows = [json.loads(line) for line in args.dev_data.open(encoding="utf-8")]
|
| 25 |
+
if any(row["split"] != "train" for row in real_rows):
|
| 26 |
+
raise ValueError("Real expansion contains non-training rows")
|
| 27 |
+
real_sources = {row["question_url"] for row in real_rows}
|
| 28 |
+
if real_sources & {row["question_url"] for row in dev_rows}:
|
| 29 |
+
raise ValueError("Development source question leaked into training")
|
| 30 |
+
|
| 31 |
+
rng = random.Random(args.seed)
|
| 32 |
+
by_family = collections.defaultdict(list)
|
| 33 |
+
for row in seed_rows:
|
| 34 |
+
if row["split"] == "train" and not row.get("paraphrase_of"):
|
| 35 |
+
by_family[row["family"]].append(row)
|
| 36 |
+
replay = []
|
| 37 |
+
for family, rows in sorted(by_family.items()):
|
| 38 |
+
rows = list(rows)
|
| 39 |
+
rng.shuffle(rows)
|
| 40 |
+
replay.extend(rows[:args.replay_per_family])
|
| 41 |
+
train = []
|
| 42 |
+
for row in replay:
|
| 43 |
+
train.append(dict(row, mixture_source="synthetic-replay"))
|
| 44 |
+
for repetition in range(args.real_repeat):
|
| 45 |
+
for row in real_rows:
|
| 46 |
+
repeated = dict(row)
|
| 47 |
+
repeated["id"] = f"{row['id']}-r{repetition + 1}"
|
| 48 |
+
repeated["mixture_source"] = "real-expansion"
|
| 49 |
+
repeated["repetition"] = repetition + 1
|
| 50 |
+
train.append(repeated)
|
| 51 |
+
rng.shuffle(train)
|
| 52 |
+
validation = [dict(row, split="validation") for row in dev_rows]
|
| 53 |
+
output_rows = train + validation
|
| 54 |
+
with args.output.open("w", encoding="utf-8") as handle:
|
| 55 |
+
for row in output_rows:
|
| 56 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 57 |
+
summary = {
|
| 58 |
+
"output": str(args.output),
|
| 59 |
+
"sha256": hashlib.sha256(args.output.read_bytes()).hexdigest(),
|
| 60 |
+
"train_rows": len(train),
|
| 61 |
+
"validation_rows": len(validation),
|
| 62 |
+
"synthetic_replay_rows": len(replay),
|
| 63 |
+
"real_expansion_rows": len(train) - len(replay),
|
| 64 |
+
"real_unique_rows": len(real_rows),
|
| 65 |
+
"real_repeat": args.real_repeat,
|
| 66 |
+
"replay_per_family": args.replay_per_family,
|
| 67 |
+
"families": len(by_family),
|
| 68 |
+
"seed": args.seed,
|
| 69 |
+
"train_dev_input_overlap": len({row["input_text"] for row in train} & {row["input_text"] for row in dev_rows}),
|
| 70 |
+
"train_dev_request_command_overlap": len(
|
| 71 |
+
{(row["request"], row["command"]) for row in train}
|
| 72 |
+
& {(row["request"], row["command"]) for row in dev_rows}
|
| 73 |
+
),
|
| 74 |
+
}
|
| 75 |
+
if summary["train_dev_input_overlap"] or summary["train_dev_request_command_overlap"]:
|
| 76 |
+
raise ValueError("Development data leaked into the training mixture")
|
| 77 |
+
args.summary.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
| 78 |
+
print(json.dumps(summary, indent=2))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__ == "__main__":
|
| 82 |
+
main()
|
candidate_training_config.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"data": "/workspace/sedweave/sedweave-v2-mix.jsonl",
|
| 3 |
+
"output": "/outputs/aae244b1-b1ab-4dbd-a1e3-815e9d722ec7/training",
|
| 4 |
+
"base_model": "asterbraid/sedweave-0.5b",
|
| 5 |
+
"max_length": 1024,
|
| 6 |
+
"max_rows": null,
|
| 7 |
+
"eval_rows": 42,
|
| 8 |
+
"epochs": 1.0,
|
| 9 |
+
"batch_size": 32,
|
| 10 |
+
"gradient_accumulation": 2,
|
| 11 |
+
"learning_rate": 2e-05,
|
| 12 |
+
"precision": "fp32",
|
| 13 |
+
"eval_steps": 25,
|
| 14 |
+
"logging_steps": 10,
|
| 15 |
+
"seed": 42,
|
| 16 |
+
"lora_r": 32,
|
| 17 |
+
"lora_alpha": 64,
|
| 18 |
+
"lora_dropout": 0.05,
|
| 19 |
+
"target_modules": "{'k_proj', 'down_proj', 'gate_proj', 'q_proj', 'v_proj', 'o_proj', 'up_proj'}",
|
| 20 |
+
"train_rows": 6926,
|
| 21 |
+
"validation_rows": 42,
|
| 22 |
+
"train_metrics": {
|
| 23 |
+
"train_runtime": 70.4543,
|
| 24 |
+
"train_samples_per_second": 98.305,
|
| 25 |
+
"train_steps_per_second": 1.547,
|
| 26 |
+
"total_flos": 2399153195662848.0,
|
| 27 |
+
"train_loss": 0.17782118021074786,
|
| 28 |
+
"epoch": 1.0
|
| 29 |
+
},
|
| 30 |
+
"data_sha256": "cd97d93d0c33d46884dbbe3fd45e19fd61787cf701e2b1626dc1e14d1dad78a5",
|
| 31 |
+
"library_versions": {
|
| 32 |
+
"torch": "2.14.0",
|
| 33 |
+
"transformers": "4.57.6",
|
| 34 |
+
"datasets": "5.0.1",
|
| 35 |
+
"peft": "0.21.0",
|
| 36 |
+
"accelerate": "1.15.0"
|
| 37 |
+
}
|
| 38 |
+
}
|
convert_real_questions.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import concurrent.futures
|
| 5 |
+
import html
|
| 6 |
+
import html.parser
|
| 7 |
+
import json
|
| 8 |
+
import os
|
| 9 |
+
import time
|
| 10 |
+
import urllib.request
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
from sedweave.execution import run_sed
|
| 14 |
+
|
| 15 |
+
MODEL = "qwen/qwen3.7-plus"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class TextExtractor(html.parser.HTMLParser):
|
| 19 |
+
def __init__(self):
|
| 20 |
+
super().__init__()
|
| 21 |
+
self.parts = []
|
| 22 |
+
self.skip = 0
|
| 23 |
+
|
| 24 |
+
def handle_starttag(self, tag, attrs):
|
| 25 |
+
if tag in {"script", "style"}:
|
| 26 |
+
self.skip += 1
|
| 27 |
+
if tag in {"p", "br", "pre", "code", "li", "tr"}:
|
| 28 |
+
self.parts.append("\n")
|
| 29 |
+
|
| 30 |
+
def handle_endtag(self, tag):
|
| 31 |
+
if tag in {"script", "style"} and self.skip:
|
| 32 |
+
self.skip -= 1
|
| 33 |
+
if tag in {"p", "pre", "code", "li", "tr"}:
|
| 34 |
+
self.parts.append("\n")
|
| 35 |
+
|
| 36 |
+
def handle_data(self, data):
|
| 37 |
+
if not self.skip:
|
| 38 |
+
self.parts.append(data)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def plain(value: str) -> str:
|
| 42 |
+
parser = TextExtractor()
|
| 43 |
+
parser.feed(value)
|
| 44 |
+
text = html.unescape("".join(parser.parts))
|
| 45 |
+
return "\n".join(line.strip() for line in text.splitlines() if line.strip())
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def convert_batch(items: list[dict]) -> list[dict]:
|
| 49 |
+
context = []
|
| 50 |
+
for item in items:
|
| 51 |
+
question = item["question"]
|
| 52 |
+
answer = item["answer"]
|
| 53 |
+
context.append({
|
| 54 |
+
"question_id": question["question_id"],
|
| 55 |
+
"title": question["title"],
|
| 56 |
+
"question": plain(question["body"])[:5000],
|
| 57 |
+
"accepted_answer": plain(answer["body"])[:5000],
|
| 58 |
+
})
|
| 59 |
+
payload = {
|
| 60 |
+
"model": MODEL,
|
| 61 |
+
"messages": [
|
| 62 |
+
{
|
| 63 |
+
"role": "system",
|
| 64 |
+
"content": (
|
| 65 |
+
"Convert real Stack Overflow sed questions into executable evaluation tasks. Return only valid JSON "
|
| 66 |
+
"with a tasks array. Include only questions solvable by one POSIX sed command reading a single text "
|
| 67 |
+
"stream on stdin and writing to stdout. Skip multi-file, in-place editing, filename, pipeline, shell "
|
| 68 |
+
"variable, file access, subprocess, interactive, network, and general discussion questions. For each "
|
| 69 |
+
"suitable question return question_id, request, command, input_text, and validation_input. The request "
|
| 70 |
+
"must be a natural, self-contained English instruction preserving the question's intent. The command "
|
| 71 |
+
"must start with sed, contain exactly one expression and no filename, and use no options except -n or "
|
| 72 |
+
"-e. Do not use -i, r, R, w, W, e, pipes, or shell expansion. Prefer POSIX syntax but allow GNU sed "
|
| 73 |
+
"supported by the accepted answer, simplified only when needed for stdin and stdout. Provide two "
|
| 74 |
+
"different representative inputs with up to 8 lines each and the same schema. Do not hardcode answers "
|
| 75 |
+
"into the command. Do not include expected outputs; they will be computed by execution."
|
| 76 |
+
),
|
| 77 |
+
},
|
| 78 |
+
{"role": "user", "content": "Return {\"tasks\": [...]} or an empty list when unsuitable.\n" + json.dumps(context, ensure_ascii=False)},
|
| 79 |
+
],
|
| 80 |
+
"response_format": {"type": "json_object"},
|
| 81 |
+
"temperature": 0.2,
|
| 82 |
+
"max_tokens": 6000,
|
| 83 |
+
"reasoning": {"enabled": False},
|
| 84 |
+
}
|
| 85 |
+
request = urllib.request.Request(
|
| 86 |
+
os.environ["OPENROUTER_BASE_URL"].rstrip("/") + "/chat/completions",
|
| 87 |
+
data=json.dumps(payload).encode("utf-8"),
|
| 88 |
+
headers={"Authorization": "Bearer " + os.environ["OPENROUTER_API_KEY"], "Content-Type": "application/json"},
|
| 89 |
+
)
|
| 90 |
+
for attempt in range(5):
|
| 91 |
+
try:
|
| 92 |
+
with urllib.request.urlopen(request, timeout=180) as response:
|
| 93 |
+
data = json.load(response)
|
| 94 |
+
return json.loads(data["choices"][0]["message"]["content"])["tasks"]
|
| 95 |
+
except Exception:
|
| 96 |
+
if attempt == 4:
|
| 97 |
+
raise
|
| 98 |
+
time.sleep(min(30, 2 ** attempt))
|
| 99 |
+
raise AssertionError("unreachable")
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def main() -> None:
|
| 103 |
+
parser = argparse.ArgumentParser()
|
| 104 |
+
parser.add_argument("--questions", default=".tmp/sed-questions.json")
|
| 105 |
+
parser.add_argument("--answers", default=".tmp/sed-answers.json")
|
| 106 |
+
parser.add_argument("--output", default="sedweave-so.jsonl")
|
| 107 |
+
parser.add_argument("--raw-output", default=".tmp/sed-converted-raw.json")
|
| 108 |
+
parser.add_argument("--skipped-output", default=".tmp/sed-converted-skipped.json")
|
| 109 |
+
args = parser.parse_args()
|
| 110 |
+
questions = json.load(open(args.questions))["items"]
|
| 111 |
+
answers = json.load(open(args.answers))
|
| 112 |
+
items = []
|
| 113 |
+
for question in questions:
|
| 114 |
+
if "accepted_answer_id" in question:
|
| 115 |
+
items.append({"question": question, "answer": answers[str(question["accepted_answer_id"])]})
|
| 116 |
+
batches = [items[index:index + 4] for index in range(0, len(items), 4)]
|
| 117 |
+
raw = []
|
| 118 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
|
| 119 |
+
futures = {executor.submit(convert_batch, batch): batch for batch in batches}
|
| 120 |
+
for future in concurrent.futures.as_completed(futures):
|
| 121 |
+
try:
|
| 122 |
+
raw.extend(future.result())
|
| 123 |
+
except Exception as error:
|
| 124 |
+
print("batch failed", error, flush=True)
|
| 125 |
+
Path(args.raw_output).parent.mkdir(parents=True, exist_ok=True)
|
| 126 |
+
Path(args.raw_output).write_text(json.dumps(raw, indent=2), encoding="utf-8")
|
| 127 |
+
|
| 128 |
+
accepted = []
|
| 129 |
+
skipped = []
|
| 130 |
+
seen = set()
|
| 131 |
+
for item in raw:
|
| 132 |
+
question_id = item.get("question_id")
|
| 133 |
+
if question_id in seen:
|
| 134 |
+
continue
|
| 135 |
+
seen.add(question_id)
|
| 136 |
+
matching = next((entry for entry in items if entry["question"]["question_id"] == question_id), None)
|
| 137 |
+
if matching is None:
|
| 138 |
+
continue
|
| 139 |
+
try:
|
| 140 |
+
request_text = item["request"].strip()
|
| 141 |
+
command = item["command"].strip()
|
| 142 |
+
input_text = item["input_text"]
|
| 143 |
+
validation_input = item["validation_input"]
|
| 144 |
+
if not request_text or input_text == validation_input:
|
| 145 |
+
raise ValueError("Missing request or identical inputs")
|
| 146 |
+
expected = run_sed(command, input_text)
|
| 147 |
+
validation_expected = run_sed(command, validation_input)
|
| 148 |
+
if not expected.strip() or not validation_expected.strip():
|
| 149 |
+
raise ValueError("Empty output")
|
| 150 |
+
if expected == input_text and validation_expected == validation_input:
|
| 151 |
+
raise ValueError("No transformation")
|
| 152 |
+
question = matching["question"]
|
| 153 |
+
answer = matching["answer"]
|
| 154 |
+
accepted.append({
|
| 155 |
+
"id": f"so-{question_id}", "request": request_text, "command": command,
|
| 156 |
+
"input_text": input_text, "expected_output": expected,
|
| 157 |
+
"validation_input": validation_input, "validation_output": validation_expected,
|
| 158 |
+
"family": "real-stackoverflow", "difficulty": 3, "split": "test",
|
| 159 |
+
"source": "stackoverflow-accepted-answer", "license": "CC-BY-SA-4.0",
|
| 160 |
+
"question_url": question["link"], "question_title": question["title"],
|
| 161 |
+
"question_owner": question["owner"].get("display_name"),
|
| 162 |
+
"answer_owner": answer["owner"].get("display_name"),
|
| 163 |
+
"answer_id": answer["answer_id"], "question_score": question["score"],
|
| 164 |
+
})
|
| 165 |
+
except Exception as error:
|
| 166 |
+
skipped.append({"question_id": question_id, "reason": str(error)[:300]})
|
| 167 |
+
accepted.sort(key=lambda row: row["id"])
|
| 168 |
+
with open(args.output, "w", encoding="utf-8") as handle:
|
| 169 |
+
for row in accepted:
|
| 170 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 171 |
+
Path(args.skipped_output).write_text(json.dumps(skipped, indent=2), encoding="utf-8")
|
| 172 |
+
print(f"accepted {len(accepted)} tasks; skipped {len(skipped)} invalid tasks from {len(raw)} candidates")
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__":
|
| 176 |
+
main()
|
data/test.jsonl
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"so-10754682","request":"Wrap each line in double quotes, handling potential carriage returns at the end of lines by removing them before quoting.","command":"sed 's/\\r$//; s/.*/\"&\"/'","input_text":"name,id,3\r\nuser,pass,4\r\n","expected_output":"\"name,id,3\"\n\"user,pass,4\"\n","validation_input":"hello,world\r\ntest,data\r\n","validation_output":"\"hello,world\"\n\"test,data\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/10754682/how-to-add-double-quotes-to-a-line-with-sed-or-awk","question_title":"How to add double quotes to a line with SED or AWK?","question_owner":"minerals","answer_owner":"Dennis Williamson","answer_id":10755347,"question_score":31,"reviewed":true}
|
| 2 |
+
{"id":"so-11687216","request":"Remove all blank lines from the input text.","command":"sed '/^$/d'","input_text":"Line 1\n\nLine 3\n\nLine 5","expected_output":"Line 1\nLine 3\nLine 5","validation_input":"Hello\n\nWorld\n\nEnd","validation_output":"Hello\nWorld\nEnd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11687216/awk-to-skip-the-blank-lines","question_title":"Awk to skip the blank lines","question_owner":"Gil","answer_owner":"Levon","answer_id":11687266,"question_score":33,"reviewed":true}
|
| 3 |
+
{"id":"so-13202715","request":"Print only the lines that start with the prefix 'RIM-COD-' from the input text.","command":"sed -n -e '/^RIM-COD-/p'","input_text":"RIM-COD-URL-12: HelloWorld-12.cod\nRIM-COD-Size: 68020\nRIM-MIDlet-Icon-2-1: icon.png\nRIM-COD-URL-11: HelloWorld-11.cod","expected_output":"RIM-COD-URL-12: HelloWorld-12.cod\nRIM-COD-Size: 68020\nRIM-COD-URL-11: HelloWorld-11.cod","validation_input":"RIM-COD-URL-10: Test.cod\nOther-Line: Value\nRIM-COD-SHA1: abc123\nManifest-Version: 1.0","validation_output":"RIM-COD-URL-10: Test.cod\nRIM-COD-SHA1: abc123\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13202715/sed-get-lines-beginning-with-some-prefix","question_title":"Sed: get lines beginning with some prefix","question_owner":"CAMOBAP","answer_owner":"John3136","answer_id":13202727,"question_score":30,"reviewed":true}
|
| 4 |
+
{"id":"so-14046878","request":"Delete from the first line exactly matching '-----THIS STUFF IS USELESS-----' to the end of the input stream.","command":"sed '/^-----THIS STUFF IS USELESS-----$/,$d'","input_text":"Files:\nsomefiles.tar.gz 1 2 3\nsomefiles.tar.gz 1 2 3\n-----THIS STUFF IS USELESS-----\nBLEH BLEH BLEH\nBLEH BLEH BLEH","expected_output":"Files:\nsomefiles.tar.gz 1 2 3\nsomefiles.tar.gz 1 2 3\n","validation_input":"Header\nData Line 1\nData Line 2\n-----THIS STUFF IS USELESS-----\nFooter 1\nFooter 2","validation_output":"Header\nData Line 1\nData Line 2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/14046878/using-sed-to-match-a-pattern-and-deleting-from-the-line-to-the-end-of-the-file","question_title":"Using sed to match a pattern and deleting from the line to the end of the file","question_owner":"Albert H","answer_owner":"shellter","answer_id":14046990,"question_score":26,"reviewed":true}
|
| 5 |
+
{"id":"so-15632691","request":"Print only the first line of the input and then stop processing.","command":"sed -n '1{p;q}'","input_text":"Line 1\nLine 2\nLine 3","expected_output":"Line 1\n","validation_input":"First\nSecond\nThird\nFourth","validation_output":"First\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15632691/fastest-way-to-print-a-single-line-in-a-file","question_title":"Fastest way to print a single line in a file","question_owner":"JBoy","answer_owner":"Chris Seymour","answer_id":15632780,"question_score":25,"reviewed":true}
|
| 6 |
+
{"id":"so-1617724","request":"Replace all newline characters with tab characters in the input stream.","command":"sed ':a;N;$!ba;s/\\n/\\t/g'","input_text":"hi\nhello\nhallo\ngreetings","expected_output":"hi\thello\thallo\tgreetings","validation_input":"salutations\nno more hello for you","validation_output":"salutations\tno more hello for you","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1617724/how-to-replace-newlines-with-tab-characters","question_title":"How to replace newlines with tab characters?","question_owner":"Vijay","answer_owner":"ghostdog74","answer_id":1617769,"question_score":24,"reviewed":true}
|
| 7 |
+
{"id":"so-16202900","request":"Remove spaces following commas only within lines 2 through 3 of the input.","command":"sed '2,3s/,\\s\\+/,/g'","input_text":"Line 1, with space\nLine 2, with space\nLine 3, with space\nLine 4, with space","expected_output":"Line 1, with space\nLine 2,with space\nLine 3,with space\nLine 4, with space","validation_input":"a, b\nb, c\nc, d\nd, e","validation_output":"a, b\nb,c\nc,d\nd, e","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16202900/using-sed-between-specific-lines-only","question_title":"Using sed between specific lines only","question_owner":"hackio","answer_owner":"anubhava","answer_id":16202932,"question_score":26,"reviewed":true}
|
| 8 |
+
{"id":"so-16576197","request":"Insert a newline between '</a>' and '<a><a>' in the input stream.","command":"sed 's#</a><a><a>#</a>\\\n<a><a>#g'","input_text":"</a><a><a>\nsome text </a><a><a> more text","expected_output":"</a>\n<a><a>\nsome text </a>\n<a><a> more text","validation_input":"prefix</a><a><a>suffix\n</a><a><a>","validation_output":"prefix</a>\n<a><a>suffix\n</a>\n<a><a>","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16576197/how-to-add-new-line-using-sed-on-macos","question_title":"How to add new line using sed on MacOS?","question_owner":"codereviewanskquestions","answer_owner":"Kevin","answer_id":16576291,"question_score":26,"reviewed":true}
|
| 9 |
+
{"id":"so-18602234","request":"Remove the period and everything following it on each line.","command":"sed 's/\\..*$//'","input_text":"95 flour.\n47 water.s\netc..","expected_output":"95 flour\n47 water\netc","validation_input":"hello.world\ntest.case.end","validation_output":"hello\ntest","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18602234/sed-to-remove-everything-after-in-file-using-command","question_title":"Sed to remove everything after "." in file using * command?","question_owner":"Novice","answer_owner":"Adam Rosenfield","answer_id":18602273,"question_score":25,"reviewed":true}
|
| 10 |
+
{"id":"so-20568515","request":"Replace the value of the variable VAR5 with VALUE10 in a configuration file content, keeping the key name intact.","command":"sed 's/^\\(VAR5=\\).*/\\1VALUE10/'","input_text":"VAR1=VALUE1\nVAR2=VALUE2\nVAR3=VALUE3\nVAR4=VALUE4\nVAR5=VALUE5\nVAR6=VALUE6","expected_output":"VAR1=VALUE1\nVAR2=VALUE2\nVAR3=VALUE3\nVAR4=VALUE4\nVAR5=VALUE10\nVAR6=VALUE6","validation_input":"KEY=OLD\nVAR5=SOMETHING\nOTHER=DATA","validation_output":"KEY=OLD\nVAR5=VALUE10\nOTHER=DATA","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20568515/how-to-use-sed-to-replace-a-config-files-variable","question_title":"How to use sed to replace a config file's variable?","question_owner":"SomeGuyOnAComputer","answer_owner":"anubhava","answer_id":20568559,"question_score":32,"reviewed":true}
|
| 11 |
+
{"id":"so-22159044","request":"Append the string ' myalias' to the end of any line containing '192.168.1.2'.","command":"sed '/192.168.1.2/s/$/ myalias/'","input_text":"192.168.1.1 www.address1.com\n192.168.1.2 www.address2.com\n192.168.1.3 www.address3.com","expected_output":"192.168.1.1 www.address1.com\n192.168.1.2 www.address2.com myalias\n192.168.1.3 www.address3.com","validation_input":"10.0.0.1 host1\n192.168.1.2 host2\n10.0.0.3 host3","validation_output":"10.0.0.1 host1\n192.168.1.2 host2 myalias\n10.0.0.3 host3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/22159044/how-to-append-a-string-at-end-of-a-specific-line-in-a-file-in-bash","question_title":"How to append a string at end of a specific line in a file in bash","question_owner":"Chris F","answer_owner":"Steve","answer_id":22159086,"question_score":30,"reviewed":true}
|
| 12 |
+
{"id":"so-22939323","request":"Replace sequences of two or more spaces with a single space in the input text.","command":"sed -e 's/ */ /g'","input_text":"iiHi Hello Hi\nthis is loga","expected_output":"iiHi Hello Hi\nthis is loga","validation_input":"a b c d\ne f","validation_output":"a b c d\ne f","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/22939323/sed-command-to-replace-multiple-spaces-into-single-spaces","question_title":"sed command to replace multiple spaces into single spaces","question_owner":"logan","answer_owner":"John Zwinck","answer_id":22939416,"question_score":25,"reviewed":true}
|
| 13 |
+
{"id":"so-24427009","request":"Extract the last three characters from every line of the input.","command":"sed -e 's/^.*\\(...\\)$/\\1/'","input_text":"hello\nworld\nabcdef","expected_output":"llo\nrld\ndef","validation_input":"short\nlonger string\nxyz","validation_output":"ort\ning\nxyz","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24427009/is-there-a-cleaner-way-of-getting-the-last-n-characters-of-every-line","question_title":"Is there a cleaner way of getting the last N characters of every line?","question_owner":"merlin2011","answer_owner":"Tiago Lopo","answer_id":24427087,"question_score":32,"reviewed":true}
|
| 14 |
+
{"id":"so-25491847","request":"Extract only the second word from each line of text.","command":"sed -n 's/^[[:space:]]*[^[:space:]]*[[:space:]]\\+\\([^[:space:]]*\\).*/\\1/p'","input_text":"* CRISTOBAL AL042014 08/05/14 12 UTC *\nthis is a test","expected_output":"CRISTOBAL\nis","validation_input":" hello world foo\none two","validation_output":"world\ntwo","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25491847/extract-the-second-word-in-a-line-from-a-text-file","question_title":"Extract The Second Word In A Line From A Text File","question_owner":"Aaron Perry","answer_owner":"zedfoxus","answer_id":25491964,"question_score":32,"reviewed":true}
|
| 15 |
+
{"id":"so-28795479","request":"Convert camelCase text to underscore_case by inserting an underscore before uppercase letters and lowercasing them.","command":"sed 's/\\([a-z0-9]\\)\\([A-Z]\\)/\\1_\\2/g; s/.*/\\L&/'","input_text":"fooBar\nmyVariableName\nsimpleTest","expected_output":"foo_bar\nmy_variable_name\nsimple_test","validation_input":"getUserName\nparseXMLData","validation_output":"get_user_name\nparse_xmldata","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28795479/awk-sed-script-to-convert-a-file-from-camelcase-to-underscores","question_title":"Awk/sed script to convert a file from camelCase to underscores","question_owner":"Corentin Peuvrel","answer_owner":"Avinash Raj","answer_id":28795550,"question_score":25,"reviewed":true}
|
| 16 |
+
{"id":"so-31903432","request":"Replace all tab characters with four spaces in the input text.","command":"sed 's/\\t/ /g'","input_text":"col1\tcol2\tcol3\nval1\tval2\tval3","expected_output":"col1 col2 col3\nval1 val2 val3","validation_input":"a\tb\n\tc","validation_output":"a b\n c","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31903432/using-sed-to-replace-tab-with-spaces","question_title":"Using sed to replace tab with spaces","question_owner":"manshuai","answer_owner":"anubhava","answer_id":31903444,"question_score":28,"reviewed":true}
|
| 17 |
+
{"id":"so-31911179","request":"Delete the first line of the input stream.","command":"sed '1d'","input_text":"Header\nLine1\nLine2","expected_output":"Line1\nLine2","validation_input":"Title\nData A\nData B","validation_output":"Data A\nData B","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31911179/ignoring-first-line-column-header-while-reading-a-file-in-bash","question_title":"Ignoring First line/Column header while reading a file in bash","question_owner":"Jai","answer_owner":"chepner","answer_id":31911198,"question_score":28,"reviewed":true}
|
| 18 |
+
{"id":"so-3194534","request":"Join every pair of consecutive lines by appending the second line to the first, effectively merging line 2 into line 1, line 4 into line 3, and so on.","command":"sed '$!N;s/\\n//'","input_text":"abcd\njoinabcd\nefgh\njoinefgh\nijkl\njoinijkl","expected_output":"abcdjoinabcd\nefghjoinefgh\nijkljoinijkl","validation_input":"line1\nline2\nline3\nline4","validation_output":"line1line2\nline3line4","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3194534/joining-two-consecutive-lines-using-awk-or-sed","question_title":"Joining two consecutive lines using awk or sed","question_owner":"Vijay","answer_owner":"Dimitre Radoulov","answer_id":3196948,"question_score":26,"reviewed":true}
|
| 19 |
+
{"id":"so-3302434","request":"Remove the substring 'ko:' from each line, keeping the rest of the text intact.","command":"sed 's/ko://'","input_text":"ko04062 ko:CXCR3\nko04062 ko:CX3CR1\nko04062 ko:CCL3","expected_output":"ko04062 CXCR3\nko04062 CX3CR1\nko04062 CCL3","validation_input":"ko04080 ko:GZMA\nko05414 ko:ITGA4","validation_output":"ko04080 GZMA\nko05414 ITGA4","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3302434/capturing-groups-in-sed","question_title":"capturing groups in sed","question_owner":"Mike Dewar","answer_owner":"ninjalj","answer_id":3302593,"question_score":25,"reviewed":true}
|
| 20 |
+
{"id":"so-34576667","request":"Replace the text 'Foo' with 'Bar' in the input stream.","command":"sed -e 's/Foo/Bar/'","input_text":"Foo","expected_output":"Bar","validation_input":"Hello Foo World","validation_output":"Hello Bar World","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34576667/sed-unescaped-newline-inside-substitute-pattern","question_title":"sed: unescaped newline inside substitute pattern?","question_owner":"RocketNuts","answer_owner":"anubhava","answer_id":34576684,"question_score":30,"reviewed":true}
|
| 21 |
+
{"id":"so-3576139","request":"Remove the string 'line number' only if it appears in the last line of the input.","command":"sed '$ s/line number//g'","input_text":"first line number\nsecond line number\nlast line number","expected_output":"first line number\nsecond line number\nlast ","validation_input":"keep line number\nremove line number","validation_output":"keep line number\nremove ","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3576139/sed-remove-string-only-in-the-last-line-of-the-file","question_title":"sed + remove string only in the last line of the file","question_owner":"lidia","answer_owner":"Scharron","answer_id":3576183,"question_score":31,"reviewed":true}
|
| 22 |
+
{"id":"so-39198780","request":"Replace all newline characters with a single space in the input stream.","command":"sed ':a;N;$!ba;s/\\n/ /g'","input_text":"my\nname\nis\nxxxx","expected_output":"my name is xxxx","validation_input":"hello\nworld","validation_output":"hello world","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39198780/replace-nnew-line-with-space-in-bash","question_title":"Replace \\n(new line) with space in bash","question_owner":"Prometheus","answer_owner":"Cyrus","answer_id":39198829,"question_score":24,"reviewed":true}
|
| 23 |
+
{"id":"so-39648222","request":"Convert a multi-line text stream into a single line by replacing all newline characters with spaces, effectively joining the lines.","command":"sed ':a;N;$!ba;s/\\n/ /g'","input_text":"{\n\"key\": \"value\"\n}","expected_output":"{ \"key\": \"value\" }","validation_input":"Line 1\nLine 2\nLine 3","validation_output":"Line 1 Line 2 Line 3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39648222/converting-json-pretty-print-to-one-line","question_title":"Converting JSON pretty print to one line","question_owner":"h.b","answer_owner":"P....","answer_id":39653559,"question_score":29,"reviewed":true}
|
| 24 |
+
{"id":"so-40506782","request":"Remove all characters from the beginning of each line up to and including the first occurrence of the digit '2'.","command":"sed 's/^[^2]*2//'","input_text":"ananas1kiwi2apple1banana2tree\nhello2world\ntest","expected_output":"apple1banana2tree\nworld\ntest","validation_input":"abc2def2ghi\nno_match_here\n123","validation_output":"def2ghi\nno_match_here\n3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40506782/delete-everyting-preceding-and-including-a-certain-substring-from-variable","question_title":"Delete everyting preceding and including a certain substring from variable","question_owner":"Anne K.","answer_owner":"heemayl","answer_id":40506863,"question_score":27,"reviewed":true}
|
| 25 |
+
{"id":"so-5024357","request":"Read lines from standard input and print them until a line containing the exact string 'EOF' is encountered. The line containing 'EOF' should also be printed, and then the program should stop processing further input.","command":"sed '/EOF/q'","input_text":"Line 1\nLine 2\nThis is EOF\nLine 4","expected_output":"Line 1\nLine 2\nThis is EOF\n","validation_input":"Start\nMiddle\nEnd with EOF marker\nIgnored line","validation_output":"Start\nMiddle\nEnd with EOF marker\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5024357/do-a-tail-f-until-matching-a-pattern","question_title":"Do a tail -F until matching a pattern","question_owner":"Sam Alba","answer_owner":"jpetazzo","answer_id":5033775,"question_score":27,"reviewed":true}
|
| 26 |
+
{"id":"so-5544322","request":"Extract and clean the value from lines starting with 'Important1: ', removing the prefix and surrounding whitespace, while suppressing all other lines.","command":"sed -n 's/^Important1: *\\([^ ]*\\) */\\1/p'","input_text":"Bla\nBla\nImportant1: One \nBla\nImportant2: Two\nBla\nBla","expected_output":"One\n","validation_input":"Ignore this\nImportant1: Value \nIgnore that\nImportant1: Another","validation_output":"Value\nAnother","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5544322/sed-get-only-the-replaced-string-from-a-multiline-input-omit-unmatched-lines","question_title":"sed - Get only the replaced string from a multiline input & omit unmatched lines!","question_owner":"porg","answer_owner":"anubhava","answer_id":5544539,"question_score":26,"reviewed":true}
|
| 27 |
+
{"id":"so-6006132","request":"Print only the lines that do not end with the string 'abcd'.","command":"sed -n '/abcd$/!p'","input_text":"this is abcd\nthis is not\nanother abcd\nend","expected_output":"this is not\nend","validation_input":"xyzabcd\nkeep this line\nfoo bar abcd\nretain","validation_output":"keep this line\nretain","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6006132/grep-line-of-text-that-does-not-end-with-abcd","question_title":"Grep. Line of text that does not end with "abcd"?","question_owner":"CCC","answer_owner":"tobyodavies","answer_id":6006139,"question_score":27,"reviewed":true}
|
| 28 |
+
{"id":"so-6011661","request":"Extract the two-digit number surrounded by identical non-digit characters from each line. If a line does not match this pattern, produce no output for that line.","command":"sed -n 's/^.*\\(.\\)\\([0-9][0-9]\\)\\1.*$/\\2/p'","input_text":"plop-02-plop\nabcX99Xdef\nno-match-here\nz55z","expected_output":"02\n99\n55","validation_input":"testA12Aend\nfailB1C\nok_77_","validation_output":"12\n77","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6011661/regexp-sed-suppress-no-match-output","question_title":"regexp (sed) suppress "no match" output","question_owner":"yPhil","answer_owner":"przemoc","answer_id":6011704,"question_score":28,"reviewed":true}
|
| 29 |
+
{"id":"so-6869449","request":"Delete lines matching the regex '^Name' but skip the first line of the input.","command":"sed -e '2,${ /^Name/d }'","input_text":"Name\nJohn\nAlbert\nMora\nName\nTommy\nTammy","expected_output":"Name\nJohn\nAlbert\nMora\nTommy\nTammy","validation_input":"Header\nData1\nHeader\nData2\nFooter","validation_output":"Header\nData1\nHeader\nData2\nFooter","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6869449/skipping-the-first-n-lines-when-using-regex-with-sed","question_title":"Skipping the first n lines when using regex with sed?","question_owner":"Legend","answer_owner":"a'r","answer_id":6869486,"question_score":26,"reviewed":true}
|
| 30 |
+
{"id":"so-689495","request":"Convert the uppercase letter immediately following an underscore in identifiers starting with 'get' to lowercase.","command":"sed -e 's/\\(get[A-Z][A-Za-z0-9]*_\\)\\([A-Z]\\)/\\1\\L\\2/g'","input_text":"getFoo_Bar\ngetBaz_Qux","expected_output":"getFoo_bar\ngetBaz_qux","validation_input":"getX_Y\ngetAb_Cd_Ef","validation_output":"getX_y\ngetAb_cd_Ef","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/689495/upper-to-lower-case-using-sed","question_title":"upper- to lower-case using sed","question_owner":"cadrian","answer_owner":"strager","answer_id":689608,"question_score":25,"reviewed":true}
|
| 31 |
+
{"id":"so-8225822","request":"Replace all occurrences of 'A' with 'a' and only print lines where a substitution was made.","command":"sed -n 's/A/a/gp'","input_text":"Apple\nBanana\nAvocado","expected_output":"apple\navocado","validation_input":"ABC\nXYZ\nA123","validation_output":"aBC\na123","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8225822/how-to-make-sed-remove-lines-not-matched-by-a-substitution","question_title":"How to make sed remove lines not matched by a substitution","question_owner":"Ropez","answer_owner":"jaypal singh","answer_id":8255627,"question_score":28,"reviewed":true}
|
| 32 |
+
{"id":"so-8356958","request":"Remove the prefix 'foo: ' from the beginning of each line in the input text.","command":"sed 's/^foo: //'","input_text":"foo: bar1\nfoo: bar2\nfoo: bar3","expected_output":"bar1\nbar2\nbar3","validation_input":"foo: hello world\nfoo: test case\nno match here","validation_output":"hello world\ntest case\nno match here","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8356958/sed-just-trying-to-remove-a-substring","question_title":"sed: just trying to remove a substring","question_owner":"user1077220","answer_owner":"aefxx","answer_id":8356980,"question_score":28,"reviewed":true}
|
| 33 |
+
{"id":"so-8394066","request":"Insert a line containing two words separated by a tab character at the beginning of the input.","command":"sed '1i\\\nword1\tword2'","input_text":"Existing line 1\nExisting line 2","expected_output":"word1\tword2\nExisting line 1\nExisting line 2","validation_input":"Data start","validation_output":"word1\tword2\nData start","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8394066/what-is-the-proper-way-to-insert-tab-in-sed","question_title":"What is the proper way to insert tab in sed?","question_owner":"dabest1","answer_owner":"Jonathan Leffler","answer_id":8394150,"question_score":33,"reviewed":true}
|
| 34 |
+
{"id":"so-8991275","request":"Replace the character 'b' with a newline in the input stream.","command":"sed 's/b/\\\n/'","input_text":"abc","expected_output":"a\nc","validation_input":"xbx","validation_output":"x\nx","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8991275/escaping-newlines-in-sed-replacement-string","question_title":"escaping newlines in sed replacement string","question_owner":"spraff","answer_owner":"jaypal singh","answer_id":8991356,"question_score":29,"reviewed":true}
|
| 35 |
+
{"id":"so-9191030","request":"Remove all occurrences of the substring 'ABC' from the end of each line.","command":"sed 's/\\(ABC\\)*$//'","input_text":"DAAAAABCBBBCCABCABC\nHelloABC\nWorld","expected_output":"DAAAAABCBBBCC\nHello\nWorld","validation_input":"TestABCABC\nNoChange\nEndABC","validation_output":"Test\nNoChange\nEnd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9191030/removing-pattern-at-the-end-of-a-string-using-sed-or-other-bash-tools","question_title":"Removing pattern at the end of a string using sed or other bash tools","question_owner":"Kay Chan","answer_owner":"Birei","answer_id":9191062,"question_score":30,"reviewed":true}
|
| 36 |
+
{"id":"so-9260625","request":"Extract the first sequence of digits from each line of input text.","command":"sed -n 's/^[^0-9]*\\([0-9][0-9]*\\).*/\\1/p'","input_text":"This is an example: 65 apples\nThere are 123 items here","expected_output":"65\n123","validation_input":"No numbers in this line\nValue is 42 and count is 7","validation_output":"42","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9260625/sed-extracting-group-of-digits","question_title":"sed extracting group of digits","question_owner":"Uthman","answer_owner":"codaddict","answer_id":9260734,"question_score":24,"reviewed":true}
|
| 37 |
+
{"id":"so-9970124","request":"Insert the line 'New Inserted Line' immediately after the first occurrence of 'Matched Keyword', before any remaining text on that line.","command":"sed '0,/Matched Keyword/s//Matched Keyword\\nNew Inserted Line/'","input_text":"Line 1\nLine 2\nThis line contains the Matched Keyword and other stuff\nLine 4\nThis line contains the Matched Keyword and other stuff\nLine 6","expected_output":"Line 1\nLine 2\nThis line contains the Matched Keyword\nNew Inserted Line and other stuff\nLine 4\nThis line contains the Matched Keyword and other stuff\nLine 6","validation_input":"Start\nMiddle Matched Keyword End\nEnd Matched Keyword Start\nFinish","validation_output":"Start\nMiddle Matched Keyword\nNew Inserted Line End\nEnd Matched Keyword Start\nFinish","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9970124/sed-to-insert-on-first-match-only","question_title":"sed to insert on first match only","question_owner":"SSS","answer_owner":"Squazic","answer_id":9970467,"question_score":26,"reviewed":true}
|
data/train.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation.jsonl
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"so-1032023","request":"Replace all occurrences of the whole word 'bar' with 'no bar' in the input text, ensuring that partial matches like 'embarassment' are not affected.","command":"sed 's/\\bbar\\b/no bar/g'","input_text":"bar embarassment\nbar foo bar\nfoobar","expected_output":"no bar embarassment\nno bar foo no bar\nfoobar","validation_input":"start bar end\nno bar here\nbarbell","validation_output":"start no bar end\nno no bar here\nbarbell","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1032023/sed-whole-word-search-and-replace","question_title":"sed whole word search and replace","question_owner":"ksuralta","answer_owner":"Joakim Lundborg","answer_id":1032039,"question_score":159,"reviewed":true}
|
| 2 |
+
{"id":"so-11145270","request":"Replace the entire third line of the input text with the string 'replacement-line'.","command":"sed '3s/.*/replacement-line/'","input_text":"Line one\nLine two\nLine three\nLine four","expected_output":"Line one\nLine two\nreplacement-line\nLine four","validation_input":"Alpha\nBeta\nGamma\nDelta\nEpsilon","validation_output":"Alpha\nBeta\nreplacement-line\nDelta\nEpsilon","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11145270/how-to-replace-an-entire-line-in-a-text-file-by-line-number","question_title":"How to replace an entire line in a text file by line number","question_owner":"user788171","answer_owner":"chepner","answer_id":11145362,"question_score":225,"reviewed":true}
|
| 3 |
+
{"id":"so-11245144","request":"Replace any line containing the string 'TEXT_TO_BE_REPLACED' with the text 'This line is removed by the admin.'","command":"sed '/TEXT_TO_BE_REPLACED/c\\This line is removed by the admin.'","input_text":"sometext sometext sometext TEXT_TO_BE_REPLACED sometext sometext sometext\nother line\nanother line with TEXT_TO_BE_REPLACED here","expected_output":"This line is removed by the admin.\nother line\nThis line is removed by the admin.\n","validation_input":"line one\nTEXT_TO_BE_REPLACED\nline three","validation_output":"line one\nThis line is removed by the admin.\nline three","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11245144/replace-whole-line-containing-a-string-using-sed","question_title":"Replace whole line containing a string using Sed","question_owner":"Rahul","answer_owner":"Todd A. Jacobs","answer_id":11245501,"question_score":472,"reviewed":true}
|
| 4 |
+
{"id":"so-11469989","request":"Remove the first 4 characters from each line of input.","command":"sed 's/^....//'","input_text":"pid: 1234\nname: test","expected_output":" 1234\n: test","validation_input":"code: ABCD\nid: 9999","validation_output":": ABCD\n9999","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11469989/how-can-i-strip-first-x-characters-from-string-using-sed","question_title":"How can I strip first X characters from string using sed?","question_owner":"Kokesh","answer_owner":"Arnaud F.","answer_id":11470076,"question_score":174,"reviewed":true}
|
| 5 |
+
{"id":"so-11568859","request":"Extract the first sequence of digits followed by 'G' and more digits from each line, printing only the match.","command":"sed -n 's/^[^0-9]*\\([0-9][0-9]*G[0-9][0-9]*\\).*/\\1/p'","input_text":"This is 02G05 a test string 20-Jul-2012","expected_output":"02G05","validation_input":"No match here\nCode 123G456 found\n9G1 end","validation_output":"123G456\n9G1","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11568859/how-to-extract-text-from-a-string-using-sed","question_title":"How to extract text from a string using sed?","question_owner":"RanRag","answer_owner":"tripleee","answer_id":11568930,"question_score":130,"reviewed":true}
|
| 6 |
+
{"id":"so-13055889","request":"Replace all commas with a comma surrounded by single quotes in the input text.","command":"sed \"s/,/','/g\"","input_text":"A,B,C","expected_output":"A','B','C","validation_input":"X,Y,Z\n1,2","validation_output":"X','Y','Z\n1','2","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13055889/sed-with-literal-string-not-input-file","question_title":"sed with literal string--not input file","question_owner":"amphibient","answer_owner":"Gilles Quénot","answer_id":13055913,"question_score":135,"reviewed":true}
|
| 7 |
+
{"id":"so-13242469","request":"Extract the text between the words 'Here' and 'String' on a single line, removing the words themselves.","command":"sed 's/^.*Here\\(.*\\)String.*$/\\1/'","input_text":"Here is a String","expected_output":" is a ","validation_input":"Here we go String now","validation_output":" we go ","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13242469/how-to-use-sed-grep-to-extract-text-between-two-words","question_title":"How to use sed/grep to extract text between two words?","question_owner":"user1190650","answer_owner":"Brian Campbell","answer_id":13242517,"question_score":228,"reviewed":true}
|
| 8 |
+
{"id":"so-1429556","request":"Print only the second line of the input stream.","command":"sed -n '2p'","input_text":"first line\nsecond line\nthird line","expected_output":"second line\n","validation_input":"alpha\nbeta\ngamma\ndelta","validation_output":"beta\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1429556/command-to-get-nth-line-of-stdout","question_title":"Command to get nth line of STDOUT","question_owner":"Alana Storm","answer_owner":"Jonathan Leffler","answer_id":1429628,"question_score":277,"reviewed":true}
|
| 9 |
+
{"id":"so-14671293","request":"Remove all sequences of digits from the input text using a POSIX-compatible character class.","command":"sed 's/[[:digit:]]\\+//g'","input_text":"abc123def456\n789xyz","expected_output":"abcdef\nxyz","validation_input":"no digits here\n1a2b3c","validation_output":"no digits here\nabc","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/14671293/why-doesnt-d-work-in-regular-expressions-in-sed","question_title":"Why doesn't `\\d` work in regular expressions in sed?","question_owner":"user2036880","answer_owner":"Kamil","answer_id":14671415,"question_score":105,"reviewed":true}
|
| 10 |
+
{"id":"so-148451","request":"Replace only the first occurrence of the string 'foo' with 'bar' in the input stream.","command":"sed '0,/foo/s//bar/'","input_text":"foo baz\nfoo qux\nfoo end","expected_output":"bar baz\nfoo qux\nfoo end","validation_input":"no match here\nfoo match here\nfoo another","validation_output":"no match here\nbar match here\nfoo another","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file","question_title":"How to use sed to replace only the first occurrence in a file?","question_owner":"David Dibben","answer_owner":"Ben Hoffstein","answer_id":148473,"question_score":346,"reviewed":true}
|
| 11 |
+
{"id":"so-15559359","request":"Insert the line 'CLIENTSCRIPT2=\"hello\"' after the first line that matches 'CLIENTSCRIPT=\"foo\"'.","command":"sed '/CLIENTSCRIPT=\"foo\"/a\\\nCLIENTSCRIPT2=\"hello\"'","input_text":"CLIENTSCRIPT=\"foo\"\nCLIENTFILE=\"bar\"","expected_output":"CLIENTSCRIPT=\"foo\"\nCLIENTSCRIPT2=\"hello\"\nCLIENTFILE=\"bar\"","validation_input":"line1\nCLIENTSCRIPT=\"foo\"\nline3","validation_output":"line1\nCLIENTSCRIPT=\"foo\"\nCLIENTSCRIPT2=\"hello\"\nline3","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15559359/insert-line-after-match-using-sed","question_title":"Insert line after match using sed","question_owner":"user2150250","answer_owner":"Gilles Quénot","answer_id":15559399,"question_score":371,"reviewed":true}
|
| 12 |
+
{"id":"so-15849119","request":"Replace all occurrences of the word 'dog' with 'log' in each line of the input.","command":"sed -e 's/dog/log/g'","input_text":"dog dog dos","expected_output":"log log dos","validation_input":"a dog b dog c","validation_output":"a log b log c","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15849119/why-does-sed-not-replace-all-occurrences","question_title":"Why does sed not replace all occurrences?","question_owner":"Nishant George Agrwal","answer_owner":"Bruno Reis","answer_id":15849152,"question_score":188,"reviewed":true}
|
| 13 |
+
{"id":"so-16414410","request":"Remove all lines that are empty or contain only whitespace characters from the input text.","command":"sed '/^[[:space:]]*$/d'","input_text":"xxxxxx\n \n\nyyyyyy\n\t\nzzzzzz","expected_output":"xxxxxx\nyyyyyy\nzzzzzz","validation_input":"hello\n \nworld\n\nfoo","validation_output":"hello\nworld\nfoo","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16414410/delete-empty-lines-using-sed","question_title":"Delete empty lines using sed","question_owner":"jonas","answer_owner":"Kent","answer_id":16414489,"question_score":530,"reviewed":true}
|
| 14 |
+
{"id":"so-1665549","request":"Extract the filename from lines matching the pattern '[wrote filename.class]' and suppress all other lines.","command":"sed -n 's/^\\[wrote \\(.*\\.class\\)\\]$/\\1/p'","input_text":"[wrote some-class-name.class]","expected_output":"some-class-name.class","validation_input":"[wrote Main.class]\ncompiling...\n[wrote Utils.class]","validation_output":"Main.class\nUtils.class","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1665549/have-sed-ignore-non-matching-lines","question_title":"Have sed ignore non-matching lines","question_owner":"Paggas","answer_owner":"liori","answer_id":1665662,"question_score":138,"reviewed":true}
|
| 15 |
+
{"id":"so-1706431","request":"Replace all spaces in the input with underscores.","command":"sed 's/ /_/g'","input_text":"This is just a test\nWindows XP","expected_output":"This_is_just_a_test\nWindows_XP","validation_input":"Hello World Foo Bar\nMy File Name.txt","validation_output":"Hello_World_Foo_Bar\nMy_File_Name.txt","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1706431/the-easiest-way-to-replace-white-spaces-with-underscores-in-bash","question_title":"The easiest way to replace white spaces with (underscores) _ in bash","question_owner":"flazzarini","answer_owner":"ghostdog74","answer_id":1706459,"question_score":107,"reviewed":true}
|
| 16 |
+
{"id":"so-17511639","request":"Extract and print only the last integer and floating-point number (separated by whitespace) from each line, ignoring preceding text.","command":"sed -n 's/^.*[^0-9]\\([0-9][0-9]*\\)[ \\t]\\([0-9][0-9]*\\.[0-9][0-9]*\\)[ \\t]*$/\\1 \\2/p'","input_text":"foo bar <foo> bla 1 2 3.4\nno match here\nvalues 10 20.5","expected_output":"2 3.4\n10 20.5","validation_input":"test 5 6.7\nabc 123 456.789\nnothing","validation_output":"5 6.7\n123 456.789\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/17511639/sed-print-only-matching-group","question_title":"sed: print only matching group","question_owner":"mort","answer_owner":"iruvar","answer_id":17511700,"question_score":205,"reviewed":true}
|
| 17 |
+
{"id":"so-18439528","request":"Insert the line ' hello world' (with three leading spaces) before the second line of the input text.","command":"sed '2i\\ hello world'","input_text":"hello\nworld","expected_output":"hello\n hello world\nworld","validation_input":"line1\nline2\nline3","validation_output":"line1\n hello world\nline2\nline3","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18439528/sed-insert-line-with-leading-spaces-to-a-specific-line","question_title":"sed insert line with leading spaces to a specific line","question_owner":"Ggdw","answer_owner":"Atropo","answer_id":18439749,"question_score":120,"reviewed":true}
|
| 18 |
+
{"id":"so-20348097","request":"Remove the colon and everything after it from each line of input.","command":"sed 's/:.*//'","input_text":"/some/random/file.csv:some string\n/some/random/file2.csv:some string2","expected_output":"/some/random/file.csv\n/some/random/file2.csv","validation_input":"path/to/data.txt:value here\nanother/path.log:more data","validation_output":"path/to/data.txt\nanother/path.log","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon","question_title":"bash, extract string before a colon","question_owner":"user788171","answer_owner":"ray","answer_id":20348145,"question_score":111,"reviewed":true}
|
| 19 |
+
{"id":"so-2112469","request":"Delete lines 5 through 10 and line 12 from the input text.","command":"sed -e '5,10d;12d'","input_text":"Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8","expected_output":"Line 1\nLine 2\nLine 3\nLine 4\n","validation_input":"A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM","validation_output":"A\nB\nC\nD\nK\nM","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2112469/delete-specific-line-numbers-from-a-text-file-using-sed","question_title":"Delete specific line number(s) from a text file using sed?","question_owner":"Justin Ethier","answer_owner":"Brian Campbell","answer_id":2112496,"question_score":367,"reviewed":true}
|
| 20 |
+
{"id":"so-24509214","request":"Replace the string 'ones' with 'one's' in the input text using sed.","command":"sed \"s/ones/one's/g\"","input_text":"ones thing","expected_output":"one's thing","validation_input":"ones and ones again","validation_output":"one's and one's again","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24509214/how-to-escape-single-quote-in-sed","question_title":"How to escape single quote in sed?","question_owner":"Thomas Bratt","answer_owner":"Kent","answer_id":24509931,"question_score":148,"reviewed":true}
|
| 21 |
+
{"id":"so-2610115","request":"Insert a literal tab character at the beginning of every line in the input.","command":"sed 's/^/\t/'","input_text":"hello\nworld","expected_output":"\thello\n\tworld","validation_input":"foo\nbar\nbaz","validation_output":"\tfoo\n\tbar\n\tbaz","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2610115/why-is-sed-not-recognizing-t-as-a-tab","question_title":"Why is sed not recognizing \\t as a tab?","question_owner":"sixtyfootersdude","answer_owner":"Mark Byers","answer_id":2610121,"question_score":132,"reviewed":true}
|
| 22 |
+
{"id":"so-26568952","request":"Swap all occurrences of 'ab' with 'bc' and 'bc' with 'ab' simultaneously in the input stream, assuming '~' does not appear in the text.","command":"sed 's/ab/~~/g; s/bc/ab/g; s/~~/bc/g'","input_text":"abbc","expected_output":"bcab","validation_input":"abc ab bc","validation_output":"bcc bc ab","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/26568952/how-to-swap-text-based-on-patterns-at-once-with-sed","question_title":"How to swap text based on patterns at once with sed?","question_owner":"DaniloNC","answer_owner":"ooga","answer_id":26568996,"question_score":344,"reviewed":true}
|
| 23 |
+
{"id":"so-2777579","request":"Extract only the sequences of digits from each line, separated by a space. If a line has multiple digit sequences, print them all on one line separated by spaces. If no digits, print nothing for that line.","command":"sed -n 's/[^0-9][^0-9]*/ /g; s/^ *//; s/ *$//; /[0-9]/p'","input_text":"This is a sample 123 text and some 987 numbers\nno numbers here\nabc 42 def","expected_output":"123 987\n42","validation_input":"start 10 middle 20 end\njust text\n555","validation_output":"10 20\n555","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2777579/how-can-i-output-only-captured-groups-with-sed","question_title":"How can I output only captured groups with sed?","question_owner":"Pablo","answer_owner":"Dennis Williamson","answer_id":2778096,"question_score":426,"reviewed":true}
|
| 24 |
+
{"id":"so-2869669","request":"Append the string 'string after each line' to the end of every line in the input.","command":"sed -e 's/$/string after each line/'","input_text":"Line one\nLine two\nLine three","expected_output":"Line onestring after each line\nLine twostring after each line\nLine threestring after each line","validation_input":"Hello World\nFoo Bar","validation_output":"Hello Worldstring after each line\nFoo Barstring after each line","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2869669/in-bash-how-do-i-add-a-string-after-each-line-in-a-file","question_title":"In Bash, how do I add a string after each line in a file?","question_owner":"Jason Volkoz","answer_owner":"Tom DeGisi","answer_id":2869736,"question_score":170,"reviewed":true}
|
| 25 |
+
{"id":"so-3134791","request":"Remove all newline characters from the input text to join all lines into a single continuous string.","command":"sed ':a;N;$!ba;s/\\n//g'","input_text":"22791\n;\n14336\n;\n22821\n;","expected_output":"22791;14336;22821;","validation_input":"A\nB\nC\n","validation_output":"ABC\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3134791/how-do-i-remove-newlines-from-a-text-file","question_title":"How do I remove newlines from a text file?","question_owner":"Alucard","answer_owner":"Tyler McHenry","answer_id":3134827,"question_score":213,"reviewed":true}
|
| 26 |
+
{"id":"so-38672680","request":"Join all lines into a single line, replacing newlines with the literal characters backslash and n.","command":"sed ':a;N;$!ba;s/\\n/\\\\n/g'","input_text":"Line one\nLine two\nLine three","expected_output":"Line one\\nLine two\\nLine three","validation_input":"First\nSecond","validation_output":"First\\nSecond","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38672680/replace-newlines-with-literal-n","question_title":"Replace newlines with literal \\n","question_owner":"Parze","answer_owner":"anubhava","answer_id":38672741,"question_score":106,"reviewed":true}
|
| 27 |
+
{"id":"so-38972736","request":"Print all lines from the first occurrence of 'PAT1' to the next occurrence of 'PAT2', inclusive of both pattern lines.","command":"sed -n '/PAT1/,/PAT2/p'","input_text":"1\n2\nPAT1\n3\n4\nPAT2\n5","expected_output":"PAT1\n3\n4\nPAT2\n","validation_input":"start\nPAT1\nmiddle\nend\nPAT2\nfinish","validation_output":"PAT1\nmiddle\nend\nPAT2\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38972736/how-to-print-lines-between-two-patterns-inclusive-or-exclusive-in-sed-awk-or","question_title":"How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?","question_owner":"fedorqui","answer_owner":"fedorqui","answer_id":38972737,"question_score":116,"reviewed":true}
|
| 28 |
+
{"id":"so-4569825","request":"Convert all uppercase letters in the input text to lowercase.","command":"sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'","input_text":"Hello World\nTHIS IS A TEST\nMixed Case Text","expected_output":"hello world\nthis is a test\nmixed case text","validation_input":"ABCdef\nXYZ123\nNo Change here","validation_output":"abcdef\nxyz123\nno change here","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/4569825/sed-one-liner-to-convert-all-uppercase-to-lowercase","question_title":"sed one-liner to convert all uppercase to lowercase?","question_owner":"magnetar","answer_owner":"magnetar","answer_id":4581564,"question_score":213,"reviewed":true}
|
| 29 |
+
{"id":"so-5080988","request":"Extract the value inside double quotes that immediately follows name= on each line.","command":"sed -n 's/.*name=\"\\([^\"]*\\)\".*/\\1/p'","input_text":"<table name=\"content_analyzer\" primary-key=\"id\">\n<type=\"global\" />\n</table>","expected_output":"content_analyzer\n","validation_input":"<tag name=\"test_value\" attr=\"val\">","validation_output":"test_value","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5080988/how-to-extract-string-following-a-pattern-with-grep-regex-or-perl","question_title":"How to extract string following a pattern with grep, regex or perl","question_owner":"wrangler","answer_owner":"sidyll","answer_id":5081519,"question_score":122,"reviewed":true}
|
| 30 |
+
{"id":"so-5227295","request":"Delete the line matching 'The second line' and all subsequent lines from the input text.","command":"sed '/The second line/,$d'","input_text":"The first line\nThe second line\nThe third line\nThe fourth line","expected_output":"The first line\n","validation_input":"Line A\nLine B\nThe second line\nLine C","validation_output":"Line A\nLine B\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5227295/how-do-i-delete-all-lines-in-a-file-starting-from-after-a-matching-line","question_title":"How do I delete all lines in a file starting from after a matching line?","question_owner":"DocWiki","answer_owner":"Dennis Williamson","answer_id":5227429,"question_score":126,"reviewed":true}
|
| 31 |
+
{"id":"so-538664","request":"Print only the first 12 characters of each line from the input text.","command":"sed -e 's/^\\(.\\{12\\}\\).*/\\1/'","input_text":"Hello World This Is A Test\nShort\nThis is a longer line that exceeds twelve characters","expected_output":"Hello World \nShort\nThis is a lo","validation_input":"123456789012345\n123456789012\nabcdefghijklmnop","validation_output":"123456789012\n123456789012\nabcdefghijkl","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/538664/using-sed-how-do-you-print-the-first-n-characters-of-a-line","question_title":"Using sed, how do you print the first 'N' characters of a line?","question_owner":"Berlin Brown","answer_owner":"Paul Tomblin","answer_id":538676,"question_score":153,"reviewed":true}
|
| 32 |
+
{"id":"so-5410757","request":"Delete all lines containing the string 'error' from the input text.","command":"sed '/error/d'","input_text":"line one\nerror found here\nline three\nanother error line\nfinal line","expected_output":"line one\nline three\nfinal line","validation_input":"no errors here\nthis is clean\nerror in middle\nclean again","validation_output":"this is clean\nclean again","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5410757/how-can-i-delete-all-lines-that-contain-a-specific-string-from-a-text-file","question_title":"How can I delete all lines that contain a specific string from a text file?","question_owner":"A Clockwork Orange","answer_owner":"SiegeX","answer_id":5410784,"question_score":2423,"reviewed":true}
|
| 33 |
+
{"id":"so-6022384","request":"Print only the 3rd line of the input text.","command":"sed '3q;d'","input_text":"first line\nsecond line\nthird line\nfourth line\nfifth line","expected_output":"third line\n","validation_input":"alpha\nbeta\ngamma\ndelta","validation_output":"gamma\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file","question_title":"Bash tool to get nth line from a file","question_owner":"Vlad Vivdovitch","answer_owner":"anubhava","answer_id":6022431,"question_score":914,"reviewed":true}
|
| 34 |
+
{"id":"so-6287755","request":"Delete all lines strictly between a line starting with # and a line starting with $, keeping the boundary lines.","command":"sed '/^#/,/^\\$/{/^#/!{/^\\$/!d}}'","input_text":"# ID 1\nblah blah\nblah blah\n$ description 1\nblah blah","expected_output":"# ID 1\n$ description 1\nblah blah","validation_input":"# Start\nremove this\nand this\n$ End\nkeep this","validation_output":"# Start\n$ End\nkeep this","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6287755/using-sed-to-delete-all-lines-between-two-matching-patterns","question_title":"Using sed to delete all lines between two matching patterns","question_owner":"Ken","answer_owner":"anubhava","answer_id":6287940,"question_score":120,"reviewed":true}
|
| 35 |
+
{"id":"so-723157","request":"Insert a newline before every occurrence of a phone number pattern like (012)345-6789 in the input text.","command":"sed 's/(\\([0-9]\\{3\\}\\))[0-9]\\{3\\}-[0-9]\\{4\\}/\\n&/g'","input_text":"some text (012)345-6789","expected_output":"some text \n(012)345-6789","validation_input":"call (123)456-7890 or (987)654-3210 now","validation_output":"call \n(123)456-7890 or \n(987)654-3210 now","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/723157/how-to-insert-a-newline-in-front-of-a-pattern","question_title":"How to insert a newline in front of a pattern?","question_owner":"Dennis","answer_owner":"Dennis","answer_id":723247,"question_score":146,"reviewed":true}
|
| 36 |
+
{"id":"so-7451423","request":"Print only the line immediately following any line that contains the string 'blah'. Do not print the matching line itself.","command":"sed -n '/blah/{n;p;}'","input_text":"header\nblah found\nnext line content\nfooter","expected_output":"next line content\n","validation_input":"no match here\nblah trigger\nresult line\nanother blah\nsecond result\nend","validation_output":"result line\nsecond result\n","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one","question_title":"How to show only next line after the matched one?","question_owner":"facha","answer_owner":"Michał Šrajer","answer_id":7451456,"question_score":279,"reviewed":true}
|
| 37 |
+
{"id":"so-7517632","request":"Replace the literal string \"http://www.fubar.com\" with URL_FUBAR in the input.","command":"sed 's#\"http://www\\.fubar\\.com\"#URL_FUBAR#g'","input_text":"Visit \"http://www.fubar.com\" now.\nKeep \"http://other.com\".","expected_output":"Visit URL_FUBAR now.\nKeep \"http://other.com\".","validation_input":"Link: \"http://www.fubar.com\"","validation_output":"Link: URL_FUBAR","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/7517632/how-do-i-escape-slashes-and-double-and-single-quotes-in-sed","question_title":"How do I escape slashes and double and single quotes in sed?","question_owner":"KRB","answer_owner":"Kusalananda","answer_id":7517900,"question_score":122,"reviewed":true}
|
| 38 |
+
{"id":"so-8206280","request":"Delete all lines that begin with a hash character (#) from the input text.","command":"sed '/^#/d'","input_text":"# This is a comment\nThis is code\n# Another comment\nMore code # inline comment","expected_output":"This is code\nMore code # inline comment","validation_input":"# Comment line 1\nValid line 1\n# Comment line 2\nValid line 2 with # symbol","validation_output":"Valid line 1\nValid line 2 with # symbol","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8206280/delete-all-lines-beginning-with-a-from-a-file","question_title":"Delete all lines beginning with a # from a file","question_owner":"Village","answer_owner":"Raymond Hettinger","answer_id":8206295,"question_score":283,"reviewed":true}
|
| 39 |
+
{"id":"so-8822097","request":"Replace any line starting with 'aaa=' followed by any characters with the line 'aaa=xxx'.","command":"sed 's/^aaa=.*/aaa=xxx/'","input_text":"aaa=bbb\naaa=ccc\naaa=ddd\nother=line","expected_output":"aaa=xxx\naaa=xxx\naaa=xxx\nother=line","validation_input":"aaa=test\nkeep=this\naaa=value","validation_output":"aaa=xxx\nkeep=this\naaa=xxx","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8822097/how-to-replace-a-whole-line-with-sed","question_title":"How to replace a whole line with sed?","question_owner":"Michael","answer_owner":"John Doyle","answer_id":8822211,"question_score":253,"reviewed":true}
|
| 40 |
+
{"id":"so-9533679","request":"Prepend the text '<added text> ' to the beginning of the first line of the input stream without adding a new line.","command":"sed '1s/^/<added text> /'","input_text":"some text at the beginning\nsecond line","expected_output":"<added text> some text at the beginning\nsecond line","validation_input":"hello world","validation_output":"<added text> hello world","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9533679/how-to-insert-a-text-at-the-beginning-of-a-file","question_title":"How to insert a text at the beginning of a file?","question_owner":"user219882","answer_owner":"kev","answer_id":9533736,"question_score":350,"reviewed":true}
|
| 41 |
+
{"id":"so-9605232","request":"Merge every two consecutive lines into a single line separated by a space.","command":"sed 'N;s/\\n/ /'","input_text":"KEY 4048:1736 string\n3\nKEY 0:1772 string\n1","expected_output":"KEY 4048:1736 string 3\nKEY 0:1772 string 1","validation_input":"Line A\nLine B\nLine C\nLine D","validation_output":"Line A Line B\nLine C Line D","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9605232/how-to-merge-every-two-lines-into-one-from-the-command-line","question_title":"How to merge every two lines into one from the command line?","question_owner":"shantanuo","answer_owner":"Kent","answer_id":9605559,"question_score":229,"reviewed":true}
|
| 42 |
+
{"id":"so-9953448","request":"Remove every space and tab character from each input line.","command":"sed 's/[[:space:]]//g'","input_text":"Hello \t World\nNew Line","expected_output":"HelloWorld\nNewLine","validation_input":"a b\tc\nd","validation_output":"abc\nd","family":"real-stackoverflow","difficulty":3,"split":"validation","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9953448/how-to-remove-all-white-spaces-from-a-given-text-file","question_title":"How to remove all white spaces from a given text file?","question_owner":"Lunar Mushrooms","answer_owner":"Paulo Scardine","answer_id":9953487,"question_score":123,"reviewed":true}
|
evaluation/v1-dev.jsonl
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"so-1032023","request":"Replace all occurrences of the whole word 'bar' with 'no bar' in the input text, ensuring that partial matches like 'embarassment' are not affected.","command":"sed 's/\\bbar\\b/no bar/g'","input_text":"bar embarassment\nbar foo bar\nfoobar","expected_output":"no bar embarassment\nno bar foo no bar\nfoobar","validation_input":"start bar end\nno bar here\nbarbell","validation_output":"start no bar end\nno no bar here\nbarbell","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1032023/sed-whole-word-search-and-replace","question_title":"sed whole word search and replace","question_owner":"ksuralta","answer_owner":"Joakim Lundborg","answer_id":1032039,"question_score":159,"reviewed":true,"prediction":"sed s/bar/no bar/g","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 2 |
+
{"id":"so-11145270","request":"Replace the entire third line of the input text with the string 'replacement-line'.","command":"sed '3s/.*/replacement-line/'","input_text":"Line one\nLine two\nLine three\nLine four","expected_output":"Line one\nLine two\nreplacement-line\nLine four","validation_input":"Alpha\nBeta\nGamma\nDelta\nEpsilon","validation_output":"Alpha\nBeta\nreplacement-line\nDelta\nEpsilon","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11145270/how-to-replace-an-entire-line-in-a-text-file-by-line-number","question_title":"How to replace an entire line in a text file by line number","question_owner":"user788171","answer_owner":"chepner","answer_id":11145362,"question_score":225,"reviewed":true,"prediction":"sed '/third/c replacement-line'","valid":true,"correct":false,"error":null}
|
| 3 |
+
{"id":"so-11245144","request":"Replace any line containing the string 'TEXT_TO_BE_REPLACED' with the text 'This line is removed by the admin.'","command":"sed '/TEXT_TO_BE_REPLACED/c\\This line is removed by the admin.'","input_text":"sometext sometext sometext TEXT_TO_BE_REPLACED sometext sometext sometext\nother line\nanother line with TEXT_TO_BE_REPLACED here","expected_output":"This line is removed by the admin.\nother line\nThis line is removed by the admin.\n","validation_input":"line one\nTEXT_TO_BE_REPLACED\nline three","validation_output":"line one\nThis line is removed by the admin.\nline three","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11245144/replace-whole-line-containing-a-string-using-sed","question_title":"Replace whole line containing a string using Sed","question_owner":"Rahul","answer_owner":"Todd A. Jacobs","answer_id":11245501,"question_score":472,"reviewed":true,"prediction":"sed s/TEXT_TO_BE_REPLACED/This line is removed by the admin./","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 4 |
+
{"id":"so-11469989","request":"Remove the first 4 characters from each line of input.","command":"sed 's/^....//'","input_text":"pid: 1234\nname: test","expected_output":" 1234\n: test","validation_input":"code: ABCD\nid: 9999","validation_output":": ABCD\n9999","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11469989/how-can-i-strip-first-x-characters-from-string-using-sed","question_title":"How can I strip first X characters from string using sed?","question_owner":"Kokesh","answer_owner":"Arnaud F.","answer_id":11470076,"question_score":174,"reviewed":true,"prediction":"sed 's/^.*/\\1/'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 9: invalid reference \\1 on `s' command's RHS"}
|
| 5 |
+
{"id":"so-11568859","request":"Extract the first sequence of digits followed by 'G' and more digits from each line, printing only the match.","command":"sed -n 's/^[^0-9]*\\([0-9][0-9]*G[0-9][0-9]*\\).*/\\1/p'","input_text":"This is 02G05 a test string 20-Jul-2012","expected_output":"02G05","validation_input":"No match here\nCode 123G456 found\n9G1 end","validation_output":"123G456\n9G1","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11568859/how-to-extract-text-from-a-string-using-sed","question_title":"How to extract text from a string using sed?","question_owner":"RanRag","answer_owner":"tripleee","answer_id":11568930,"question_score":130,"reviewed":true,"prediction":"sed 's/[^0-9][0-9]G*//'","valid":true,"correct":false,"error":null}
|
| 6 |
+
{"id":"so-13055889","request":"Replace all commas with a comma surrounded by single quotes in the input text.","command":"sed \"s/,/','/g\"","input_text":"A,B,C","expected_output":"A','B','C","validation_input":"X,Y,Z\n1,2","validation_output":"X','Y','Z\n1','2","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13055889/sed-with-literal-string-not-input-file","question_title":"sed with literal string--not input file","question_owner":"amphibient","answer_owner":"Gilles Quénot","answer_id":13055913,"question_score":135,"reviewed":true,"prediction":"sed 's/,/,\"\"/g'","valid":true,"correct":false,"error":null}
|
| 7 |
+
{"id":"so-13242469","request":"Extract the text between the words 'Here' and 'String' on a single line, removing the words themselves.","command":"sed 's/^.*Here\\(.*\\)String.*$/\\1/'","input_text":"Here is a String","expected_output":" is a ","validation_input":"Here we go String now","validation_output":" we go ","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13242469/how-to-use-sed-grep-to-extract-text-between-two-words","question_title":"How to use sed/grep to extract text between two words?","question_owner":"user1190650","answer_owner":"Brian Campbell","answer_id":13242517,"question_score":228,"reviewed":true,"prediction":"sed -n /Here/,/String/p","valid":true,"correct":false,"error":null}
|
| 8 |
+
{"id":"so-1429556","request":"Print only the second line of the input stream.","command":"sed -n '2p'","input_text":"first line\nsecond line\nthird line","expected_output":"second line\n","validation_input":"alpha\nbeta\ngamma\ndelta","validation_output":"beta\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1429556/command-to-get-nth-line-of-stdout","question_title":"Command to get nth line of STDOUT","question_owner":"Alana Storm","answer_owner":"Jonathan Leffler","answer_id":1429628,"question_score":277,"reviewed":true,"prediction":"sed -n 2p","valid":true,"correct":true,"error":null}
|
| 9 |
+
{"id":"so-14671293","request":"Remove all sequences of digits from the input text using a POSIX-compatible character class.","command":"sed 's/[[:digit:]]\\+//g'","input_text":"abc123def456\n789xyz","expected_output":"abcdef\nxyz","validation_input":"no digits here\n1a2b3c","validation_output":"no digits here\nabc","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/14671293/why-doesnt-d-work-in-regular-expressions-in-sed","question_title":"Why doesn't `\\d` work in regular expressions in sed?","question_owner":"user2036880","answer_owner":"Kamil","answer_id":14671415,"question_score":105,"reviewed":true,"prediction":"sed 's/[0-9][0-9]*/\\n/g'","valid":true,"correct":false,"error":null}
|
| 10 |
+
{"id":"so-148451","request":"Replace only the first occurrence of the string 'foo' with 'bar' in the input stream.","command":"sed '0,/foo/s//bar/'","input_text":"foo baz\nfoo qux\nfoo end","expected_output":"bar baz\nfoo qux\nfoo end","validation_input":"no match here\nfoo match here\nfoo another","validation_output":"no match here\nbar match here\nfoo another","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file","question_title":"How to use sed to replace only the first occurrence in a file?","question_owner":"David Dibben","answer_owner":"Ben Hoffstein","answer_id":148473,"question_score":346,"reviewed":true,"prediction":"sed s/foo/bar/","valid":true,"correct":false,"error":null}
|
| 11 |
+
{"id":"so-15559359","request":"Insert the line 'CLIENTSCRIPT2=\"hello\"' after the first line that matches 'CLIENTSCRIPT=\"foo\"'.","command":"sed '/CLIENTSCRIPT=\"foo\"/a\\\nCLIENTSCRIPT2=\"hello\"'","input_text":"CLIENTSCRIPT=\"foo\"\nCLIENTFILE=\"bar\"","expected_output":"CLIENTSCRIPT=\"foo\"\nCLIENTSCRIPT2=\"hello\"\nCLIENTFILE=\"bar\"","validation_input":"line1\nCLIENTSCRIPT=\"foo\"\nline3","validation_output":"line1\nCLIENTSCRIPT=\"foo\"\nCLIENTSCRIPT2=\"hello\"\nline3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15559359/insert-line-after-match-using-sed","question_title":"Insert line after match using sed","question_owner":"user2150250","answer_owner":"Gilles Quénot","answer_id":15559399,"question_score":371,"reviewed":true,"prediction":"sed '/CLIENTSCRIPT=\"foo\"/a CLIENTSCRIPT2=\"hello\"'","valid":true,"correct":true,"error":null}
|
| 12 |
+
{"id":"so-15849119","request":"Replace all occurrences of the word 'dog' with 'log' in each line of the input.","command":"sed -e 's/dog/log/g'","input_text":"dog dog dos","expected_output":"log log dos","validation_input":"a dog b dog c","validation_output":"a log b log c","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15849119/why-does-sed-not-replace-all-occurrences","question_title":"Why does sed not replace all occurrences?","question_owner":"Nishant George Agrwal","answer_owner":"Bruno Reis","answer_id":15849152,"question_score":188,"reviewed":true,"prediction":"sed s/dog/log/g","valid":true,"correct":true,"error":null}
|
| 13 |
+
{"id":"so-16414410","request":"Remove all lines that are empty or contain only whitespace characters from the input text.","command":"sed '/^[[:space:]]*$/d'","input_text":"xxxxxx\n \n\nyyyyyy\n\t\nzzzzzz","expected_output":"xxxxxx\nyyyyyy\nzzzzzz","validation_input":"hello\n \nworld\n\nfoo","validation_output":"hello\nworld\nfoo","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16414410/delete-empty-lines-using-sed","question_title":"Delete empty lines using sed","question_owner":"jonas","answer_owner":"Kent","answer_id":16414489,"question_score":530,"reviewed":true,"prediction":"sed '/^$/d'","valid":true,"correct":false,"error":null}
|
| 14 |
+
{"id":"so-1665549","request":"Extract the filename from lines matching the pattern '[wrote filename.class]' and suppress all other lines.","command":"sed -n 's/^\\[wrote \\(.*\\.class\\)\\]$/\\1/p'","input_text":"[wrote some-class-name.class]","expected_output":"some-class-name.class","validation_input":"[wrote Main.class]\ncompiling...\n[wrote Utils.class]","validation_output":"Main.class\nUtils.class","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1665549/have-sed-ignore-non-matching-lines","question_title":"Have sed ignore non-matching lines","question_owner":"Paggas","answer_owner":"liori","answer_id":1665662,"question_score":138,"reviewed":true,"prediction":"sed -n /[wrote filename.class]/p","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 15 |
+
{"id":"so-1706431","request":"Replace all spaces in the input with underscores.","command":"sed 's/ /_/g'","input_text":"This is just a test\nWindows XP","expected_output":"This_is_just_a_test\nWindows_XP","validation_input":"Hello World Foo Bar\nMy File Name.txt","validation_output":"Hello_World_Foo_Bar\nMy_File_Name.txt","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1706431/the-easiest-way-to-replace-white-spaces-with-underscores-in-bash","question_title":"The easiest way to replace white spaces with (underscores) _ in bash","question_owner":"flazzarini","answer_owner":"ghostdog74","answer_id":1706459,"question_score":107,"reviewed":true,"prediction":"sed 's/\\ /_/g'","valid":true,"correct":true,"error":null}
|
| 16 |
+
{"id":"so-17511639","request":"Extract and print only the last integer and floating-point number (separated by whitespace) from each line, ignoring preceding text.","command":"sed -n 's/^.*[^0-9]\\([0-9][0-9]*\\)[ \\t]\\([0-9][0-9]*\\.[0-9][0-9]*\\)[ \\t]*$/\\1 \\2/p'","input_text":"foo bar <foo> bla 1 2 3.4\nno match here\nvalues 10 20.5","expected_output":"2 3.4\n10 20.5","validation_input":"test 5 6.7\nabc 123 456.789\nnothing","validation_output":"5 6.7\n123 456.789\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/17511639/sed-print-only-matching-group","question_title":"sed: print only matching group","question_owner":"mort","answer_owner":"iruvar","answer_id":17511700,"question_score":205,"reviewed":true,"prediction":"sed 's/[^ ]*\\.[^ ]*\\|[^ ]*\\([^ ]*\\).*/\\1/'","valid":false,"correct":false,"error":"Pipes and shell control operators are not allowed."}
|
| 17 |
+
{"id":"so-18439528","request":"Insert the line ' hello world' (with three leading spaces) before the second line of the input text.","command":"sed '2i\\ hello world'","input_text":"hello\nworld","expected_output":"hello\n hello world\nworld","validation_input":"line1\nline2\nline3","validation_output":"line1\n hello world\nline2\nline3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18439528/sed-insert-line-with-leading-spaces-to-a-specific-line","question_title":"sed insert line with leading spaces to a specific line","question_owner":"Ggdw","answer_owner":"Atropo","answer_id":18439749,"question_score":120,"reviewed":true,"prediction":"sed '/^$/i hello world'","valid":true,"correct":false,"error":null}
|
| 18 |
+
{"id":"so-20348097","request":"Remove the colon and everything after it from each line of input.","command":"sed 's/:.*//'","input_text":"/some/random/file.csv:some string\n/some/random/file2.csv:some string2","expected_output":"/some/random/file.csv\n/some/random/file2.csv","validation_input":"path/to/data.txt:value here\nanother/path.log:more data","validation_output":"path/to/data.txt\nanother/path.log","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon","question_title":"bash, extract string before a colon","question_owner":"user788171","answer_owner":"ray","answer_id":20348145,"question_score":111,"reviewed":true,"prediction":"sed 's/[^:]*:\\([^:]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 19 |
+
{"id":"so-2112469","request":"Delete lines 5 through 10 and line 12 from the input text.","command":"sed -e '5,10d;12d'","input_text":"Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8","expected_output":"Line 1\nLine 2\nLine 3\nLine 4\n","validation_input":"A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM","validation_output":"A\nB\nC\nD\nK\nM","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2112469/delete-specific-line-numbers-from-a-text-file-using-sed","question_title":"Delete specific line number(s) from a text file using sed?","question_owner":"Justin Ethier","answer_owner":"Brian Campbell","answer_id":2112496,"question_score":367,"reviewed":true,"prediction":"sed 5,10d sed 12d","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 20 |
+
{"id":"so-24509214","request":"Replace the string 'ones' with 'one's' in the input text using sed.","command":"sed \"s/ones/one's/g\"","input_text":"ones thing","expected_output":"one's thing","validation_input":"ones and ones again","validation_output":"one's and one's again","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24509214/how-to-escape-single-quote-in-sed","question_title":"How to escape single quote in sed?","question_owner":"Thomas Bratt","answer_owner":"Kent","answer_id":24509931,"question_score":148,"reviewed":true,"prediction":"sed s/ones/one's/","valid":false,"correct":false,"error":"Cannot parse sed command: No closing quotation"}
|
| 21 |
+
{"id":"so-2610115","request":"Insert a literal tab character at the beginning of every line in the input.","command":"sed 's/^/\t/'","input_text":"hello\nworld","expected_output":"\thello\n\tworld","validation_input":"foo\nbar\nbaz","validation_output":"\tfoo\n\tbar\n\tbaz","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2610115/why-is-sed-not-recognizing-t-as-a-tab","question_title":"Why is sed not recognizing \\t as a tab?","question_owner":"sixtyfootersdude","answer_owner":"Mark Byers","answer_id":2610121,"question_score":132,"reviewed":true,"prediction":"sed 's/^/\\\\t/'","valid":true,"correct":false,"error":null}
|
| 22 |
+
{"id":"so-26568952","request":"Swap all occurrences of 'ab' with 'bc' and 'bc' with 'ab' simultaneously in the input stream, assuming '~' does not appear in the text.","command":"sed 's/ab/~~/g; s/bc/ab/g; s/~~/bc/g'","input_text":"abbc","expected_output":"bcab","validation_input":"abc ab bc","validation_output":"bcc bc ab","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/26568952/how-to-swap-text-based-on-patterns-at-once-with-sed","question_title":"How to swap text based on patterns at once with sed?","question_owner":"DaniloNC","answer_owner":"ooga","answer_id":26568996,"question_score":344,"reviewed":true,"prediction":"sed s/ab/cb/s/cb/a/g","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 9: unknown option to `s'"}
|
| 23 |
+
{"id":"so-2777579","request":"Extract only the sequences of digits from each line, separated by a space. If a line has multiple digit sequences, print them all on one line separated by spaces. If no digits, print nothing for that line.","command":"sed -n 's/[^0-9][^0-9]*/ /g; s/^ *//; s/ *$//; /[0-9]/p'","input_text":"This is a sample 123 text and some 987 numbers\nno numbers here\nabc 42 def","expected_output":"123 987\n42","validation_input":"start 10 middle 20 end\njust text\n555","validation_output":"10 20\n555","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2777579/how-can-i-output-only-captured-groups-with-sed","question_title":"How can I output only captured groups with sed?","question_owner":"Pablo","answer_owner":"Dennis Williamson","answer_id":2778096,"question_score":426,"reviewed":true,"prediction":"sed 's/[0-9][0-9]*/\\1/g'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 18: invalid reference \\1 on `s' command's RHS"}
|
| 24 |
+
{"id":"so-2869669","request":"Append the string 'string after each line' to the end of every line in the input.","command":"sed -e 's/$/string after each line/'","input_text":"Line one\nLine two\nLine three","expected_output":"Line onestring after each line\nLine twostring after each line\nLine threestring after each line","validation_input":"Hello World\nFoo Bar","validation_output":"Hello Worldstring after each line\nFoo Barstring after each line","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2869669/in-bash-how-do-i-add-a-string-after-each-line-in-a-file","question_title":"In Bash, how do I add a string after each line in a file?","question_owner":"Jason Volkoz","answer_owner":"Tom DeGisi","answer_id":2869736,"question_score":170,"reviewed":true,"prediction":"sed '/$/a string after each line'","valid":true,"correct":false,"error":null}
|
| 25 |
+
{"id":"so-3134791","request":"Remove all newline characters from the input text to join all lines into a single continuous string.","command":"sed ':a;N;$!ba;s/\\n//g'","input_text":"22791\n;\n14336\n;\n22821\n;","expected_output":"22791;14336;22821;","validation_input":"A\nB\nC\n","validation_output":"ABC\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3134791/how-do-i-remove-newlines-from-a-text-file","question_title":"How do I remove newlines from a text file?","question_owner":"Alucard","answer_owner":"Tyler McHenry","answer_id":3134827,"question_score":213,"reviewed":true,"prediction":"sed 's/[ \\t]*$//'","valid":true,"correct":false,"error":null}
|
| 26 |
+
{"id":"so-38672680","request":"Join all lines into a single line, replacing newlines with the literal characters backslash and n.","command":"sed ':a;N;$!ba;s/\\n/\\\\n/g'","input_text":"Line one\nLine two\nLine three","expected_output":"Line one\\nLine two\\nLine three","validation_input":"First\nSecond","validation_output":"First\\nSecond","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38672680/replace-newlines-with-literal-n","question_title":"Replace newlines with literal \\n","question_owner":"Parze","answer_owner":"anubhava","answer_id":38672741,"question_score":106,"reviewed":true,"prediction":"sed 's/\\n/\\\\/g'","valid":true,"correct":false,"error":null}
|
| 27 |
+
{"id":"so-38972736","request":"Print all lines from the first occurrence of 'PAT1' to the next occurrence of 'PAT2', inclusive of both pattern lines.","command":"sed -n '/PAT1/,/PAT2/p'","input_text":"1\n2\nPAT1\n3\n4\nPAT2\n5","expected_output":"PAT1\n3\n4\nPAT2\n","validation_input":"start\nPAT1\nmiddle\nend\nPAT2\nfinish","validation_output":"PAT1\nmiddle\nend\nPAT2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38972736/how-to-print-lines-between-two-patterns-inclusive-or-exclusive-in-sed-awk-or","question_title":"How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?","question_owner":"fedorqui","answer_owner":"fedorqui","answer_id":38972737,"question_score":116,"reviewed":true,"prediction":"sed -n /PAT1/,/PAT2/p","valid":true,"correct":true,"error":null}
|
| 28 |
+
{"id":"so-4569825","request":"Convert all uppercase letters in the input text to lowercase.","command":"sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'","input_text":"Hello World\nTHIS IS A TEST\nMixed Case Text","expected_output":"hello world\nthis is a test\nmixed case text","validation_input":"ABCdef\nXYZ123\nNo Change here","validation_output":"abcdef\nxyz123\nno change here","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/4569825/sed-one-liner-to-convert-all-uppercase-to-lowercase","question_title":"sed one-liner to convert all uppercase to lowercase?","question_owner":"magnetar","answer_owner":"magnetar","answer_id":4581564,"question_score":213,"reviewed":true,"prediction":"sed 's/.*/\\L&/'","valid":true,"correct":true,"error":null}
|
| 29 |
+
{"id":"so-5080988","request":"Extract the value inside double quotes that immediately follows name= on each line.","command":"sed -n 's/.*name=\"\\([^\"]*\\)\".*/\\1/p'","input_text":"<table name=\"content_analyzer\" primary-key=\"id\">\n<type=\"global\" />\n</table>","expected_output":"content_analyzer\n","validation_input":"<tag name=\"test_value\" attr=\"val\">","validation_output":"test_value","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5080988/how-to-extract-string-following-a-pattern-with-grep-regex-or-perl","question_title":"How to extract string following a pattern with grep, regex or perl","question_owner":"wrangler","answer_owner":"sidyll","answer_id":5081519,"question_score":122,"reviewed":true,"prediction":"sed 's/\".*\"?/\\1/'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 11: invalid reference \\1 on `s' command's RHS"}
|
| 30 |
+
{"id":"so-5227295","request":"Delete the line matching 'The second line' and all subsequent lines from the input text.","command":"sed '/The second line/,$d'","input_text":"The first line\nThe second line\nThe third line\nThe fourth line","expected_output":"The first line\n","validation_input":"Line A\nLine B\nThe second line\nLine C","validation_output":"Line A\nLine B\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5227295/how-do-i-delete-all-lines-in-a-file-starting-from-after-a-matching-line","question_title":"How do I delete all lines in a file starting from after a matching line?","question_owner":"DocWiki","answer_owner":"Dennis Williamson","answer_id":5227429,"question_score":126,"reviewed":true,"prediction":"sed /The second line/d","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 31 |
+
{"id":"so-538664","request":"Print only the first 12 characters of each line from the input text.","command":"sed -e 's/^\\(.\\{12\\}\\).*/\\1/'","input_text":"Hello World This Is A Test\nShort\nThis is a longer line that exceeds twelve characters","expected_output":"Hello World \nShort\nThis is a lo","validation_input":"123456789012345\n123456789012\nabcdefghijklmnop","validation_output":"123456789012\n123456789012\nabcdefghijkl","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/538664/using-sed-how-do-you-print-the-first-n-characters-of-a-line","question_title":"Using sed, how do you print the first 'N' characters of a line?","question_owner":"Berlin Brown","answer_owner":"Paul Tomblin","answer_id":538676,"question_score":153,"reviewed":true,"prediction":"sed 's/^\\(.\\{12\\}\\).*/\\1/'","valid":true,"correct":true,"error":null}
|
| 32 |
+
{"id":"so-5410757","request":"Delete all lines containing the string 'error' from the input text.","command":"sed '/error/d'","input_text":"line one\nerror found here\nline three\nanother error line\nfinal line","expected_output":"line one\nline three\nfinal line","validation_input":"no errors here\nthis is clean\nerror in middle\nclean again","validation_output":"this is clean\nclean again","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5410757/how-can-i-delete-all-lines-that-contain-a-specific-string-from-a-text-file","question_title":"How can I delete all lines that contain a specific string from a text file?","question_owner":"A Clockwork Orange","answer_owner":"SiegeX","answer_id":5410784,"question_score":2423,"reviewed":true,"prediction":"sed /error/d","valid":true,"correct":true,"error":null}
|
| 33 |
+
{"id":"so-6022384","request":"Print only the 3rd line of the input text.","command":"sed '3q;d'","input_text":"first line\nsecond line\nthird line\nfourth line\nfifth line","expected_output":"third line\n","validation_input":"alpha\nbeta\ngamma\ndelta","validation_output":"gamma\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file","question_title":"Bash tool to get nth line from a file","question_owner":"Vlad Vivdovitch","answer_owner":"anubhava","answer_id":6022431,"question_score":914,"reviewed":true,"prediction":"sed -n 3p","valid":true,"correct":true,"error":null}
|
| 34 |
+
{"id":"so-6287755","request":"Delete all lines strictly between a line starting with # and a line starting with $, keeping the boundary lines.","command":"sed '/^#/,/^\\$/{/^#/!{/^\\$/!d}}'","input_text":"# ID 1\nblah blah\nblah blah\n$ description 1\nblah blah","expected_output":"# ID 1\n$ description 1\nblah blah","validation_input":"# Start\nremove this\nand this\n$ End\nkeep this","validation_output":"# Start\n$ End\nkeep this","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6287755/using-sed-to-delete-all-lines-between-two-matching-patterns","question_title":"Using sed to delete all lines between two matching patterns","question_owner":"Ken","answer_owner":"anubhava","answer_id":6287940,"question_score":120,"reviewed":true,"prediction":"sed /^#/d;/^$/d","valid":true,"correct":false,"error":null}
|
| 35 |
+
{"id":"so-723157","request":"Insert a newline before every occurrence of a phone number pattern like (012)345-6789 in the input text.","command":"sed 's/(\\([0-9]\\{3\\}\\))[0-9]\\{3\\}-[0-9]\\{4\\}/\\n&/g'","input_text":"some text (012)345-6789","expected_output":"some text \n(012)345-6789","validation_input":"call (123)456-7890 or (987)654-3210 now","validation_output":"call \n(123)456-7890 or \n(987)654-3210 now","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/723157/how-to-insert-a-newline-in-front-of-a-pattern","question_title":"How to insert a newline in front of a pattern?","question_owner":"Dennis","answer_owner":"Dennis","answer_id":723247,"question_score":146,"reviewed":true,"prediction":"sed 's/\\(.\\{7\\}\\)/\\1\\n\\1/'","valid":true,"correct":false,"error":null}
|
| 36 |
+
{"id":"so-7451423","request":"Print only the line immediately following any line that contains the string 'blah'. Do not print the matching line itself.","command":"sed -n '/blah/{n;p;}'","input_text":"header\nblah found\nnext line content\nfooter","expected_output":"next line content\n","validation_input":"no match here\nblah trigger\nresult line\nanother blah\nsecond result\nend","validation_output":"result line\nsecond result\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one","question_title":"How to show only next line after the matched one?","question_owner":"facha","answer_owner":"Michał Šrajer","answer_id":7451456,"question_score":279,"reviewed":true,"prediction":"sed -n /blah/p","valid":true,"correct":false,"error":null}
|
| 37 |
+
{"id":"so-7517632","request":"Replace the literal string \"http://www.fubar.com\" with URL_FUBAR in the input.","command":"sed 's#\"http://www\\.fubar\\.com\"#URL_FUBAR#g'","input_text":"Visit \"http://www.fubar.com\" now.\nKeep \"http://other.com\".","expected_output":"Visit URL_FUBAR now.\nKeep \"http://other.com\".","validation_input":"Link: \"http://www.fubar.com\"","validation_output":"Link: URL_FUBAR","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/7517632/how-do-i-escape-slashes-and-double-and-single-quotes-in-sed","question_title":"How do I escape slashes and double and single quotes in sed?","question_owner":"KRB","answer_owner":"Kusalananda","answer_id":7517900,"question_score":122,"reviewed":true,"prediction":"sed s/http://www.fubar.com/URL_FUBAR/g","valid":false,"correct":false,"error":"/usr/bin/sed: couldn't open file ww.fubar.com/URL_FUBAR/g: No such file or directory"}
|
| 38 |
+
{"id":"so-8206280","request":"Delete all lines that begin with a hash character (#) from the input text.","command":"sed '/^#/d'","input_text":"# This is a comment\nThis is code\n# Another comment\nMore code # inline comment","expected_output":"This is code\nMore code # inline comment","validation_input":"# Comment line 1\nValid line 1\n# Comment line 2\nValid line 2 with # symbol","validation_output":"Valid line 1\nValid line 2 with # symbol","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8206280/delete-all-lines-beginning-with-a-from-a-file","question_title":"Delete all lines beginning with a # from a file","question_owner":"Village","answer_owner":"Raymond Hettinger","answer_id":8206295,"question_score":283,"reviewed":true,"prediction":"sed '/^#/d'","valid":true,"correct":true,"error":null}
|
| 39 |
+
{"id":"so-8822097","request":"Replace any line starting with 'aaa=' followed by any characters with the line 'aaa=xxx'.","command":"sed 's/^aaa=.*/aaa=xxx/'","input_text":"aaa=bbb\naaa=ccc\naaa=ddd\nother=line","expected_output":"aaa=xxx\naaa=xxx\naaa=xxx\nother=line","validation_input":"aaa=test\nkeep=this\naaa=value","validation_output":"aaa=xxx\nkeep=this\naaa=xxx","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8822097/how-to-replace-a-whole-line-with-sed","question_title":"How to replace a whole line with sed?","question_owner":"Michael","answer_owner":"John Doyle","answer_id":8822211,"question_score":253,"reviewed":true,"prediction":"sed '/^aaa=/c aaa=xxx'","valid":true,"correct":false,"error":null}
|
| 40 |
+
{"id":"so-9533679","request":"Prepend the text '<added text> ' to the beginning of the first line of the input stream without adding a new line.","command":"sed '1s/^/<added text> /'","input_text":"some text at the beginning\nsecond line","expected_output":"<added text> some text at the beginning\nsecond line","validation_input":"hello world","validation_output":"<added text> hello world","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9533679/how-to-insert-a-text-at-the-beginning-of-a-file","question_title":"How to insert a text at the beginning of a file?","question_owner":"user219882","answer_owner":"kev","answer_id":9533736,"question_score":350,"reviewed":true,"prediction":"sed 's/^/<added text> /'","valid":true,"correct":false,"error":null}
|
| 41 |
+
{"id":"so-9605232","request":"Merge every two consecutive lines into a single line separated by a space.","command":"sed 'N;s/\\n/ /'","input_text":"KEY 4048:1736 string\n3\nKEY 0:1772 string\n1","expected_output":"KEY 4048:1736 string 3\nKEY 0:1772 string 1","validation_input":"Line A\nLine B\nLine C\nLine D","validation_output":"Line A Line B\nLine C Line D","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9605232/how-to-merge-every-two-lines-into-one-from-the-command-line","question_title":"How to merge every two lines into one from the command line?","question_owner":"shantanuo","answer_owner":"Kent","answer_id":9605559,"question_score":229,"reviewed":true,"prediction":"sed 's/\\([^ ]*\\) \\([^ ]*\\)/\\1 \\2/'","valid":true,"correct":false,"error":null}
|
| 42 |
+
{"id":"so-9953448","request":"Remove every space and tab character from each input line.","command":"sed 's/[[:space:]]//g'","input_text":"Hello \t World\nNew Line","expected_output":"HelloWorld\nNewLine","validation_input":"a b\tc\nd","validation_output":"abc\nd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9953448/how-to-remove-all-white-spaces-from-a-given-text-file","question_title":"How to remove all white spaces from a given text file?","question_owner":"Lunar Mushrooms","answer_owner":"Paulo Scardine","answer_id":9953487,"question_score":123,"reviewed":true,"prediction":"sed 's/[ \\t]+/ /g'","valid":true,"correct":false,"error":null}
|
evaluation/v1-dev.summary.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "asterbraid/sedweave-0.5b",
|
| 3 |
+
"split": "test",
|
| 4 |
+
"rows": 42,
|
| 5 |
+
"valid_at_1": 0.7142857142857143,
|
| 6 |
+
"correct_at_1": 0.23809523809523808,
|
| 7 |
+
"exact_output_on_two_inputs": true,
|
| 8 |
+
"prediction_cleanup": "special tokens only",
|
| 9 |
+
"seconds": 14.53479290008545,
|
| 10 |
+
"data_sha256": "5e8eec182a096b1d169845ef6f03235b3166b7f3315b473ec8cbc3e44dfc8c44",
|
| 11 |
+
"transformers_version": "5.17.0",
|
| 12 |
+
"torch_version": "2.14.0",
|
| 13 |
+
"families": {
|
| 14 |
+
"real-stackoverflow": {
|
| 15 |
+
"rows": 42,
|
| 16 |
+
"valid": 30,
|
| 17 |
+
"correct": 10
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
evaluation/v1-test.jsonl
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"so-10754682","request":"Wrap each line in double quotes, handling potential carriage returns at the end of lines by removing them before quoting.","command":"sed 's/\\r$//; s/.*/\"&\"/'","input_text":"name,id,3\r\nuser,pass,4\r\n","expected_output":"\"name,id,3\"\n\"user,pass,4\"\n","validation_input":"hello,world\r\ntest,data\r\n","validation_output":"\"hello,world\"\n\"test,data\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/10754682/how-to-add-double-quotes-to-a-line-with-sed-or-awk","question_title":"How to add double quotes to a line with SED or AWK?","question_owner":"minerals","answer_owner":"Dennis Williamson","answer_id":10755347,"question_score":31,"reviewed":true,"prediction":"sed 's/$/\"/'","valid":true,"correct":false,"error":null}
|
| 2 |
+
{"id":"so-11687216","request":"Remove all blank lines from the input text.","command":"sed '/^$/d'","input_text":"Line 1\n\nLine 3\n\nLine 5","expected_output":"Line 1\nLine 3\nLine 5","validation_input":"Hello\n\nWorld\n\nEnd","validation_output":"Hello\nWorld\nEnd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11687216/awk-to-skip-the-blank-lines","question_title":"Awk to skip the blank lines","question_owner":"Gil","answer_owner":"Levon","answer_id":11687266,"question_score":33,"reviewed":true,"prediction":"sed '/^$/d'","valid":true,"correct":true,"error":null}
|
| 3 |
+
{"id":"so-13202715","request":"Print only the lines that start with the prefix 'RIM-COD-' from the input text.","command":"sed -n -e '/^RIM-COD-/p'","input_text":"RIM-COD-URL-12: HelloWorld-12.cod\nRIM-COD-Size: 68020\nRIM-MIDlet-Icon-2-1: icon.png\nRIM-COD-URL-11: HelloWorld-11.cod","expected_output":"RIM-COD-URL-12: HelloWorld-12.cod\nRIM-COD-Size: 68020\nRIM-COD-URL-11: HelloWorld-11.cod","validation_input":"RIM-COD-URL-10: Test.cod\nOther-Line: Value\nRIM-COD-SHA1: abc123\nManifest-Version: 1.0","validation_output":"RIM-COD-URL-10: Test.cod\nRIM-COD-SHA1: abc123\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13202715/sed-get-lines-beginning-with-some-prefix","question_title":"Sed: get lines beginning with some prefix","question_owner":"CAMOBAP","answer_owner":"John3136","answer_id":13202727,"question_score":30,"reviewed":true,"prediction":"sed -n /RIM-COD-/p","valid":true,"correct":true,"error":null}
|
| 4 |
+
{"id":"so-14046878","request":"Delete from the first line exactly matching '-----THIS STUFF IS USELESS-----' to the end of the input stream.","command":"sed '/^-----THIS STUFF IS USELESS-----$/,$d'","input_text":"Files:\nsomefiles.tar.gz 1 2 3\nsomefiles.tar.gz 1 2 3\n-----THIS STUFF IS USELESS-----\nBLEH BLEH BLEH\nBLEH BLEH BLEH","expected_output":"Files:\nsomefiles.tar.gz 1 2 3\nsomefiles.tar.gz 1 2 3\n","validation_input":"Header\nData Line 1\nData Line 2\n-----THIS STUFF IS USELESS-----\nFooter 1\nFooter 2","validation_output":"Header\nData Line 1\nData Line 2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/14046878/using-sed-to-match-a-pattern-and-deleting-from-the-line-to-the-end-of-the-file","question_title":"Using sed to match a pattern and deleting from the line to the end of the file","question_owner":"Albert H","answer_owner":"shellter","answer_id":14046990,"question_score":26,"reviewed":true,"prediction":"sed '/-----THIS STUFF IS USELESS-----/d'","valid":true,"correct":false,"error":null}
|
| 5 |
+
{"id":"so-15632691","request":"Print only the first line of the input and then stop processing.","command":"sed -n '1{p;q}'","input_text":"Line 1\nLine 2\nLine 3","expected_output":"Line 1\n","validation_input":"First\nSecond\nThird\nFourth","validation_output":"First\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15632691/fastest-way-to-print-a-single-line-in-a-file","question_title":"Fastest way to print a single line in a file","question_owner":"JBoy","answer_owner":"Chris Seymour","answer_id":15632780,"question_score":25,"reviewed":true,"prediction":"sed -n 1p","valid":true,"correct":true,"error":null}
|
| 6 |
+
{"id":"so-1617724","request":"Replace all newline characters with tab characters in the input stream.","command":"sed ':a;N;$!ba;s/\\n/\\t/g'","input_text":"hi\nhello\nhallo\ngreetings","expected_output":"hi\thello\thallo\tgreetings","validation_input":"salutations\nno more hello for you","validation_output":"salutations\tno more hello for you","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1617724/how-to-replace-newlines-with-tab-characters","question_title":"How to replace newlines with tab characters?","question_owner":"Vijay","answer_owner":"ghostdog74","answer_id":1617769,"question_score":24,"reviewed":true,"prediction":"sed 's/\\n/\\t/g'","valid":true,"correct":false,"error":null}
|
| 7 |
+
{"id":"so-16202900","request":"Remove spaces following commas only within lines 2 through 3 of the input.","command":"sed '2,3s/,\\s\\+/,/g'","input_text":"Line 1, with space\nLine 2, with space\nLine 3, with space\nLine 4, with space","expected_output":"Line 1, with space\nLine 2,with space\nLine 3,with space\nLine 4, with space","validation_input":"a, b\nb, c\nc, d\nd, e","validation_output":"a, b\nb,c\nc,d\nd, e","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16202900/using-sed-between-specific-lines-only","question_title":"Using sed between specific lines only","question_owner":"hackio","answer_owner":"anubhava","answer_id":16202932,"question_score":26,"reviewed":true,"prediction":"sed 's/,*/ /g'","valid":true,"correct":false,"error":null}
|
| 8 |
+
{"id":"so-16576197","request":"Insert a newline between '</a>' and '<a><a>' in the input stream.","command":"sed 's#</a><a><a>#</a>\\\n<a><a>#g'","input_text":"</a><a><a>\nsome text </a><a><a> more text","expected_output":"</a>\n<a><a>\nsome text </a>\n<a><a> more text","validation_input":"prefix</a><a><a>suffix\n</a><a><a>","validation_output":"prefix</a>\n<a><a>suffix\n</a>\n<a><a>","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16576197/how-to-add-new-line-using-sed-on-macos","question_title":"How to add new line using sed on MacOS?","question_owner":"codereviewanskquestions","answer_owner":"Kevin","answer_id":16576291,"question_score":26,"reviewed":true,"prediction":"sed '/<a>/i <a><a>'","valid":true,"correct":false,"error":null}
|
| 9 |
+
{"id":"so-18602234","request":"Remove the period and everything following it on each line.","command":"sed 's/\\..*$//'","input_text":"95 flour.\n47 water.s\netc..","expected_output":"95 flour\n47 water\netc","validation_input":"hello.world\ntest.case.end","validation_output":"hello\ntest","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18602234/sed-to-remove-everything-after-in-file-using-command","question_title":"Sed to remove everything after "." in file using * command?","question_owner":"Novice","answer_owner":"Adam Rosenfield","answer_id":18602273,"question_score":25,"reviewed":true,"prediction":"sed 's/[.]*$//'","valid":true,"correct":false,"error":null}
|
| 10 |
+
{"id":"so-20568515","request":"Replace the value of the variable VAR5 with VALUE10 in a configuration file content, keeping the key name intact.","command":"sed 's/^\\(VAR5=\\).*/\\1VALUE10/'","input_text":"VAR1=VALUE1\nVAR2=VALUE2\nVAR3=VALUE3\nVAR4=VALUE4\nVAR5=VALUE5\nVAR6=VALUE6","expected_output":"VAR1=VALUE1\nVAR2=VALUE2\nVAR3=VALUE3\nVAR4=VALUE4\nVAR5=VALUE10\nVAR6=VALUE6","validation_input":"KEY=OLD\nVAR5=SOMETHING\nOTHER=DATA","validation_output":"KEY=OLD\nVAR5=VALUE10\nOTHER=DATA","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20568515/how-to-use-sed-to-replace-a-config-files-variable","question_title":"How to use sed to replace a config file's variable?","question_owner":"SomeGuyOnAComputer","answer_owner":"anubhava","answer_id":20568559,"question_score":32,"reviewed":true,"prediction":"sed s/VAR5=VALUE10/VAR5=VALUE10/g","valid":true,"correct":false,"error":null}
|
| 11 |
+
{"id":"so-22159044","request":"Append the string ' myalias' to the end of any line containing '192.168.1.2'.","command":"sed '/192.168.1.2/s/$/ myalias/'","input_text":"192.168.1.1 www.address1.com\n192.168.1.2 www.address2.com\n192.168.1.3 www.address3.com","expected_output":"192.168.1.1 www.address1.com\n192.168.1.2 www.address2.com myalias\n192.168.1.3 www.address3.com","validation_input":"10.0.0.1 host1\n192.168.1.2 host2\n10.0.0.3 host3","validation_output":"10.0.0.1 host1\n192.168.1.2 host2 myalias\n10.0.0.3 host3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/22159044/how-to-append-a-string-at-end-of-a-specific-line-in-a-file-in-bash","question_title":"How to append a string at end of a specific line in a file in bash","question_owner":"Chris F","answer_owner":"Steve","answer_id":22159086,"question_score":30,"reviewed":true,"prediction":"sed 's/$/ myalias/'","valid":true,"correct":false,"error":null}
|
| 12 |
+
{"id":"so-22939323","request":"Replace sequences of two or more spaces with a single space in the input text.","command":"sed -e 's/ */ /g'","input_text":"iiHi Hello Hi\nthis is loga","expected_output":"iiHi Hello Hi\nthis is loga","validation_input":"a b c d\ne f","validation_output":"a b c d\ne f","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/22939323/sed-command-to-replace-multiple-spaces-into-single-spaces","question_title":"sed command to replace multiple spaces into single spaces","question_owner":"logan","answer_owner":"John Zwinck","answer_id":22939416,"question_score":25,"reviewed":true,"prediction":"sed 's/[ \\{2,\\}]/ /g'","valid":true,"correct":false,"error":null}
|
| 13 |
+
{"id":"so-24427009","request":"Extract the last three characters from every line of the input.","command":"sed -e 's/^.*\\(...\\)$/\\1/'","input_text":"hello\nworld\nabcdef","expected_output":"llo\nrld\ndef","validation_input":"short\nlonger string\nxyz","validation_output":"ort\ning\nxyz","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24427009/is-there-a-cleaner-way-of-getting-the-last-n-characters-of-every-line","question_title":"Is there a cleaner way of getting the last N characters of every line?","question_owner":"merlin2011","answer_owner":"Tiago Lopo","answer_id":24427087,"question_score":32,"reviewed":true,"prediction":"sed 's/.$//'","valid":true,"correct":false,"error":null}
|
| 14 |
+
{"id":"so-25491847","request":"Extract only the second word from each line of text.","command":"sed -n 's/^[[:space:]]*[^[:space:]]*[[:space:]]\\+\\([^[:space:]]*\\).*/\\1/p'","input_text":"* CRISTOBAL AL042014 08/05/14 12 UTC *\nthis is a test","expected_output":"CRISTOBAL\nis","validation_input":" hello world foo\none two","validation_output":"world\ntwo","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25491847/extract-the-second-word-in-a-line-from-a-text-file","question_title":"Extract The Second Word In A Line From A Text File","question_owner":"Aaron Perry","answer_owner":"zedfoxus","answer_id":25491964,"question_score":32,"reviewed":true,"prediction":"sed 's/[^ ]*\\([^ ]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 15 |
+
{"id":"so-28795479","request":"Convert camelCase text to underscore_case by inserting an underscore before uppercase letters and lowercasing them.","command":"sed 's/\\([a-z0-9]\\)\\([A-Z]\\)/\\1_\\2/g; s/.*/\\L&/'","input_text":"fooBar\nmyVariableName\nsimpleTest","expected_output":"foo_bar\nmy_variable_name\nsimple_test","validation_input":"getUserName\nparseXMLData","validation_output":"get_user_name\nparse_xmldata","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28795479/awk-sed-script-to-convert-a-file-from-camelcase-to-underscores","question_title":"Awk/sed script to convert a file from camelCase to underscores","question_owner":"Corentin Peuvrel","answer_owner":"Avinash Raj","answer_id":28795550,"question_score":25,"reviewed":true,"prediction":"sed 's/\\b[A-Z][a-z]*\\b/_\\L\\1_/g'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 26: invalid reference \\1 on `s' command's RHS"}
|
| 16 |
+
{"id":"so-31903432","request":"Replace all tab characters with four spaces in the input text.","command":"sed 's/\\t/ /g'","input_text":"col1\tcol2\tcol3\nval1\tval2\tval3","expected_output":"col1 col2 col3\nval1 val2 val3","validation_input":"a\tb\n\tc","validation_output":"a b\n c","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31903432/using-sed-to-replace-tab-with-spaces","question_title":"Using sed to replace tab with spaces","question_owner":"manshuai","answer_owner":"anubhava","answer_id":31903444,"question_score":28,"reviewed":true,"prediction":"sed 's/\\t/ /g'","valid":true,"correct":false,"error":null}
|
| 17 |
+
{"id":"so-31911179","request":"Delete the first line of the input stream.","command":"sed '1d'","input_text":"Header\nLine1\nLine2","expected_output":"Line1\nLine2","validation_input":"Title\nData A\nData B","validation_output":"Data A\nData B","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31911179/ignoring-first-line-column-header-while-reading-a-file-in-bash","question_title":"Ignoring First line/Column header while reading a file in bash","question_owner":"Jai","answer_owner":"chepner","answer_id":31911198,"question_score":28,"reviewed":true,"prediction":"sed '/^$/d'","valid":true,"correct":false,"error":null}
|
| 18 |
+
{"id":"so-3194534","request":"Join every pair of consecutive lines by appending the second line to the first, effectively merging line 2 into line 1, line 4 into line 3, and so on.","command":"sed '$!N;s/\\n//'","input_text":"abcd\njoinabcd\nefgh\njoinefgh\nijkl\njoinijkl","expected_output":"abcdjoinabcd\nefghjoinefgh\nijkljoinijkl","validation_input":"line1\nline2\nline3\nline4","validation_output":"line1line2\nline3line4","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3194534/joining-two-consecutive-lines-using-awk-or-sed","question_title":"Joining two consecutive lines using awk or sed","question_owner":"Vijay","answer_owner":"Dimitre Radoulov","answer_id":3196948,"question_score":26,"reviewed":true,"prediction":"sed 's/\\([^ ]*\\) \\([^ ]*\\)/\\2\\n\\1/'","valid":true,"correct":false,"error":null}
|
| 19 |
+
{"id":"so-3302434","request":"Remove the substring 'ko:' from each line, keeping the rest of the text intact.","command":"sed 's/ko://'","input_text":"ko04062 ko:CXCR3\nko04062 ko:CX3CR1\nko04062 ko:CCL3","expected_output":"ko04062 CXCR3\nko04062 CX3CR1\nko04062 CCL3","validation_input":"ko04080 ko:GZMA\nko05414 ko:ITGA4","validation_output":"ko04080 GZMA\nko05414 ITGA4","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3302434/capturing-groups-in-sed","question_title":"capturing groups in sed","question_owner":"Mike Dewar","answer_owner":"ninjalj","answer_id":3302593,"question_score":25,"reviewed":true,"prediction":"sed s/ko:/* /","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 20 |
+
{"id":"so-34576667","request":"Replace the text 'Foo' with 'Bar' in the input stream.","command":"sed -e 's/Foo/Bar/'","input_text":"Foo","expected_output":"Bar","validation_input":"Hello Foo World","validation_output":"Hello Bar World","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34576667/sed-unescaped-newline-inside-substitute-pattern","question_title":"sed: unescaped newline inside substitute pattern?","question_owner":"RocketNuts","answer_owner":"anubhava","answer_id":34576684,"question_score":30,"reviewed":true,"prediction":"sed s/Foo/Bar/","valid":true,"correct":true,"error":null}
|
| 21 |
+
{"id":"so-3576139","request":"Remove the string 'line number' only if it appears in the last line of the input.","command":"sed '$ s/line number//g'","input_text":"first line number\nsecond line number\nlast line number","expected_output":"first line number\nsecond line number\nlast ","validation_input":"keep line number\nremove line number","validation_output":"keep line number\nremove ","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3576139/sed-remove-string-only-in-the-last-line-of-the-file","question_title":"sed + remove string only in the last line of the file","question_owner":"lidia","answer_owner":"Scharron","answer_id":3576183,"question_score":31,"reviewed":true,"prediction":"sed '/line number/d'","valid":true,"correct":false,"error":null}
|
| 22 |
+
{"id":"so-39198780","request":"Replace all newline characters with a single space in the input stream.","command":"sed ':a;N;$!ba;s/\\n/ /g'","input_text":"my\nname\nis\nxxxx","expected_output":"my name is xxxx","validation_input":"hello\nworld","validation_output":"hello world","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39198780/replace-nnew-line-with-space-in-bash","question_title":"Replace \\n(new line) with space in bash","question_owner":"Prometheus","answer_owner":"Cyrus","answer_id":39198829,"question_score":24,"reviewed":true,"prediction":"sed 's/\\n/ /g'","valid":true,"correct":false,"error":null}
|
| 23 |
+
{"id":"so-39648222","request":"Convert a multi-line text stream into a single line by replacing all newline characters with spaces, effectively joining the lines.","command":"sed ':a;N;$!ba;s/\\n/ /g'","input_text":"{\n\"key\": \"value\"\n}","expected_output":"{ \"key\": \"value\" }","validation_input":"Line 1\nLine 2\nLine 3","validation_output":"Line 1 Line 2 Line 3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39648222/converting-json-pretty-print-to-one-line","question_title":"Converting JSON pretty print to one line","question_owner":"h.b","answer_owner":"P....","answer_id":39653559,"question_score":29,"reviewed":true,"prediction":"sed 's/\\n / /g'","valid":true,"correct":false,"error":null}
|
| 24 |
+
{"id":"so-40506782","request":"Remove all characters from the beginning of each line up to and including the first occurrence of the digit '2'.","command":"sed 's/^[^2]*2//'","input_text":"ananas1kiwi2apple1banana2tree\nhello2world\ntest","expected_output":"apple1banana2tree\nworld\ntest","validation_input":"abc2def2ghi\nno_match_here\n123","validation_output":"def2ghi\nno_match_here\n3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40506782/delete-everyting-preceding-and-including-a-certain-substring-from-variable","question_title":"Delete everyting preceding and including a certain substring from variable","question_owner":"Anne K.","answer_owner":"heemayl","answer_id":40506863,"question_score":27,"reviewed":true,"prediction":"sed 's/^[0-9]*//'","valid":true,"correct":false,"error":null}
|
| 25 |
+
{"id":"so-5024357","request":"Read lines from standard input and print them until a line containing the exact string 'EOF' is encountered. The line containing 'EOF' should also be printed, and then the program should stop processing further input.","command":"sed '/EOF/q'","input_text":"Line 1\nLine 2\nThis is EOF\nLine 4","expected_output":"Line 1\nLine 2\nThis is EOF\n","validation_input":"Start\nMiddle\nEnd with EOF marker\nIgnored line","validation_output":"Start\nMiddle\nEnd with EOF marker\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5024357/do-a-tail-f-until-matching-a-pattern","question_title":"Do a tail -F until matching a pattern","question_owner":"Sam Alba","answer_owner":"jpetazzo","answer_id":5033775,"question_score":27,"reviewed":true,"prediction":"sed -n /EOF/p","valid":true,"correct":false,"error":null}
|
| 26 |
+
{"id":"so-5544322","request":"Extract and clean the value from lines starting with 'Important1: ', removing the prefix and surrounding whitespace, while suppressing all other lines.","command":"sed -n 's/^Important1: *\\([^ ]*\\) */\\1/p'","input_text":"Bla\nBla\nImportant1: One \nBla\nImportant2: Two\nBla\nBla","expected_output":"One\n","validation_input":"Ignore this\nImportant1: Value \nIgnore that\nImportant1: Another","validation_output":"Value\nAnother","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5544322/sed-get-only-the-replaced-string-from-a-multiline-input-omit-unmatched-lines","question_title":"sed - Get only the replaced string from a multiline input & omit unmatched lines!","question_owner":"porg","answer_owner":"anubhava","answer_id":5544539,"question_score":26,"reviewed":true,"prediction":"sed 's/^Importance1: //;s/[ \\t]*$//'","valid":true,"correct":false,"error":null}
|
| 27 |
+
{"id":"so-6006132","request":"Print only the lines that do not end with the string 'abcd'.","command":"sed -n '/abcd$/!p'","input_text":"this is abcd\nthis is not\nanother abcd\nend","expected_output":"this is not\nend","validation_input":"xyzabcd\nkeep this line\nfoo bar abcd\nretain","validation_output":"keep this line\nretain","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6006132/grep-line-of-text-that-does-not-end-with-abcd","question_title":"Grep. Line of text that does not end with "abcd"?","question_owner":"CCC","answer_owner":"tobyodavies","answer_id":6006139,"question_score":27,"reviewed":true,"prediction":"sed /abcd/d","valid":true,"correct":true,"error":null}
|
| 28 |
+
{"id":"so-6011661","request":"Extract the two-digit number surrounded by identical non-digit characters from each line. If a line does not match this pattern, produce no output for that line.","command":"sed -n 's/^.*\\(.\\)\\([0-9][0-9]\\)\\1.*$/\\2/p'","input_text":"plop-02-plop\nabcX99Xdef\nno-match-here\nz55z","expected_output":"02\n99\n55","validation_input":"testA12Aend\nfailB1C\nok_77_","validation_output":"12\n77","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6011661/regexp-sed-suppress-no-match-output","question_title":"regexp (sed) suppress "no match" output","question_owner":"yPhil","answer_owner":"przemoc","answer_id":6011704,"question_score":28,"reviewed":true,"prediction":"sed 's/[^0-9][^0-9]*/\\1/'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 19: invalid reference \\1 on `s' command's RHS"}
|
| 29 |
+
{"id":"so-6869449","request":"Delete lines matching the regex '^Name' but skip the first line of the input.","command":"sed -e '2,${ /^Name/d }'","input_text":"Name\nJohn\nAlbert\nMora\nName\nTommy\nTammy","expected_output":"Name\nJohn\nAlbert\nMora\nTommy\nTammy","validation_input":"Header\nData1\nHeader\nData2\nFooter","validation_output":"Header\nData1\nHeader\nData2\nFooter","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6869449/skipping-the-first-n-lines-when-using-regex-with-sed","question_title":"Skipping the first n lines when using regex with sed?","question_owner":"Legend","answer_owner":"a'r","answer_id":6869486,"question_score":26,"reviewed":true,"prediction":"sed '/^Name/c//'","valid":true,"correct":false,"error":null}
|
| 30 |
+
{"id":"so-689495","request":"Convert the uppercase letter immediately following an underscore in identifiers starting with 'get' to lowercase.","command":"sed -e 's/\\(get[A-Z][A-Za-z0-9]*_\\)\\([A-Z]\\)/\\1\\L\\2/g'","input_text":"getFoo_Bar\ngetBaz_Qux","expected_output":"getFoo_bar\ngetBaz_qux","validation_input":"getX_Y\ngetAb_Cd_Ef","validation_output":"getX_y\ngetAb_cd_Ef","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/689495/upper-to-lower-case-using-sed","question_title":"upper- to lower-case using sed","question_owner":"cadrian","answer_owner":"strager","answer_id":689608,"question_score":25,"reviewed":true,"prediction":"sed 's/_[a-z]*/\\L\\1/'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 15: invalid reference \\1 on `s' command's RHS"}
|
| 31 |
+
{"id":"so-8225822","request":"Replace all occurrences of 'A' with 'a' and only print lines where a substitution was made.","command":"sed -n 's/A/a/gp'","input_text":"Apple\nBanana\nAvocado","expected_output":"apple\navocado","validation_input":"ABC\nXYZ\nA123","validation_output":"aBC\na123","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8225822/how-to-make-sed-remove-lines-not-matched-by-a-substitution","question_title":"How to make sed remove lines not matched by a substitution","question_owner":"Ropez","answer_owner":"jaypal singh","answer_id":8255627,"question_score":28,"reviewed":true,"prediction":"sed s/A/a/g","valid":true,"correct":false,"error":null}
|
| 32 |
+
{"id":"so-8356958","request":"Remove the prefix 'foo: ' from the beginning of each line in the input text.","command":"sed 's/^foo: //'","input_text":"foo: bar1\nfoo: bar2\nfoo: bar3","expected_output":"bar1\nbar2\nbar3","validation_input":"foo: hello world\nfoo: test case\nno match here","validation_output":"hello world\ntest case\nno match here","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8356958/sed-just-trying-to-remove-a-substring","question_title":"sed: just trying to remove a substring","question_owner":"user1077220","answer_owner":"aefxx","answer_id":8356980,"question_score":28,"reviewed":true,"prediction":"sed 's/^foo: //'","valid":true,"correct":true,"error":null}
|
| 33 |
+
{"id":"so-8394066","request":"Insert a line containing two words separated by a tab character at the beginning of the input.","command":"sed '1i\\\nword1\tword2'","input_text":"Existing line 1\nExisting line 2","expected_output":"word1\tword2\nExisting line 1\nExisting line 2","validation_input":"Data start","validation_output":"word1\tword2\nData start","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8394066/what-is-the-proper-way-to-insert-tab-in-sed","question_title":"What is the proper way to insert tab in sed?","question_owner":"dabest1","answer_owner":"Jonathan Leffler","answer_id":8394150,"question_score":33,"reviewed":true,"prediction":"sed '1i \\tInserted line'","valid":true,"correct":false,"error":null}
|
| 34 |
+
{"id":"so-8991275","request":"Replace the character 'b' with a newline in the input stream.","command":"sed 's/b/\\\n/'","input_text":"abc","expected_output":"a\nc","validation_input":"xbx","validation_output":"x\nx","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8991275/escaping-newlines-in-sed-replacement-string","question_title":"escaping newlines in sed replacement string","question_owner":"spraff","answer_owner":"jaypal singh","answer_id":8991356,"question_score":29,"reviewed":true,"prediction":"sed 's/b/\\n/g'","valid":true,"correct":true,"error":null}
|
| 35 |
+
{"id":"so-9191030","request":"Remove all occurrences of the substring 'ABC' from the end of each line.","command":"sed 's/\\(ABC\\)*$//'","input_text":"DAAAAABCBBBCCABCABC\nHelloABC\nWorld","expected_output":"DAAAAABCBBBCC\nHello\nWorld","validation_input":"TestABCABC\nNoChange\nEndABC","validation_output":"Test\nNoChange\nEnd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9191030/removing-pattern-at-the-end-of-a-string-using-sed-or-other-bash-tools","question_title":"Removing pattern at the end of a string using sed or other bash tools","question_owner":"Kay Chan","answer_owner":"Birei","answer_id":9191062,"question_score":30,"reviewed":true,"prediction":"sed 's/ABC*$//'","valid":true,"correct":false,"error":null}
|
| 36 |
+
{"id":"so-9260625","request":"Extract the first sequence of digits from each line of input text.","command":"sed -n 's/^[^0-9]*\\([0-9][0-9]*\\).*/\\1/p'","input_text":"This is an example: 65 apples\nThere are 123 items here","expected_output":"65\n123","validation_input":"No numbers in this line\nValue is 42 and count is 7","validation_output":"42","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9260625/sed-extracting-group-of-digits","question_title":"sed extracting group of digits","question_owner":"Uthman","answer_owner":"codaddict","answer_id":9260734,"question_score":24,"reviewed":true,"prediction":"sed 's/[^0-9]*\\([0-9]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 37 |
+
{"id":"so-9970124","request":"Insert the line 'New Inserted Line' immediately after the first occurrence of 'Matched Keyword', before any remaining text on that line.","command":"sed '0,/Matched Keyword/s//Matched Keyword\\nNew Inserted Line/'","input_text":"Line 1\nLine 2\nThis line contains the Matched Keyword and other stuff\nLine 4\nThis line contains the Matched Keyword and other stuff\nLine 6","expected_output":"Line 1\nLine 2\nThis line contains the Matched Keyword\nNew Inserted Line and other stuff\nLine 4\nThis line contains the Matched Keyword and other stuff\nLine 6","validation_input":"Start\nMiddle Matched Keyword End\nEnd Matched Keyword Start\nFinish","validation_output":"Start\nMiddle Matched Keyword\nNew Inserted Line End\nEnd Matched Keyword Start\nFinish","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9970124/sed-to-insert-on-first-match-only","question_title":"sed to insert on first match only","question_owner":"SSS","answer_owner":"Squazic","answer_id":9970467,"question_score":26,"reviewed":true,"prediction":"sed '/Matched Keyword/i New Inserted Line'","valid":true,"correct":false,"error":null}
|
evaluation/v1-test.summary.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "asterbraid/sedweave-0.5b",
|
| 3 |
+
"split": "test",
|
| 4 |
+
"rows": 37,
|
| 5 |
+
"valid_at_1": 0.8918918918918919,
|
| 6 |
+
"correct_at_1": 0.1891891891891892,
|
| 7 |
+
"exact_output_on_two_inputs": true,
|
| 8 |
+
"prediction_cleanup": "special tokens only",
|
| 9 |
+
"seconds": 19.91174840927124,
|
| 10 |
+
"data_sha256": "9351a02c467b606e9c16ca2b2fcef7309850a4edfd3b539e9adc192ac766b555",
|
| 11 |
+
"transformers_version": "5.17.0",
|
| 12 |
+
"torch_version": "2.14.0",
|
| 13 |
+
"families": {
|
| 14 |
+
"real-stackoverflow": {
|
| 15 |
+
"rows": 37,
|
| 16 |
+
"valid": 33,
|
| 17 |
+
"correct": 7
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
evaluation/v2-dev.jsonl
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"so-1032023","request":"Replace all occurrences of the whole word 'bar' with 'no bar' in the input text, ensuring that partial matches like 'embarassment' are not affected.","command":"sed 's/\\bbar\\b/no bar/g'","input_text":"bar embarassment\nbar foo bar\nfoobar","expected_output":"no bar embarassment\nno bar foo no bar\nfoobar","validation_input":"start bar end\nno bar here\nbarbell","validation_output":"start no bar end\nno no bar here\nbarbell","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1032023/sed-whole-word-search-and-replace","question_title":"sed whole word search and replace","question_owner":"ksuralta","answer_owner":"Joakim Lundborg","answer_id":1032039,"question_score":159,"reviewed":true,"prediction":"sed -e 's/bar/no bar/g'","valid":true,"correct":false,"error":null}
|
| 2 |
+
{"id":"so-11145270","request":"Replace the entire third line of the input text with the string 'replacement-line'.","command":"sed '3s/.*/replacement-line/'","input_text":"Line one\nLine two\nLine three\nLine four","expected_output":"Line one\nLine two\nreplacement-line\nLine four","validation_input":"Alpha\nBeta\nGamma\nDelta\nEpsilon","validation_output":"Alpha\nBeta\nreplacement-line\nDelta\nEpsilon","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11145270/how-to-replace-an-entire-line-in-a-text-file-by-line-number","question_title":"How to replace an entire line in a text file by line number","question_owner":"user788171","answer_owner":"chepner","answer_id":11145362,"question_score":225,"reviewed":true,"prediction":"sed '/^3/d;s/ replacement-line//'","valid":true,"correct":false,"error":null}
|
| 3 |
+
{"id":"so-11245144","request":"Replace any line containing the string 'TEXT_TO_BE_REPLACED' with the text 'This line is removed by the admin.'","command":"sed '/TEXT_TO_BE_REPLACED/c\\This line is removed by the admin.'","input_text":"sometext sometext sometext TEXT_TO_BE_REPLACED sometext sometext sometext\nother line\nanother line with TEXT_TO_BE_REPLACED here","expected_output":"This line is removed by the admin.\nother line\nThis line is removed by the admin.\n","validation_input":"line one\nTEXT_TO_BE_REPLACED\nline three","validation_output":"line one\nThis line is removed by the admin.\nline three","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11245144/replace-whole-line-containing-a-string-using-sed","question_title":"Replace whole line containing a string using Sed","question_owner":"Rahul","answer_owner":"Todd A. Jacobs","answer_id":11245501,"question_score":472,"reviewed":true,"prediction":"sed '/TEXT_TO_BE_REPLACED/c This line is removed by the admin.'","valid":true,"correct":true,"error":null}
|
| 4 |
+
{"id":"so-11469989","request":"Remove the first 4 characters from each line of input.","command":"sed 's/^....//'","input_text":"pid: 1234\nname: test","expected_output":" 1234\n: test","validation_input":"code: ABCD\nid: 9999","validation_output":": ABCD\n9999","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11469989/how-can-i-strip-first-x-characters-from-string-using-sed","question_title":"How can I strip first X characters from string using sed?","question_owner":"Kokesh","answer_owner":"Arnaud F.","answer_id":11470076,"question_score":174,"reviewed":true,"prediction":"sed 's/^\\(.\\{4\\}\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 5 |
+
{"id":"so-11568859","request":"Extract the first sequence of digits followed by 'G' and more digits from each line, printing only the match.","command":"sed -n 's/^[^0-9]*\\([0-9][0-9]*G[0-9][0-9]*\\).*/\\1/p'","input_text":"This is 02G05 a test string 20-Jul-2012","expected_output":"02G05","validation_input":"No match here\nCode 123G456 found\n9G1 end","validation_output":"123G456\n9G1","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11568859/how-to-extract-text-from-a-string-using-sed","question_title":"How to extract text from a string using sed?","question_owner":"RanRag","answer_owner":"tripleee","answer_id":11568930,"question_score":130,"reviewed":true,"prediction":"sed -n 's/^\\(.\\{3\\}\\)G.*\\{4\\}\\(.\\{4\\}\\).*/\\1/'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 37: Invalid preceding regular expression"}
|
| 6 |
+
{"id":"so-13055889","request":"Replace all commas with a comma surrounded by single quotes in the input text.","command":"sed \"s/,/','/g\"","input_text":"A,B,C","expected_output":"A','B','C","validation_input":"X,Y,Z\n1,2","validation_output":"X','Y','Z\n1','2","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13055889/sed-with-literal-string-not-input-file","question_title":"sed with literal string--not input file","question_owner":"amphibient","answer_owner":"Gilles Quénot","answer_id":13055913,"question_score":135,"reviewed":true,"prediction":"sed 's/,/\\'\"\\1\"\\',/'","valid":false,"correct":false,"error":"Cannot parse sed command: No closing quotation"}
|
| 7 |
+
{"id":"so-13242469","request":"Extract the text between the words 'Here' and 'String' on a single line, removing the words themselves.","command":"sed 's/^.*Here\\(.*\\)String.*$/\\1/'","input_text":"Here is a String","expected_output":" is a ","validation_input":"Here we go String now","validation_output":" we go ","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13242469/how-to-use-sed-grep-to-extract-text-between-two-words","question_title":"How to use sed/grep to extract text between two words?","question_owner":"user1190650","answer_owner":"Brian Campbell","answer_id":13242517,"question_score":228,"reviewed":true,"prediction":"sed -n /Here/,/String/p","valid":true,"correct":false,"error":null}
|
| 8 |
+
{"id":"so-1429556","request":"Print only the second line of the input stream.","command":"sed -n '2p'","input_text":"first line\nsecond line\nthird line","expected_output":"second line\n","validation_input":"alpha\nbeta\ngamma\ndelta","validation_output":"beta\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1429556/command-to-get-nth-line-of-stdout","question_title":"Command to get nth line of STDOUT","question_owner":"Alana Storm","answer_owner":"Jonathan Leffler","answer_id":1429628,"question_score":277,"reviewed":true,"prediction":"sed -n '2p'","valid":true,"correct":true,"error":null}
|
| 9 |
+
{"id":"so-14671293","request":"Remove all sequences of digits from the input text using a POSIX-compatible character class.","command":"sed 's/[[:digit:]]\\+//g'","input_text":"abc123def456\n789xyz","expected_output":"abcdef\nxyz","validation_input":"no digits here\n1a2b3c","validation_output":"no digits here\nabc","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/14671293/why-doesnt-d-work-in-regular-expressions-in-sed","question_title":"Why doesn't `\\d` work in regular expressions in sed?","question_owner":"user2036880","answer_owner":"Kamil","answer_id":14671415,"question_score":105,"reviewed":true,"prediction":"sed 's/[0-9][0-9]*/\\1/g'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 18: invalid reference \\1 on `s' command's RHS"}
|
| 10 |
+
{"id":"so-148451","request":"Replace only the first occurrence of the string 'foo' with 'bar' in the input stream.","command":"sed '0,/foo/s//bar/'","input_text":"foo baz\nfoo qux\nfoo end","expected_output":"bar baz\nfoo qux\nfoo end","validation_input":"no match here\nfoo match here\nfoo another","validation_output":"no match here\nbar match here\nfoo another","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file","question_title":"How to use sed to replace only the first occurrence in a file?","question_owner":"David Dibben","answer_owner":"Ben Hoffstein","answer_id":148473,"question_score":346,"reviewed":true,"prediction":"sed s/foo/bar/1p","valid":true,"correct":false,"error":null}
|
| 11 |
+
{"id":"so-15559359","request":"Insert the line 'CLIENTSCRIPT2=\"hello\"' after the first line that matches 'CLIENTSCRIPT=\"foo\"'.","command":"sed '/CLIENTSCRIPT=\"foo\"/a\\\nCLIENTSCRIPT2=\"hello\"'","input_text":"CLIENTSCRIPT=\"foo\"\nCLIENTFILE=\"bar\"","expected_output":"CLIENTSCRIPT=\"foo\"\nCLIENTSCRIPT2=\"hello\"\nCLIENTFILE=\"bar\"","validation_input":"line1\nCLIENTSCRIPT=\"foo\"\nline3","validation_output":"line1\nCLIENTSCRIPT=\"foo\"\nCLIENTSCRIPT2=\"hello\"\nline3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15559359/insert-line-after-match-using-sed","question_title":"Insert line after match using sed","question_owner":"user2150250","answer_owner":"Gilles Quénot","answer_id":15559399,"question_score":371,"reviewed":true,"prediction":"sed '/CLIENTSCRIPT=\"foo\"/a CLIENTSCRIPT2=\"hello\"'","valid":true,"correct":true,"error":null}
|
| 12 |
+
{"id":"so-15849119","request":"Replace all occurrences of the word 'dog' with 'log' in each line of the input.","command":"sed -e 's/dog/log/g'","input_text":"dog dog dos","expected_output":"log log dos","validation_input":"a dog b dog c","validation_output":"a log b log c","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15849119/why-does-sed-not-replace-all-occurrences","question_title":"Why does sed not replace all occurrences?","question_owner":"Nishant George Agrwal","answer_owner":"Bruno Reis","answer_id":15849152,"question_score":188,"reviewed":true,"prediction":"sed 's/dog/log/g'","valid":true,"correct":true,"error":null}
|
| 13 |
+
{"id":"so-16414410","request":"Remove all lines that are empty or contain only whitespace characters from the input text.","command":"sed '/^[[:space:]]*$/d'","input_text":"xxxxxx\n \n\nyyyyyy\n\t\nzzzzzz","expected_output":"xxxxxx\nyyyyyy\nzzzzzz","validation_input":"hello\n \nworld\n\nfoo","validation_output":"hello\nworld\nfoo","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16414410/delete-empty-lines-using-sed","question_title":"Delete empty lines using sed","question_owner":"jonas","answer_owner":"Kent","answer_id":16414489,"question_score":530,"reviewed":true,"prediction":"sed '/^$/d'","valid":true,"correct":false,"error":null}
|
| 14 |
+
{"id":"so-1665549","request":"Extract the filename from lines matching the pattern '[wrote filename.class]' and suppress all other lines.","command":"sed -n 's/^\\[wrote \\(.*\\.class\\)\\]$/\\1/p'","input_text":"[wrote some-class-name.class]","expected_output":"some-class-name.class","validation_input":"[wrote Main.class]\ncompiling...\n[wrote Utils.class]","validation_output":"Main.class\nUtils.class","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1665549/have-sed-ignore-non-matching-lines","question_title":"Have sed ignore non-matching lines","question_owner":"Paggas","answer_owner":"liori","answer_id":1665662,"question_score":138,"reviewed":true,"prediction":"sed -n /[wrote filename.class]/p","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 15 |
+
{"id":"so-1706431","request":"Replace all spaces in the input with underscores.","command":"sed 's/ /_/g'","input_text":"This is just a test\nWindows XP","expected_output":"This_is_just_a_test\nWindows_XP","validation_input":"Hello World Foo Bar\nMy File Name.txt","validation_output":"Hello_World_Foo_Bar\nMy_File_Name.txt","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1706431/the-easiest-way-to-replace-white-spaces-with-underscores-in-bash","question_title":"The easiest way to replace white spaces with (underscores) _ in bash","question_owner":"flazzarini","answer_owner":"ghostdog74","answer_id":1706459,"question_score":107,"reviewed":true,"prediction":"sed 's/[ \\t]+/_/g'","valid":true,"correct":false,"error":null}
|
| 16 |
+
{"id":"so-17511639","request":"Extract and print only the last integer and floating-point number (separated by whitespace) from each line, ignoring preceding text.","command":"sed -n 's/^.*[^0-9]\\([0-9][0-9]*\\)[ \\t]\\([0-9][0-9]*\\.[0-9][0-9]*\\)[ \\t]*$/\\1 \\2/p'","input_text":"foo bar <foo> bla 1 2 3.4\nno match here\nvalues 10 20.5","expected_output":"2 3.4\n10 20.5","validation_input":"test 5 6.7\nabc 123 456.789\nnothing","validation_output":"5 6.7\n123 456.789\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/17511639/sed-print-only-matching-group","question_title":"sed: print only matching group","question_owner":"mort","answer_owner":"iruvar","answer_id":17511700,"question_score":205,"reviewed":true,"prediction":"sed 's/[^ ]* \\([^ ]*\\) [^ ]*\\).*/\\1/'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 31: Unmatched ) or \\)"}
|
| 17 |
+
{"id":"so-18439528","request":"Insert the line ' hello world' (with three leading spaces) before the second line of the input text.","command":"sed '2i\\ hello world'","input_text":"hello\nworld","expected_output":"hello\n hello world\nworld","validation_input":"line1\nline2\nline3","validation_output":"line1\n hello world\nline2\nline3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18439528/sed-insert-line-with-leading-spaces-to-a-specific-line","question_title":"sed insert line with leading spaces to a specific line","question_owner":"Ggdw","answer_owner":"Atropo","answer_id":18439749,"question_score":120,"reviewed":true,"prediction":"sed '/second/a hello world'","valid":true,"correct":false,"error":null}
|
| 18 |
+
{"id":"so-20348097","request":"Remove the colon and everything after it from each line of input.","command":"sed 's/:.*//'","input_text":"/some/random/file.csv:some string\n/some/random/file2.csv:some string2","expected_output":"/some/random/file.csv\n/some/random/file2.csv","validation_input":"path/to/data.txt:value here\nanother/path.log:more data","validation_output":"path/to/data.txt\nanother/path.log","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon","question_title":"bash, extract string before a colon","question_owner":"user788171","answer_owner":"ray","answer_id":20348145,"question_score":111,"reviewed":true,"prediction":"sed 's/[^:]*:\\([^:]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 19 |
+
{"id":"so-2112469","request":"Delete lines 5 through 10 and line 12 from the input text.","command":"sed -e '5,10d;12d'","input_text":"Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8","expected_output":"Line 1\nLine 2\nLine 3\nLine 4\n","validation_input":"A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM","validation_output":"A\nB\nC\nD\nK\nM","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2112469/delete-specific-line-numbers-from-a-text-file-using-sed","question_title":"Delete specific line number(s) from a text file using sed?","question_owner":"Justin Ethier","answer_owner":"Brian Campbell","answer_id":2112496,"question_score":367,"reviewed":true,"prediction":"sed 5,10d; sed 12d","valid":false,"correct":false,"error":"Expected exactly one sed expression and no filenames."}
|
| 20 |
+
{"id":"so-24509214","request":"Replace the string 'ones' with 'one's' in the input text using sed.","command":"sed \"s/ones/one's/g\"","input_text":"ones thing","expected_output":"one's thing","validation_input":"ones and ones again","validation_output":"one's and one's again","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24509214/how-to-escape-single-quote-in-sed","question_title":"How to escape single quote in sed?","question_owner":"Thomas Bratt","answer_owner":"Kent","answer_id":24509931,"question_score":148,"reviewed":true,"prediction":"sed s/ones/one's/","valid":false,"correct":false,"error":"Cannot parse sed command: No closing quotation"}
|
| 21 |
+
{"id":"so-2610115","request":"Insert a literal tab character at the beginning of every line in the input.","command":"sed 's/^/\t/'","input_text":"hello\nworld","expected_output":"\thello\n\tworld","validation_input":"foo\nbar\nbaz","validation_output":"\tfoo\n\tbar\n\tbaz","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2610115/why-is-sed-not-recognizing-t-as-a-tab","question_title":"Why is sed not recognizing \\t as a tab?","question_owner":"sixtyfootersdude","answer_owner":"Mark Byers","answer_id":2610121,"question_score":132,"reviewed":true,"prediction":"sed 's/^/\\\\t/'","valid":true,"correct":false,"error":null}
|
| 22 |
+
{"id":"so-26568952","request":"Swap all occurrences of 'ab' with 'bc' and 'bc' with 'ab' simultaneously in the input stream, assuming '~' does not appear in the text.","command":"sed 's/ab/~~/g; s/bc/ab/g; s/~~/bc/g'","input_text":"abbc","expected_output":"bcab","validation_input":"abc ab bc","validation_output":"bcc bc ab","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/26568952/how-to-swap-text-based-on-patterns-at-once-with-sed","question_title":"How to swap text based on patterns at once with sed?","question_owner":"DaniloNC","answer_owner":"ooga","answer_id":26568996,"question_score":344,"reviewed":true,"prediction":"sed 's/ab/bc/g; s/bc/ab/g'","valid":true,"correct":false,"error":null}
|
| 23 |
+
{"id":"so-2777579","request":"Extract only the sequences of digits from each line, separated by a space. If a line has multiple digit sequences, print them all on one line separated by spaces. If no digits, print nothing for that line.","command":"sed -n 's/[^0-9][^0-9]*/ /g; s/^ *//; s/ *$//; /[0-9]/p'","input_text":"This is a sample 123 text and some 987 numbers\nno numbers here\nabc 42 def","expected_output":"123 987\n42","validation_input":"start 10 middle 20 end\njust text\n555","validation_output":"10 20\n555","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2777579/how-can-i-output-only-captured-groups-with-sed","question_title":"How can I output only captured groups with sed?","question_owner":"Pablo","answer_owner":"Dennis Williamson","answer_id":2778096,"question_score":426,"reviewed":true,"prediction":"sed 's/[0-9][0-9]*/&/g'","valid":true,"correct":false,"error":null}
|
| 24 |
+
{"id":"so-2869669","request":"Append the string 'string after each line' to the end of every line in the input.","command":"sed -e 's/$/string after each line/'","input_text":"Line one\nLine two\nLine three","expected_output":"Line onestring after each line\nLine twostring after each line\nLine threestring after each line","validation_input":"Hello World\nFoo Bar","validation_output":"Hello Worldstring after each line\nFoo Barstring after each line","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/2869669/in-bash-how-do-i-add-a-string-after-each-line-in-a-file","question_title":"In Bash, how do I add a string after each line in a file?","question_owner":"Jason Volkoz","answer_owner":"Tom DeGisi","answer_id":2869736,"question_score":170,"reviewed":true,"prediction":"sed '/^$/a string after each line'","valid":true,"correct":false,"error":null}
|
| 25 |
+
{"id":"so-3134791","request":"Remove all newline characters from the input text to join all lines into a single continuous string.","command":"sed ':a;N;$!ba;s/\\n//g'","input_text":"22791\n;\n14336\n;\n22821\n;","expected_output":"22791;14336;22821;","validation_input":"A\nB\nC\n","validation_output":"ABC\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3134791/how-do-i-remove-newlines-from-a-text-file","question_title":"How do I remove newlines from a text file?","question_owner":"Alucard","answer_owner":"Tyler McHenry","answer_id":3134827,"question_score":213,"reviewed":true,"prediction":"sed 's/[ \\t]*$//'","valid":true,"correct":false,"error":null}
|
| 26 |
+
{"id":"so-38672680","request":"Join all lines into a single line, replacing newlines with the literal characters backslash and n.","command":"sed ':a;N;$!ba;s/\\n/\\\\n/g'","input_text":"Line one\nLine two\nLine three","expected_output":"Line one\\nLine two\\nLine three","validation_input":"First\nSecond","validation_output":"First\\nSecond","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38672680/replace-newlines-with-literal-n","question_title":"Replace newlines with literal \\n","question_owner":"Parze","answer_owner":"anubhava","answer_id":38672741,"question_score":106,"reviewed":true,"prediction":"sed 's/\\n/\\\\n/g'","valid":true,"correct":false,"error":null}
|
| 27 |
+
{"id":"so-38972736","request":"Print all lines from the first occurrence of 'PAT1' to the next occurrence of 'PAT2', inclusive of both pattern lines.","command":"sed -n '/PAT1/,/PAT2/p'","input_text":"1\n2\nPAT1\n3\n4\nPAT2\n5","expected_output":"PAT1\n3\n4\nPAT2\n","validation_input":"start\nPAT1\nmiddle\nend\nPAT2\nfinish","validation_output":"PAT1\nmiddle\nend\nPAT2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38972736/how-to-print-lines-between-two-patterns-inclusive-or-exclusive-in-sed-awk-or","question_title":"How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?","question_owner":"fedorqui","answer_owner":"fedorqui","answer_id":38972737,"question_score":116,"reviewed":true,"prediction":"sed -n /PAT1/,/PAT2/p","valid":true,"correct":true,"error":null}
|
| 28 |
+
{"id":"so-4569825","request":"Convert all uppercase letters in the input text to lowercase.","command":"sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'","input_text":"Hello World\nTHIS IS A TEST\nMixed Case Text","expected_output":"hello world\nthis is a test\nmixed case text","validation_input":"ABCdef\nXYZ123\nNo Change here","validation_output":"abcdef\nxyz123\nno change here","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/4569825/sed-one-liner-to-convert-all-uppercase-to-lowercase","question_title":"sed one-liner to convert all uppercase to lowercase?","question_owner":"magnetar","answer_owner":"magnetar","answer_id":4581564,"question_score":213,"reviewed":true,"prediction":"sed 's/.*/\\L&/'","valid":true,"correct":true,"error":null}
|
| 29 |
+
{"id":"so-5080988","request":"Extract the value inside double quotes that immediately follows name= on each line.","command":"sed -n 's/.*name=\"\\([^\"]*\\)\".*/\\1/p'","input_text":"<table name=\"content_analyzer\" primary-key=\"id\">\n<type=\"global\" />\n</table>","expected_output":"content_analyzer\n","validation_input":"<tag name=\"test_value\" attr=\"val\">","validation_output":"test_value","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5080988/how-to-extract-string-following-a-pattern-with-grep-regex-or-perl","question_title":"How to extract string following a pattern with grep, regex or perl","question_owner":"wrangler","answer_owner":"sidyll","answer_id":5081519,"question_score":122,"reviewed":true,"prediction":"sed -n 's/.*name=\"\\([^\"]*\\)\"[^>]*>//p'","valid":true,"correct":false,"error":null}
|
| 30 |
+
{"id":"so-5227295","request":"Delete the line matching 'The second line' and all subsequent lines from the input text.","command":"sed '/The second line/,$d'","input_text":"The first line\nThe second line\nThe third line\nThe fourth line","expected_output":"The first line\n","validation_input":"Line A\nLine B\nThe second line\nLine C","validation_output":"Line A\nLine B\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5227295/how-do-i-delete-all-lines-in-a-file-starting-from-after-a-matching-line","question_title":"How do I delete all lines in a file starting from after a matching line?","question_owner":"DocWiki","answer_owner":"Dennis Williamson","answer_id":5227429,"question_score":126,"reviewed":true,"prediction":"sed '/The second line/d'","valid":true,"correct":false,"error":null}
|
| 31 |
+
{"id":"so-538664","request":"Print only the first 12 characters of each line from the input text.","command":"sed -e 's/^\\(.\\{12\\}\\).*/\\1/'","input_text":"Hello World This Is A Test\nShort\nThis is a longer line that exceeds twelve characters","expected_output":"Hello World \nShort\nThis is a lo","validation_input":"123456789012345\n123456789012\nabcdefghijklmnop","validation_output":"123456789012\n123456789012\nabcdefghijkl","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/538664/using-sed-how-do-you-print-the-first-n-characters-of-a-line","question_title":"Using sed, how do you print the first 'N' characters of a line?","question_owner":"Berlin Brown","answer_owner":"Paul Tomblin","answer_id":538676,"question_score":153,"reviewed":true,"prediction":"sed 's/^\\(.\\{12\\}\\).*/\\1/'","valid":true,"correct":true,"error":null}
|
| 32 |
+
{"id":"so-5410757","request":"Delete all lines containing the string 'error' from the input text.","command":"sed '/error/d'","input_text":"line one\nerror found here\nline three\nanother error line\nfinal line","expected_output":"line one\nline three\nfinal line","validation_input":"no errors here\nthis is clean\nerror in middle\nclean again","validation_output":"this is clean\nclean again","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5410757/how-can-i-delete-all-lines-that-contain-a-specific-string-from-a-text-file","question_title":"How can I delete all lines that contain a specific string from a text file?","question_owner":"A Clockwork Orange","answer_owner":"SiegeX","answer_id":5410784,"question_score":2423,"reviewed":true,"prediction":"sed /error/d","valid":true,"correct":true,"error":null}
|
| 33 |
+
{"id":"so-6022384","request":"Print only the 3rd line of the input text.","command":"sed '3q;d'","input_text":"first line\nsecond line\nthird line\nfourth line\nfifth line","expected_output":"third line\n","validation_input":"alpha\nbeta\ngamma\ndelta","validation_output":"gamma\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file","question_title":"Bash tool to get nth line from a file","question_owner":"Vlad Vivdovitch","answer_owner":"anubhava","answer_id":6022431,"question_score":914,"reviewed":true,"prediction":"sed -n '3p'","valid":true,"correct":true,"error":null}
|
| 34 |
+
{"id":"so-6287755","request":"Delete all lines strictly between a line starting with # and a line starting with $, keeping the boundary lines.","command":"sed '/^#/,/^\\$/{/^#/!{/^\\$/!d}}'","input_text":"# ID 1\nblah blah\nblah blah\n$ description 1\nblah blah","expected_output":"# ID 1\n$ description 1\nblah blah","validation_input":"# Start\nremove this\nand this\n$ End\nkeep this","validation_output":"# Start\n$ End\nkeep this","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6287755/using-sed-to-delete-all-lines-between-two-matching-patterns","question_title":"Using sed to delete all lines between two matching patterns","question_owner":"Ken","answer_owner":"anubhava","answer_id":6287940,"question_score":120,"reviewed":true,"prediction":"sed '/^#/d;/^$/d'","valid":true,"correct":false,"error":null}
|
| 35 |
+
{"id":"so-723157","request":"Insert a newline before every occurrence of a phone number pattern like (012)345-6789 in the input text.","command":"sed 's/(\\([0-9]\\{3\\}\\))[0-9]\\{3\\}-[0-9]\\{4\\}/\\n&/g'","input_text":"some text (012)345-6789","expected_output":"some text \n(012)345-6789","validation_input":"call (123)456-7890 or (987)654-3210 now","validation_output":"call \n(123)456-7890 or \n(987)654-3210 now","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/723157/how-to-insert-a-newline-in-front-of-a-pattern","question_title":"How to insert a newline in front of a pattern?","question_owner":"Dennis","answer_owner":"Dennis","answer_id":723247,"question_score":146,"reviewed":true,"prediction":"sed 's/\\([^)]*\\)\\)/\\1\\n&/g'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 21: Unmatched ) or \\)"}
|
| 36 |
+
{"id":"so-7451423","request":"Print only the line immediately following any line that contains the string 'blah'. Do not print the matching line itself.","command":"sed -n '/blah/{n;p;}'","input_text":"header\nblah found\nnext line content\nfooter","expected_output":"next line content\n","validation_input":"no match here\nblah trigger\nresult line\nanother blah\nsecond result\nend","validation_output":"result line\nsecond result\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one","question_title":"How to show only next line after the matched one?","question_owner":"facha","answer_owner":"Michał Šrajer","answer_id":7451456,"question_score":279,"reviewed":true,"prediction":"sed -n /blah/p","valid":true,"correct":false,"error":null}
|
| 37 |
+
{"id":"so-7517632","request":"Replace the literal string \"http://www.fubar.com\" with URL_FUBAR in the input.","command":"sed 's#\"http://www\\.fubar\\.com\"#URL_FUBAR#g'","input_text":"Visit \"http://www.fubar.com\" now.\nKeep \"http://other.com\".","expected_output":"Visit URL_FUBAR now.\nKeep \"http://other.com\".","validation_input":"Link: \"http://www.fubar.com\"","validation_output":"Link: URL_FUBAR","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/7517632/how-do-i-escape-slashes-and-double-and-single-quotes-in-sed","question_title":"How do I escape slashes and double and single quotes in sed?","question_owner":"KRB","answer_owner":"Kusalananda","answer_id":7517900,"question_score":122,"reviewed":true,"prediction":"sed s/http://www.fubar.com/URL_FUBAR/g","valid":false,"correct":false,"error":"/usr/bin/sed: couldn't open file ww.fubar.com/URL_FUBAR/g: No such file or directory"}
|
| 38 |
+
{"id":"so-8206280","request":"Delete all lines that begin with a hash character (#) from the input text.","command":"sed '/^#/d'","input_text":"# This is a comment\nThis is code\n# Another comment\nMore code # inline comment","expected_output":"This is code\nMore code # inline comment","validation_input":"# Comment line 1\nValid line 1\n# Comment line 2\nValid line 2 with # symbol","validation_output":"Valid line 1\nValid line 2 with # symbol","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8206280/delete-all-lines-beginning-with-a-from-a-file","question_title":"Delete all lines beginning with a # from a file","question_owner":"Village","answer_owner":"Raymond Hettinger","answer_id":8206295,"question_score":283,"reviewed":true,"prediction":"sed '/^#/d'","valid":true,"correct":true,"error":null}
|
| 39 |
+
{"id":"so-8822097","request":"Replace any line starting with 'aaa=' followed by any characters with the line 'aaa=xxx'.","command":"sed 's/^aaa=.*/aaa=xxx/'","input_text":"aaa=bbb\naaa=ccc\naaa=ddd\nother=line","expected_output":"aaa=xxx\naaa=xxx\naaa=xxx\nother=line","validation_input":"aaa=test\nkeep=this\naaa=value","validation_output":"aaa=xxx\nkeep=this\naaa=xxx","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8822097/how-to-replace-a-whole-line-with-sed","question_title":"How to replace a whole line with sed?","question_owner":"Michael","answer_owner":"John Doyle","answer_id":8822211,"question_score":253,"reviewed":true,"prediction":"sed '/^aaa=/ { s/^aaa=//; s/^\\(.\\{0,\\}\\).*/\\1=xxx; }'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 47: unterminated `s' command"}
|
| 40 |
+
{"id":"so-9533679","request":"Prepend the text '<added text> ' to the beginning of the first line of the input stream without adding a new line.","command":"sed '1s/^/<added text> /'","input_text":"some text at the beginning\nsecond line","expected_output":"<added text> some text at the beginning\nsecond line","validation_input":"hello world","validation_output":"<added text> hello world","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9533679/how-to-insert-a-text-at-the-beginning-of-a-file","question_title":"How to insert a text at the beginning of a file?","question_owner":"user219882","answer_owner":"kev","answer_id":9533736,"question_score":350,"reviewed":true,"prediction":"sed 's/^/<< added text >/'","valid":true,"correct":false,"error":null}
|
| 41 |
+
{"id":"so-9605232","request":"Merge every two consecutive lines into a single line separated by a space.","command":"sed 'N;s/\\n/ /'","input_text":"KEY 4048:1736 string\n3\nKEY 0:1772 string\n1","expected_output":"KEY 4048:1736 string 3\nKEY 0:1772 string 1","validation_input":"Line A\nLine B\nLine C\nLine D","validation_output":"Line A Line B\nLine C Line D","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9605232/how-to-merge-every-two-lines-into-one-from-the-command-line","question_title":"How to merge every two lines into one from the command line?","question_owner":"shantanuo","answer_owner":"Kent","answer_id":9605559,"question_score":229,"reviewed":true,"prediction":"sed 's/\\([^ ]*\\) \\([^ ]*\\)/\\1 \\2/'","valid":true,"correct":false,"error":null}
|
| 42 |
+
{"id":"so-9953448","request":"Remove every space and tab character from each input line.","command":"sed 's/[[:space:]]//g'","input_text":"Hello \t World\nNew Line","expected_output":"HelloWorld\nNewLine","validation_input":"a b\tc\nd","validation_output":"abc\nd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9953448/how-to-remove-all-white-spaces-from-a-given-text-file","question_title":"How to remove all white spaces from a given text file?","question_owner":"Lunar Mushrooms","answer_owner":"Paulo Scardine","answer_id":9953487,"question_score":123,"reviewed":true,"prediction":"sed 's/[ \\t]+/ /g'","valid":true,"correct":false,"error":null}
|
evaluation/v2-dev.summary.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "/outputs/aae244b1-b1ab-4dbd-a1e3-815e9d722ec7/training/model",
|
| 3 |
+
"split": "test",
|
| 4 |
+
"rows": 42,
|
| 5 |
+
"valid_at_1": 0.7619047619047619,
|
| 6 |
+
"correct_at_1": 0.23809523809523808,
|
| 7 |
+
"exact_output_on_two_inputs": true,
|
| 8 |
+
"prediction_cleanup": "special tokens only",
|
| 9 |
+
"seconds": 15.143665075302124,
|
| 10 |
+
"data_sha256": "5e8eec182a096b1d169845ef6f03235b3166b7f3315b473ec8cbc3e44dfc8c44",
|
| 11 |
+
"transformers_version": "5.17.0",
|
| 12 |
+
"torch_version": "2.14.0",
|
| 13 |
+
"families": {
|
| 14 |
+
"real-stackoverflow": {
|
| 15 |
+
"rows": 42,
|
| 16 |
+
"valid": 32,
|
| 17 |
+
"correct": 10
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
evaluation/v2-test.jsonl
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"so-10754682","request":"Wrap each line in double quotes, handling potential carriage returns at the end of lines by removing them before quoting.","command":"sed 's/\\r$//; s/.*/\"&\"/'","input_text":"name,id,3\r\nuser,pass,4\r\n","expected_output":"\"name,id,3\"\n\"user,pass,4\"\n","validation_input":"hello,world\r\ntest,data\r\n","validation_output":"\"hello,world\"\n\"test,data\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/10754682/how-to-add-double-quotes-to-a-line-with-sed-or-awk","question_title":"How to add double quotes to a line with SED or AWK?","question_owner":"minerals","answer_owner":"Dennis Williamson","answer_id":10755347,"question_score":31,"reviewed":true,"prediction":"sed 's/[ \\t]*$//' s/[^\"]*\"\\([^\"]*\\)\"'/'\"/g s/\\([^\"]*\\)/\\\"\\1\\\"/'","valid":false,"correct":false,"error":"Cannot parse sed command: No closing quotation"}
|
| 2 |
+
{"id":"so-11687216","request":"Remove all blank lines from the input text.","command":"sed '/^$/d'","input_text":"Line 1\n\nLine 3\n\nLine 5","expected_output":"Line 1\nLine 3\nLine 5","validation_input":"Hello\n\nWorld\n\nEnd","validation_output":"Hello\nWorld\nEnd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/11687216/awk-to-skip-the-blank-lines","question_title":"Awk to skip the blank lines","question_owner":"Gil","answer_owner":"Levon","answer_id":11687266,"question_score":33,"reviewed":true,"prediction":"sed '/^$/d'","valid":true,"correct":true,"error":null}
|
| 3 |
+
{"id":"so-13202715","request":"Print only the lines that start with the prefix 'RIM-COD-' from the input text.","command":"sed -n -e '/^RIM-COD-/p'","input_text":"RIM-COD-URL-12: HelloWorld-12.cod\nRIM-COD-Size: 68020\nRIM-MIDlet-Icon-2-1: icon.png\nRIM-COD-URL-11: HelloWorld-11.cod","expected_output":"RIM-COD-URL-12: HelloWorld-12.cod\nRIM-COD-Size: 68020\nRIM-COD-URL-11: HelloWorld-11.cod","validation_input":"RIM-COD-URL-10: Test.cod\nOther-Line: Value\nRIM-COD-SHA1: abc123\nManifest-Version: 1.0","validation_output":"RIM-COD-URL-10: Test.cod\nRIM-COD-SHA1: abc123\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/13202715/sed-get-lines-beginning-with-some-prefix","question_title":"Sed: get lines beginning with some prefix","question_owner":"CAMOBAP","answer_owner":"John3136","answer_id":13202727,"question_score":30,"reviewed":true,"prediction":"sed -n /RIM-COD-*/p","valid":true,"correct":true,"error":null}
|
| 4 |
+
{"id":"so-14046878","request":"Delete from the first line exactly matching '-----THIS STUFF IS USELESS-----' to the end of the input stream.","command":"sed '/^-----THIS STUFF IS USELESS-----$/,$d'","input_text":"Files:\nsomefiles.tar.gz 1 2 3\nsomefiles.tar.gz 1 2 3\n-----THIS STUFF IS USELESS-----\nBLEH BLEH BLEH\nBLEH BLEH BLEH","expected_output":"Files:\nsomefiles.tar.gz 1 2 3\nsomefiles.tar.gz 1 2 3\n","validation_input":"Header\nData Line 1\nData Line 2\n-----THIS STUFF IS USELESS-----\nFooter 1\nFooter 2","validation_output":"Header\nData Line 1\nData Line 2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/14046878/using-sed-to-match-a-pattern-and-deleting-from-the-line-to-the-end-of-the-file","question_title":"Using sed to match a pattern and deleting from the line to the end of the file","question_owner":"Albert H","answer_owner":"shellter","answer_id":14046990,"question_score":26,"reviewed":true,"prediction":"sed '/-----THIS STUFF IS USELESS-----/d'","valid":true,"correct":false,"error":null}
|
| 5 |
+
{"id":"so-15632691","request":"Print only the first line of the input and then stop processing.","command":"sed -n '1{p;q}'","input_text":"Line 1\nLine 2\nLine 3","expected_output":"Line 1\n","validation_input":"First\nSecond\nThird\nFourth","validation_output":"First\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/15632691/fastest-way-to-print-a-single-line-in-a-file","question_title":"Fastest way to print a single line in a file","question_owner":"JBoy","answer_owner":"Chris Seymour","answer_id":15632780,"question_score":25,"reviewed":true,"prediction":"sed -n 1p","valid":true,"correct":true,"error":null}
|
| 6 |
+
{"id":"so-1617724","request":"Replace all newline characters with tab characters in the input stream.","command":"sed ':a;N;$!ba;s/\\n/\\t/g'","input_text":"hi\nhello\nhallo\ngreetings","expected_output":"hi\thello\thallo\tgreetings","validation_input":"salutations\nno more hello for you","validation_output":"salutations\tno more hello for you","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1617724/how-to-replace-newlines-with-tab-characters","question_title":"How to replace newlines with tab characters?","question_owner":"Vijay","answer_owner":"ghostdog74","answer_id":1617769,"question_score":24,"reviewed":true,"prediction":"sed 's/\\n/\\t/g'","valid":true,"correct":false,"error":null}
|
| 7 |
+
{"id":"so-16202900","request":"Remove spaces following commas only within lines 2 through 3 of the input.","command":"sed '2,3s/,\\s\\+/,/g'","input_text":"Line 1, with space\nLine 2, with space\nLine 3, with space\nLine 4, with space","expected_output":"Line 1, with space\nLine 2,with space\nLine 3,with space\nLine 4, with space","validation_input":"a, b\nb, c\nc, d\nd, e","validation_output":"a, b\nb,c\nc,d\nd, e","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16202900/using-sed-between-specific-lines-only","question_title":"Using sed between specific lines only","question_owner":"hackio","answer_owner":"anubhava","answer_id":16202932,"question_score":26,"reviewed":true,"prediction":"sed -e '/^2/,/3/{s/[ ,]*$//'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 0: unmatched `{'"}
|
| 8 |
+
{"id":"so-16576197","request":"Insert a newline between '</a>' and '<a><a>' in the input stream.","command":"sed 's#</a><a><a>#</a>\\\n<a><a>#g'","input_text":"</a><a><a>\nsome text </a><a><a> more text","expected_output":"</a>\n<a><a>\nsome text </a>\n<a><a> more text","validation_input":"prefix</a><a><a>suffix\n</a><a><a>","validation_output":"prefix</a>\n<a><a>suffix\n</a>\n<a><a>","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/16576197/how-to-add-new-line-using-sed-on-macos","question_title":"How to add new line using sed on MacOS?","question_owner":"codereviewanskquestions","answer_owner":"Kevin","answer_id":16576291,"question_score":26,"reviewed":true,"prediction":"sed '/<a><a>/a\\n'","valid":true,"correct":false,"error":null}
|
| 9 |
+
{"id":"so-18602234","request":"Remove the period and everything following it on each line.","command":"sed 's/\\..*$//'","input_text":"95 flour.\n47 water.s\netc..","expected_output":"95 flour\n47 water\netc","validation_input":"hello.world\ntest.case.end","validation_output":"hello\ntest","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18602234/sed-to-remove-everything-after-in-file-using-command","question_title":"Sed to remove everything after "." in file using * command?","question_owner":"Novice","answer_owner":"Adam Rosenfield","answer_id":18602273,"question_score":25,"reviewed":true,"prediction":"sed 's/[.]*$//'","valid":true,"correct":false,"error":null}
|
| 10 |
+
{"id":"so-20568515","request":"Replace the value of the variable VAR5 with VALUE10 in a configuration file content, keeping the key name intact.","command":"sed 's/^\\(VAR5=\\).*/\\1VALUE10/'","input_text":"VAR1=VALUE1\nVAR2=VALUE2\nVAR3=VALUE3\nVAR4=VALUE4\nVAR5=VALUE5\nVAR6=VALUE6","expected_output":"VAR1=VALUE1\nVAR2=VALUE2\nVAR3=VALUE3\nVAR4=VALUE4\nVAR5=VALUE10\nVAR6=VALUE6","validation_input":"KEY=OLD\nVAR5=SOMETHING\nOTHER=DATA","validation_output":"KEY=OLD\nVAR5=VALUE10\nOTHER=DATA","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20568515/how-to-use-sed-to-replace-a-config-files-variable","question_title":"How to use sed to replace a config file's variable?","question_owner":"SomeGuyOnAComputer","answer_owner":"anubhava","answer_id":20568559,"question_score":32,"reviewed":true,"prediction":"sed -i 's/VAR5=VALUE10/VAR5=VALUE10/'","valid":false,"correct":false,"error":"Unsupported sed option: -i"}
|
| 11 |
+
{"id":"so-22159044","request":"Append the string ' myalias' to the end of any line containing '192.168.1.2'.","command":"sed '/192.168.1.2/s/$/ myalias/'","input_text":"192.168.1.1 www.address1.com\n192.168.1.2 www.address2.com\n192.168.1.3 www.address3.com","expected_output":"192.168.1.1 www.address1.com\n192.168.1.2 www.address2.com myalias\n192.168.1.3 www.address3.com","validation_input":"10.0.0.1 host1\n192.168.1.2 host2\n10.0.0.3 host3","validation_output":"10.0.0.1 host1\n192.168.1.2 host2 myalias\n10.0.0.3 host3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/22159044/how-to-append-a-string-at-end-of-a-specific-line-in-a-file-in-bash","question_title":"How to append a string at end of a specific line in a file in bash","question_owner":"Chris F","answer_owner":"Steve","answer_id":22159086,"question_score":30,"reviewed":true,"prediction":"sed '/192.168.1.2/a myalias'","valid":true,"correct":false,"error":null}
|
| 12 |
+
{"id":"so-22939323","request":"Replace sequences of two or more spaces with a single space in the input text.","command":"sed -e 's/ */ /g'","input_text":"iiHi Hello Hi\nthis is loga","expected_output":"iiHi Hello Hi\nthis is loga","validation_input":"a b c d\ne f","validation_output":"a b c d\ne f","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/22939323/sed-command-to-replace-multiple-spaces-into-single-spaces","question_title":"sed command to replace multiple spaces into single spaces","question_owner":"logan","answer_owner":"John Zwinck","answer_id":22939416,"question_score":25,"reviewed":true,"prediction":"sed 's/[ \\{2,\\}]*\\ / /g'","valid":true,"correct":true,"error":null}
|
| 13 |
+
{"id":"so-24427009","request":"Extract the last three characters from every line of the input.","command":"sed -e 's/^.*\\(...\\)$/\\1/'","input_text":"hello\nworld\nabcdef","expected_output":"llo\nrld\ndef","validation_input":"short\nlonger string\nxyz","validation_output":"ort\ning\nxyz","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24427009/is-there-a-cleaner-way-of-getting-the-last-n-characters-of-every-line","question_title":"Is there a cleaner way of getting the last N characters of every line?","question_owner":"merlin2011","answer_owner":"Tiago Lopo","answer_id":24427087,"question_score":32,"reviewed":true,"prediction":"sed 's/^\\(.\\{3\\}\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 14 |
+
{"id":"so-25491847","request":"Extract only the second word from each line of text.","command":"sed -n 's/^[[:space:]]*[^[:space:]]*[[:space:]]\\+\\([^[:space:]]*\\).*/\\1/p'","input_text":"* CRISTOBAL AL042014 08/05/14 12 UTC *\nthis is a test","expected_output":"CRISTOBAL\nis","validation_input":" hello world foo\none two","validation_output":"world\ntwo","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25491847/extract-the-second-word-in-a-line-from-a-text-file","question_title":"Extract The Second Word In A Line From A Text File","question_owner":"Aaron Perry","answer_owner":"zedfoxus","answer_id":25491964,"question_score":32,"reviewed":true,"prediction":"sed 's/^[^ ]*\\([^ ]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 15 |
+
{"id":"so-28795479","request":"Convert camelCase text to underscore_case by inserting an underscore before uppercase letters and lowercasing them.","command":"sed 's/\\([a-z0-9]\\)\\([A-Z]\\)/\\1_\\2/g; s/.*/\\L&/'","input_text":"fooBar\nmyVariableName\nsimpleTest","expected_output":"foo_bar\nmy_variable_name\nsimple_test","validation_input":"getUserName\nparseXMLData","validation_output":"get_user_name\nparse_xmldata","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28795479/awk-sed-script-to-convert-a-file-from-camelcase-to-underscores","question_title":"Awk/sed script to convert a file from camelCase to underscores","question_owner":"Corentin Peuvrel","answer_owner":"Avinash Raj","answer_id":28795550,"question_score":25,"reviewed":true,"prediction":"sed 's/\\(.\\{2\\}\\)\\([a-z]\\)/_\\1_\\2/g'","valid":true,"correct":false,"error":null}
|
| 16 |
+
{"id":"so-31903432","request":"Replace all tab characters with four spaces in the input text.","command":"sed 's/\\t/ /g'","input_text":"col1\tcol2\tcol3\nval1\tval2\tval3","expected_output":"col1 col2 col3\nval1 val2 val3","validation_input":"a\tb\n\tc","validation_output":"a b\n c","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31903432/using-sed-to-replace-tab-with-spaces","question_title":"Using sed to replace tab with spaces","question_owner":"manshuai","answer_owner":"anubhava","answer_id":31903444,"question_score":28,"reviewed":true,"prediction":"sed 's/\\t/ /g'","valid":true,"correct":true,"error":null}
|
| 17 |
+
{"id":"so-31911179","request":"Delete the first line of the input stream.","command":"sed '1d'","input_text":"Header\nLine1\nLine2","expected_output":"Line1\nLine2","validation_input":"Title\nData A\nData B","validation_output":"Data A\nData B","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31911179/ignoring-first-line-column-header-while-reading-a-file-in-bash","question_title":"Ignoring First line/Column header while reading a file in bash","question_owner":"Jai","answer_owner":"chepner","answer_id":31911198,"question_score":28,"reviewed":true,"prediction":"sed '$d'","valid":true,"correct":false,"error":null}
|
| 18 |
+
{"id":"so-3194534","request":"Join every pair of consecutive lines by appending the second line to the first, effectively merging line 2 into line 1, line 4 into line 3, and so on.","command":"sed '$!N;s/\\n//'","input_text":"abcd\njoinabcd\nefgh\njoinefgh\nijkl\njoinijkl","expected_output":"abcdjoinabcd\nefghjoinefgh\nijkljoinijkl","validation_input":"line1\nline2\nline3\nline4","validation_output":"line1line2\nline3line4","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3194534/joining-two-consecutive-lines-using-awk-or-sed","question_title":"Joining two consecutive lines using awk or sed","question_owner":"Vijay","answer_owner":"Dimitre Radoulov","answer_id":3196948,"question_score":26,"reviewed":true,"prediction":"sed 's/\\([^ ]*\\) \\([^ ]*\\)/\\1\\2/'","valid":true,"correct":false,"error":null}
|
| 19 |
+
{"id":"so-3302434","request":"Remove the substring 'ko:' from each line, keeping the rest of the text intact.","command":"sed 's/ko://'","input_text":"ko04062 ko:CXCR3\nko04062 ko:CX3CR1\nko04062 ko:CCL3","expected_output":"ko04062 CXCR3\nko04062 CX3CR1\nko04062 CCL3","validation_input":"ko04080 ko:GZMA\nko05414 ko:ITGA4","validation_output":"ko04080 GZMA\nko05414 ITGA4","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3302434/capturing-groups-in-sed","question_title":"capturing groups in sed","question_owner":"Mike Dewar","answer_owner":"ninjalj","answer_id":3302593,"question_score":25,"reviewed":true,"prediction":"sed 's/ko:.*//'","valid":true,"correct":false,"error":null}
|
| 20 |
+
{"id":"so-34576667","request":"Replace the text 'Foo' with 'Bar' in the input stream.","command":"sed -e 's/Foo/Bar/'","input_text":"Foo","expected_output":"Bar","validation_input":"Hello Foo World","validation_output":"Hello Bar World","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34576667/sed-unescaped-newline-inside-substitute-pattern","question_title":"sed: unescaped newline inside substitute pattern?","question_owner":"RocketNuts","answer_owner":"anubhava","answer_id":34576684,"question_score":30,"reviewed":true,"prediction":"sed s/Foo/Bar/g","valid":true,"correct":true,"error":null}
|
| 21 |
+
{"id":"so-3576139","request":"Remove the string 'line number' only if it appears in the last line of the input.","command":"sed '$ s/line number//g'","input_text":"first line number\nsecond line number\nlast line number","expected_output":"first line number\nsecond line number\nlast ","validation_input":"keep line number\nremove line number","validation_output":"keep line number\nremove ","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/3576139/sed-remove-string-only-in-the-last-line-of-the-file","question_title":"sed + remove string only in the last line of the file","question_owner":"lidia","answer_owner":"Scharron","answer_id":3576183,"question_score":31,"reviewed":true,"prediction":"sed -n '$p' | grep -oP '\\bline number\\b' | sed '/line number/d'","valid":false,"correct":false,"error":"Pipes and shell control operators are not allowed."}
|
| 22 |
+
{"id":"so-39198780","request":"Replace all newline characters with a single space in the input stream.","command":"sed ':a;N;$!ba;s/\\n/ /g'","input_text":"my\nname\nis\nxxxx","expected_output":"my name is xxxx","validation_input":"hello\nworld","validation_output":"hello world","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39198780/replace-nnew-line-with-space-in-bash","question_title":"Replace \\n(new line) with space in bash","question_owner":"Prometheus","answer_owner":"Cyrus","answer_id":39198829,"question_score":24,"reviewed":true,"prediction":"sed 's/\\n/ /g'","valid":true,"correct":false,"error":null}
|
| 23 |
+
{"id":"so-39648222","request":"Convert a multi-line text stream into a single line by replacing all newline characters with spaces, effectively joining the lines.","command":"sed ':a;N;$!ba;s/\\n/ /g'","input_text":"{\n\"key\": \"value\"\n}","expected_output":"{ \"key\": \"value\" }","validation_input":"Line 1\nLine 2\nLine 3","validation_output":"Line 1 Line 2 Line 3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39648222/converting-json-pretty-print-to-one-line","question_title":"Converting JSON pretty print to one line","question_owner":"h.b","answer_owner":"P....","answer_id":39653559,"question_score":29,"reviewed":true,"prediction":"sed 's/\\n / /g'","valid":true,"correct":false,"error":null}
|
| 24 |
+
{"id":"so-40506782","request":"Remove all characters from the beginning of each line up to and including the first occurrence of the digit '2'.","command":"sed 's/^[^2]*2//'","input_text":"ananas1kiwi2apple1banana2tree\nhello2world\ntest","expected_output":"apple1banana2tree\nworld\ntest","validation_input":"abc2def2ghi\nno_match_here\n123","validation_output":"def2ghi\nno_match_here\n3","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40506782/delete-everyting-preceding-and-including-a-certain-substring-from-variable","question_title":"Delete everyting preceding and including a certain substring from variable","question_owner":"Anne K.","answer_owner":"heemayl","answer_id":40506863,"question_score":27,"reviewed":true,"prediction":"sed 's/^[0-9][0-9]*//'","valid":true,"correct":false,"error":null}
|
| 25 |
+
{"id":"so-5024357","request":"Read lines from standard input and print them until a line containing the exact string 'EOF' is encountered. The line containing 'EOF' should also be printed, and then the program should stop processing further input.","command":"sed '/EOF/q'","input_text":"Line 1\nLine 2\nThis is EOF\nLine 4","expected_output":"Line 1\nLine 2\nThis is EOF\n","validation_input":"Start\nMiddle\nEnd with EOF marker\nIgnored line","validation_output":"Start\nMiddle\nEnd with EOF marker\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5024357/do-a-tail-f-until-matching-a-pattern","question_title":"Do a tail -F until matching a pattern","question_owner":"Sam Alba","answer_owner":"jpetazzo","answer_id":5033775,"question_score":27,"reviewed":true,"prediction":"sed -n /EOF/p","valid":true,"correct":false,"error":null}
|
| 26 |
+
{"id":"so-5544322","request":"Extract and clean the value from lines starting with 'Important1: ', removing the prefix and surrounding whitespace, while suppressing all other lines.","command":"sed -n 's/^Important1: *\\([^ ]*\\) */\\1/p'","input_text":"Bla\nBla\nImportant1: One \nBla\nImportant2: Two\nBla\nBla","expected_output":"One\n","validation_input":"Ignore this\nImportant1: Value \nIgnore that\nImportant1: Another","validation_output":"Value\nAnother","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/5544322/sed-get-only-the-replaced-string-from-a-multiline-input-omit-unmatched-lines","question_title":"sed - Get only the replaced string from a multiline input & omit unmatched lines!","question_owner":"porg","answer_owner":"anubhava","answer_id":5544539,"question_score":26,"reviewed":true,"prediction":"sed -n 's/^Important1: //; s/[ \\t]*$//'","valid":true,"correct":false,"error":null}
|
| 27 |
+
{"id":"so-6006132","request":"Print only the lines that do not end with the string 'abcd'.","command":"sed -n '/abcd$/!p'","input_text":"this is abcd\nthis is not\nanother abcd\nend","expected_output":"this is not\nend","validation_input":"xyzabcd\nkeep this line\nfoo bar abcd\nretain","validation_output":"keep this line\nretain","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6006132/grep-line-of-text-that-does-not-end-with-abcd","question_title":"Grep. Line of text that does not end with "abcd"?","question_owner":"CCC","answer_owner":"tobyodavies","answer_id":6006139,"question_score":27,"reviewed":true,"prediction":"sed -n /[^$]abcd.*$/p","valid":true,"correct":false,"error":null}
|
| 28 |
+
{"id":"so-6011661","request":"Extract the two-digit number surrounded by identical non-digit characters from each line. If a line does not match this pattern, produce no output for that line.","command":"sed -n 's/^.*\\(.\\)\\([0-9][0-9]\\)\\1.*$/\\2/p'","input_text":"plop-02-plop\nabcX99Xdef\nno-match-here\nz55z","expected_output":"02\n99\n55","validation_input":"testA12Aend\nfailB1C\nok_77_","validation_output":"12\n77","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6011661/regexp-sed-suppress-no-match-output","question_title":"regexp (sed) suppress "no match" output","question_owner":"yPhil","answer_owner":"przemoc","answer_id":6011704,"question_score":28,"reviewed":true,"prediction":"sed -n 's/[^0-9][^0-9]*\\1\\b.*\\1\\b/p'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 27: unterminated `s' command"}
|
| 29 |
+
{"id":"so-6869449","request":"Delete lines matching the regex '^Name' but skip the first line of the input.","command":"sed -e '2,${ /^Name/d }'","input_text":"Name\nJohn\nAlbert\nMora\nName\nTommy\nTammy","expected_output":"Name\nJohn\nAlbert\nMora\nTommy\nTammy","validation_input":"Header\nData1\nHeader\nData2\nFooter","validation_output":"Header\nData1\nHeader\nData2\nFooter","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/6869449/skipping-the-first-n-lines-when-using-regex-with-sed","question_title":"Skipping the first n lines when using regex with sed?","question_owner":"Legend","answer_owner":"a'r","answer_id":6869486,"question_score":26,"reviewed":true,"prediction":"sed '/^Name/c//'","valid":true,"correct":false,"error":null}
|
| 30 |
+
{"id":"so-689495","request":"Convert the uppercase letter immediately following an underscore in identifiers starting with 'get' to lowercase.","command":"sed -e 's/\\(get[A-Z][A-Za-z0-9]*_\\)\\([A-Z]\\)/\\1\\L\\2/g'","input_text":"getFoo_Bar\ngetBaz_Qux","expected_output":"getFoo_bar\ngetBaz_qux","validation_input":"getX_Y\ngetAb_Cd_Ef","validation_output":"getX_y\ngetAb_cd_Ef","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/689495/upper-to-lower-case-using-sed","question_title":"upper- to lower-case using sed","question_owner":"cadrian","answer_owner":"strager","answer_id":689608,"question_score":25,"reviewed":true,"prediction":"sed 's/_([A-Z])/\\L\\1/g'","valid":false,"correct":false,"error":"/usr/bin/sed: -e expression #1, char 17: invalid reference \\1 on `s' command's RHS"}
|
| 31 |
+
{"id":"so-8225822","request":"Replace all occurrences of 'A' with 'a' and only print lines where a substitution was made.","command":"sed -n 's/A/a/gp'","input_text":"Apple\nBanana\nAvocado","expected_output":"apple\navocado","validation_input":"ABC\nXYZ\nA123","validation_output":"aBC\na123","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8225822/how-to-make-sed-remove-lines-not-matched-by-a-substitution","question_title":"How to make sed remove lines not matched by a substitution","question_owner":"Ropez","answer_owner":"jaypal singh","answer_id":8255627,"question_score":28,"reviewed":true,"prediction":"sed 's/A/a/g'","valid":true,"correct":false,"error":null}
|
| 32 |
+
{"id":"so-8356958","request":"Remove the prefix 'foo: ' from the beginning of each line in the input text.","command":"sed 's/^foo: //'","input_text":"foo: bar1\nfoo: bar2\nfoo: bar3","expected_output":"bar1\nbar2\nbar3","validation_input":"foo: hello world\nfoo: test case\nno match here","validation_output":"hello world\ntest case\nno match here","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8356958/sed-just-trying-to-remove-a-substring","question_title":"sed: just trying to remove a substring","question_owner":"user1077220","answer_owner":"aefxx","answer_id":8356980,"question_score":28,"reviewed":true,"prediction":"sed 's/^foo:\\([^ ]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 33 |
+
{"id":"so-8394066","request":"Insert a line containing two words separated by a tab character at the beginning of the input.","command":"sed '1i\\\nword1\tword2'","input_text":"Existing line 1\nExisting line 2","expected_output":"word1\tword2\nExisting line 1\nExisting line 2","validation_input":"Data start","validation_output":"word1\tword2\nData start","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8394066/what-is-the-proper-way-to-insert-tab-in-sed","question_title":"What is the proper way to insert tab in sed?","question_owner":"dabest1","answer_owner":"Jonathan Leffler","answer_id":8394150,"question_score":33,"reviewed":true,"prediction":"sed '1i\\tsed\\t'","valid":true,"correct":false,"error":null}
|
| 34 |
+
{"id":"so-8991275","request":"Replace the character 'b' with a newline in the input stream.","command":"sed 's/b/\\\n/'","input_text":"abc","expected_output":"a\nc","validation_input":"xbx","validation_output":"x\nx","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/8991275/escaping-newlines-in-sed-replacement-string","question_title":"escaping newlines in sed replacement string","question_owner":"spraff","answer_owner":"jaypal singh","answer_id":8991356,"question_score":29,"reviewed":true,"prediction":"sed 's/b/\\n/g'","valid":true,"correct":true,"error":null}
|
| 35 |
+
{"id":"so-9191030","request":"Remove all occurrences of the substring 'ABC' from the end of each line.","command":"sed 's/\\(ABC\\)*$//'","input_text":"DAAAAABCBBBCCABCABC\nHelloABC\nWorld","expected_output":"DAAAAABCBBBCC\nHello\nWorld","validation_input":"TestABCABC\nNoChange\nEndABC","validation_output":"Test\nNoChange\nEnd","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9191030/removing-pattern-at-the-end-of-a-string-using-sed-or-other-bash-tools","question_title":"Removing pattern at the end of a string using sed or other bash tools","question_owner":"Kay Chan","answer_owner":"Birei","answer_id":9191062,"question_score":30,"reviewed":true,"prediction":"sed '$s/ABC*$//'","valid":true,"correct":false,"error":null}
|
| 36 |
+
{"id":"so-9260625","request":"Extract the first sequence of digits from each line of input text.","command":"sed -n 's/^[^0-9]*\\([0-9][0-9]*\\).*/\\1/p'","input_text":"This is an example: 65 apples\nThere are 123 items here","expected_output":"65\n123","validation_input":"No numbers in this line\nValue is 42 and count is 7","validation_output":"42","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9260625/sed-extracting-group-of-digits","question_title":"sed extracting group of digits","question_owner":"Uthman","answer_owner":"codaddict","answer_id":9260734,"question_score":24,"reviewed":true,"prediction":"sed 's/[^0-9]*\\([0-9][0-9]*\\).*/\\1/'","valid":true,"correct":false,"error":null}
|
| 37 |
+
{"id":"so-9970124","request":"Insert the line 'New Inserted Line' immediately after the first occurrence of 'Matched Keyword', before any remaining text on that line.","command":"sed '0,/Matched Keyword/s//Matched Keyword\\nNew Inserted Line/'","input_text":"Line 1\nLine 2\nThis line contains the Matched Keyword and other stuff\nLine 4\nThis line contains the Matched Keyword and other stuff\nLine 6","expected_output":"Line 1\nLine 2\nThis line contains the Matched Keyword\nNew Inserted Line and other stuff\nLine 4\nThis line contains the Matched Keyword and other stuff\nLine 6","validation_input":"Start\nMiddle Matched Keyword End\nEnd Matched Keyword Start\nFinish","validation_output":"Start\nMiddle Matched Keyword\nNew Inserted Line End\nEnd Matched Keyword Start\nFinish","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/9970124/sed-to-insert-on-first-match-only","question_title":"sed to insert on first match only","question_owner":"SSS","answer_owner":"Squazic","answer_id":9970467,"question_score":26,"reviewed":true,"prediction":"sed '/Matched Keyword/i New Inserted Line'","valid":true,"correct":false,"error":null}
|
evaluation/v2-test.summary.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "/outputs/aae244b1-b1ab-4dbd-a1e3-815e9d722ec7/training/model",
|
| 3 |
+
"split": "test",
|
| 4 |
+
"rows": 37,
|
| 5 |
+
"valid_at_1": 0.8378378378378378,
|
| 6 |
+
"correct_at_1": 0.1891891891891892,
|
| 7 |
+
"exact_output_on_two_inputs": true,
|
| 8 |
+
"prediction_cleanup": "special tokens only",
|
| 9 |
+
"seconds": 14.307973384857178,
|
| 10 |
+
"data_sha256": "9351a02c467b606e9c16ca2b2fcef7309850a4edfd3b539e9adc192ac766b555",
|
| 11 |
+
"transformers_version": "5.17.0",
|
| 12 |
+
"torch_version": "2.14.0",
|
| 13 |
+
"families": {
|
| 14 |
+
"real-stackoverflow": {
|
| 15 |
+
"rows": 37,
|
| 16 |
+
"valid": 31,
|
| 17 |
+
"correct": 7
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
fetch_real_questions.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
import time
|
| 6 |
+
import urllib.parse
|
| 7 |
+
import urllib.request
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
API_ROOT = "https://api.stackexchange.com/2.3"
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def get_json(path: str, **params) -> dict:
|
| 14 |
+
query = urllib.parse.urlencode({"site": "stackoverflow", "filter": "withbody", **params})
|
| 15 |
+
request = urllib.request.Request(
|
| 16 |
+
f"{API_ROOT}/{path}?{query}",
|
| 17 |
+
headers={"User-Agent": "Asterbraid-Sedweave-Dataset/1.0"},
|
| 18 |
+
)
|
| 19 |
+
with urllib.request.urlopen(request, timeout=60) as response:
|
| 20 |
+
data = json.load(response)
|
| 21 |
+
if "error_message" in data:
|
| 22 |
+
raise RuntimeError(data["error_message"])
|
| 23 |
+
if data.get("backoff"):
|
| 24 |
+
time.sleep(data["backoff"])
|
| 25 |
+
return data
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def main() -> None:
|
| 29 |
+
parser = argparse.ArgumentParser()
|
| 30 |
+
parser.add_argument("--output-dir", type=Path, default=Path(".tmp"))
|
| 31 |
+
parser.add_argument("--pages", type=int, default=1)
|
| 32 |
+
args = parser.parse_args()
|
| 33 |
+
args.output_dir.mkdir(parents=True, exist_ok=True)
|
| 34 |
+
|
| 35 |
+
questions = []
|
| 36 |
+
for page in range(1, args.pages + 1):
|
| 37 |
+
data = get_json("questions", order="desc", sort="votes", tagged="sed", pagesize=100, page=page)
|
| 38 |
+
questions.extend(data["items"])
|
| 39 |
+
if not data.get("has_more"):
|
| 40 |
+
break
|
| 41 |
+
(args.output_dir / "sed-questions.json").write_text(json.dumps({"items": questions}, indent=2), encoding="utf-8")
|
| 42 |
+
|
| 43 |
+
answer_ids = [str(question["accepted_answer_id"]) for question in questions if "accepted_answer_id" in question]
|
| 44 |
+
answers = {}
|
| 45 |
+
for start in range(0, len(answer_ids), 100):
|
| 46 |
+
batch = answer_ids[start:start + 100]
|
| 47 |
+
data = get_json("answers/" + ";".join(batch), order="desc", sort="activity", pagesize=100)
|
| 48 |
+
for answer in data["items"]:
|
| 49 |
+
answers[str(answer["answer_id"])] = answer
|
| 50 |
+
(args.output_dir / "sed-answers.json").write_text(json.dumps(answers, indent=2), encoding="utf-8")
|
| 51 |
+
print(f"saved {len(questions)} questions and {len(answers)} accepted answers")
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
main()
|
paraphrase_real_data.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import concurrent.futures
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
import re
|
| 8 |
+
import time
|
| 9 |
+
import urllib.request
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
MODEL = "qwen/qwen3.7-plus"
|
| 13 |
+
NUMBER_PATTERN = re.compile(r"(?<![A-Za-z_])\d+(?:\.\d+)?(?![A-Za-z_])")
|
| 14 |
+
QUOTED_PATTERN = re.compile(r"'([^']+)'|\"([^\"]+)\"|`([^`]+)`")
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def number_aliases(number: int) -> set[str]:
|
| 18 |
+
units = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
|
| 19 |
+
teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
|
| 20 |
+
tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
|
| 21 |
+
if number < 10:
|
| 22 |
+
words = units[number]
|
| 23 |
+
elif number < 20:
|
| 24 |
+
words = teens[number - 10]
|
| 25 |
+
elif number < 100:
|
| 26 |
+
words = tens[number // 10] + ("-" + units[number % 10] if number % 10 else "")
|
| 27 |
+
else:
|
| 28 |
+
words = str(number)
|
| 29 |
+
ordinals = {
|
| 30 |
+
0: "zeroth", 1: "first", 2: "second", 3: "third", 4: "fourth", 5: "fifth",
|
| 31 |
+
6: "sixth", 7: "seventh", 8: "eighth", 9: "ninth", 10: "tenth", 11: "eleventh",
|
| 32 |
+
12: "twelfth", 13: "thirteenth", 14: "fourteenth", 15: "fifteenth", 16: "sixteenth",
|
| 33 |
+
17: "seventeenth", 18: "eighteenth", 19: "nineteenth", 20: "twentieth", 30: "thirtieth",
|
| 34 |
+
40: "fortieth", 50: "fiftieth", 60: "sixtieth", 70: "seventieth", 80: "eightieth", 90: "ninetieth",
|
| 35 |
+
}
|
| 36 |
+
ordinal = ordinals.get(number, str(number))
|
| 37 |
+
return {str(number), words, words.replace("-", " "), ordinal, ordinal.replace("-", " ")}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def valid_paraphrase(original: str, paraphrase: str) -> bool:
|
| 41 |
+
paraphrase = paraphrase.strip()
|
| 42 |
+
if not 10 <= len(paraphrase) <= 500 or paraphrase == original.strip():
|
| 43 |
+
return False
|
| 44 |
+
if "\n" in paraphrase or "```" in paraphrase:
|
| 45 |
+
return False
|
| 46 |
+
lowered = paraphrase.lower()
|
| 47 |
+
for value in set(NUMBER_PATTERN.findall(original)):
|
| 48 |
+
aliases = number_aliases(int(value)) if value.isdigit() else {value}
|
| 49 |
+
if not any(re.search(r"(?<![a-z0-9])" + re.escape(alias) + r"(?![a-z0-9])", lowered) for alias in aliases):
|
| 50 |
+
return False
|
| 51 |
+
for groups in QUOTED_PATTERN.findall(original):
|
| 52 |
+
literal = next(value for value in groups if value)
|
| 53 |
+
if literal not in paraphrase:
|
| 54 |
+
return False
|
| 55 |
+
return True
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def request_batch(batch: list[dict]) -> list[str]:
|
| 59 |
+
payload = {
|
| 60 |
+
"model": MODEL,
|
| 61 |
+
"messages": [
|
| 62 |
+
{
|
| 63 |
+
"role": "system",
|
| 64 |
+
"content": (
|
| 65 |
+
"Paraphrase technical text-processing requests. Return only valid JSON. Preserve the exact operation, "
|
| 66 |
+
"every number, literal string, pattern, position, separator, output format, ordering, and constraint. "
|
| 67 |
+
"Keep all quoted literals unchanged. Do not add or remove requirements. Keep each request concise and "
|
| 68 |
+
"natural, and vary sentence structure."
|
| 69 |
+
),
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"role": "user",
|
| 73 |
+
"content": "Return {\"paraphrases\": [...]} with exactly one paraphrase per numbered input, in order.\n"
|
| 74 |
+
+ "\n".join(f"{index}. {row['request']}" for index, row in enumerate(batch, 1)),
|
| 75 |
+
},
|
| 76 |
+
],
|
| 77 |
+
"response_format": {"type": "json_object"},
|
| 78 |
+
"temperature": 0.8,
|
| 79 |
+
"max_tokens": 4000,
|
| 80 |
+
"reasoning": {"enabled": False},
|
| 81 |
+
}
|
| 82 |
+
request = urllib.request.Request(
|
| 83 |
+
os.environ["OPENROUTER_BASE_URL"].rstrip("/") + "/chat/completions",
|
| 84 |
+
data=json.dumps(payload).encode("utf-8"),
|
| 85 |
+
headers={"Authorization": "Bearer " + os.environ["OPENROUTER_API_KEY"], "Content-Type": "application/json"},
|
| 86 |
+
)
|
| 87 |
+
for attempt in range(4):
|
| 88 |
+
try:
|
| 89 |
+
with urllib.request.urlopen(request, timeout=180) as response:
|
| 90 |
+
data = json.load(response)
|
| 91 |
+
values = json.loads(data["choices"][0]["message"]["content"])["paraphrases"]
|
| 92 |
+
if not isinstance(values, list) or len(values) != len(batch):
|
| 93 |
+
raise ValueError("Wrong paraphrase count")
|
| 94 |
+
return [str(value).strip() for value in values]
|
| 95 |
+
except Exception:
|
| 96 |
+
if attempt == 3:
|
| 97 |
+
raise
|
| 98 |
+
time.sleep(2 ** attempt)
|
| 99 |
+
raise AssertionError("unreachable")
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def main() -> None:
|
| 103 |
+
parser = argparse.ArgumentParser()
|
| 104 |
+
parser.add_argument("input", type=Path)
|
| 105 |
+
parser.add_argument("output", type=Path)
|
| 106 |
+
args = parser.parse_args()
|
| 107 |
+
rows = [json.loads(line) for line in args.input.open(encoding="utf-8")]
|
| 108 |
+
if any(row["split"] != "train" for row in rows):
|
| 109 |
+
raise ValueError("Paraphrases are allowed only for training rows")
|
| 110 |
+
batches = [rows[index:index + 12] for index in range(0, len(rows), 12)]
|
| 111 |
+
paraphrases = []
|
| 112 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
|
| 113 |
+
futures = {executor.submit(request_batch, batch): batch for batch in batches}
|
| 114 |
+
for future in concurrent.futures.as_completed(futures):
|
| 115 |
+
batch = futures[future]
|
| 116 |
+
try:
|
| 117 |
+
values = future.result()
|
| 118 |
+
except Exception as error:
|
| 119 |
+
print("batch failed", error, flush=True)
|
| 120 |
+
continue
|
| 121 |
+
for row, value in zip(batch, values):
|
| 122 |
+
if not valid_paraphrase(row["request"], value):
|
| 123 |
+
continue
|
| 124 |
+
new_row = dict(row)
|
| 125 |
+
new_row["id"] = row["id"] + "-p1"
|
| 126 |
+
new_row["paraphrase_of"] = row["id"]
|
| 127 |
+
new_row["request"] = value
|
| 128 |
+
new_row["source"] = "openrouter-paraphrase"
|
| 129 |
+
new_row["paraphrase_model"] = MODEL
|
| 130 |
+
paraphrases.append(new_row)
|
| 131 |
+
output = rows + paraphrases
|
| 132 |
+
output.sort(key=lambda row: row["id"])
|
| 133 |
+
with args.output.open("w", encoding="utf-8") as handle:
|
| 134 |
+
for row in output:
|
| 135 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 136 |
+
print(f"wrote {len(rows)} originals and {len(paraphrases)} guarded paraphrases")
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
if __name__ == "__main__":
|
| 140 |
+
main()
|
prepare_real_splits.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def main() -> None:
|
| 9 |
+
parser = argparse.ArgumentParser()
|
| 10 |
+
parser.add_argument("--questions", type=Path, required=True)
|
| 11 |
+
parser.add_argument("--output-dir", type=Path, required=True)
|
| 12 |
+
parser.add_argument("--manifest", type=Path, required=True)
|
| 13 |
+
args = parser.parse_args()
|
| 14 |
+
questions = json.loads(args.questions.read_text(encoding="utf-8"))["items"]
|
| 15 |
+
if len(questions) != 400:
|
| 16 |
+
raise ValueError("Expected exactly 400 ranked questions")
|
| 17 |
+
groups = {
|
| 18 |
+
"excluded_initial_benchmark": questions[:100],
|
| 19 |
+
"train_candidates": questions[100:300],
|
| 20 |
+
"frozen_test_candidates": questions[300:400],
|
| 21 |
+
}
|
| 22 |
+
args.output_dir.mkdir(parents=True, exist_ok=True)
|
| 23 |
+
manifest = {}
|
| 24 |
+
for name, items in groups.items():
|
| 25 |
+
if name != "excluded_initial_benchmark":
|
| 26 |
+
(args.output_dir / f"{name}.json").write_text(json.dumps({"items": items}, indent=2), encoding="utf-8")
|
| 27 |
+
manifest[name] = {
|
| 28 |
+
"ranks": [questions.index(items[0]) + 1, questions.index(items[-1]) + 1],
|
| 29 |
+
"question_ids": [item["question_id"] for item in items],
|
| 30 |
+
}
|
| 31 |
+
all_ids = [item["question_id"] for items in groups.values() for item in items]
|
| 32 |
+
if len(all_ids) != len(set(all_ids)):
|
| 33 |
+
raise ValueError("Duplicate question IDs across source splits")
|
| 34 |
+
args.manifest.write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
| 35 |
+
print(json.dumps({name: len(items) for name, items in groups.items()}, indent=2))
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
main()
|
real-source-splits.json
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"excluded_initial_benchmark": {
|
| 3 |
+
"ranks": [
|
| 4 |
+
1,
|
| 5 |
+
100
|
| 6 |
+
],
|
| 7 |
+
"question_ids": [
|
| 8 |
+
5410757,
|
| 9 |
+
1251999,
|
| 10 |
+
1583219,
|
| 11 |
+
6022384,
|
| 12 |
+
339483,
|
| 13 |
+
44656515,
|
| 14 |
+
5171901,
|
| 15 |
+
1632113,
|
| 16 |
+
12696125,
|
| 17 |
+
16414410,
|
| 18 |
+
1103149,
|
| 19 |
+
9733338,
|
| 20 |
+
4247068,
|
| 21 |
+
11245144,
|
| 22 |
+
407523,
|
| 23 |
+
2777579,
|
| 24 |
+
15559359,
|
| 25 |
+
2112469,
|
| 26 |
+
19456518,
|
| 27 |
+
36989457,
|
| 28 |
+
10748453,
|
| 29 |
+
9533679,
|
| 30 |
+
5694228,
|
| 31 |
+
148451,
|
| 32 |
+
26568952,
|
| 33 |
+
584894,
|
| 34 |
+
6758963,
|
| 35 |
+
10445934,
|
| 36 |
+
15580144,
|
| 37 |
+
366980,
|
| 38 |
+
19242275,
|
| 39 |
+
8206280,
|
| 40 |
+
7573368,
|
| 41 |
+
7451423,
|
| 42 |
+
1429556,
|
| 43 |
+
3557037,
|
| 44 |
+
48492422,
|
| 45 |
+
9366816,
|
| 46 |
+
8822097,
|
| 47 |
+
6537490,
|
| 48 |
+
9605232,
|
| 49 |
+
13242469,
|
| 50 |
+
11145270,
|
| 51 |
+
35154684,
|
| 52 |
+
1444406,
|
| 53 |
+
4569825,
|
| 54 |
+
3134791,
|
| 55 |
+
4366533,
|
| 56 |
+
13380607,
|
| 57 |
+
17511639,
|
| 58 |
+
127318,
|
| 59 |
+
16790793,
|
| 60 |
+
15849119,
|
| 61 |
+
16745988,
|
| 62 |
+
1654021,
|
| 63 |
+
27787536,
|
| 64 |
+
11469989,
|
| 65 |
+
4396974,
|
| 66 |
+
17988756,
|
| 67 |
+
2869669,
|
| 68 |
+
15978504,
|
| 69 |
+
905144,
|
| 70 |
+
4198138,
|
| 71 |
+
16637799,
|
| 72 |
+
1032023,
|
| 73 |
+
7727640,
|
| 74 |
+
538664,
|
| 75 |
+
4438306,
|
| 76 |
+
24509214,
|
| 77 |
+
3306007,
|
| 78 |
+
723157,
|
| 79 |
+
6250698,
|
| 80 |
+
1665549,
|
| 81 |
+
13055889,
|
| 82 |
+
4652652,
|
| 83 |
+
2610115,
|
| 84 |
+
11568859,
|
| 85 |
+
4412945,
|
| 86 |
+
5227295,
|
| 87 |
+
13181725,
|
| 88 |
+
2372719,
|
| 89 |
+
9953448,
|
| 90 |
+
5080988,
|
| 91 |
+
7517632,
|
| 92 |
+
6287755,
|
| 93 |
+
18439528,
|
| 94 |
+
12833714,
|
| 95 |
+
30003570,
|
| 96 |
+
38972736,
|
| 97 |
+
8786634,
|
| 98 |
+
20348097,
|
| 99 |
+
15758814,
|
| 100 |
+
1706431,
|
| 101 |
+
38672680,
|
| 102 |
+
14671293,
|
| 103 |
+
4793892,
|
| 104 |
+
1169927,
|
| 105 |
+
12101440,
|
| 106 |
+
4078933,
|
| 107 |
+
10986794
|
| 108 |
+
]
|
| 109 |
+
},
|
| 110 |
+
"train_candidates": {
|
| 111 |
+
"ranks": [
|
| 112 |
+
101,
|
| 113 |
+
300
|
| 114 |
+
],
|
| 115 |
+
"question_ids": [
|
| 116 |
+
22497246,
|
| 117 |
+
11694980,
|
| 118 |
+
1733692,
|
| 119 |
+
3795512,
|
| 120 |
+
27305177,
|
| 121 |
+
6711567,
|
| 122 |
+
12061410,
|
| 123 |
+
46082397,
|
| 124 |
+
9591744,
|
| 125 |
+
17998763,
|
| 126 |
+
16675179,
|
| 127 |
+
11287564,
|
| 128 |
+
22099623,
|
| 129 |
+
43171648,
|
| 130 |
+
18527365,
|
| 131 |
+
9541867,
|
| 132 |
+
15965073,
|
| 133 |
+
19151954,
|
| 134 |
+
24717676,
|
| 135 |
+
29613304,
|
| 136 |
+
7680504,
|
| 137 |
+
1585170,
|
| 138 |
+
17908555,
|
| 139 |
+
47252026,
|
| 140 |
+
6744006,
|
| 141 |
+
20563639,
|
| 142 |
+
16778667,
|
| 143 |
+
2310605,
|
| 144 |
+
11967776,
|
| 145 |
+
12176026,
|
| 146 |
+
16440377,
|
| 147 |
+
471183,
|
| 148 |
+
7657647,
|
| 149 |
+
6178498,
|
| 150 |
+
24889346,
|
| 151 |
+
16768776,
|
| 152 |
+
17534840,
|
| 153 |
+
13446255,
|
| 154 |
+
12297859,
|
| 155 |
+
20871534,
|
| 156 |
+
6156259,
|
| 157 |
+
40714970,
|
| 158 |
+
19339248,
|
| 159 |
+
7209629,
|
| 160 |
+
5864146,
|
| 161 |
+
17236005,
|
| 162 |
+
3337936,
|
| 163 |
+
2320564,
|
| 164 |
+
22956516,
|
| 165 |
+
1853009,
|
| 166 |
+
25486667,
|
| 167 |
+
4823864,
|
| 168 |
+
1538676,
|
| 169 |
+
30431353,
|
| 170 |
+
2957094,
|
| 171 |
+
4513623,
|
| 172 |
+
5398395,
|
| 173 |
+
18620153,
|
| 174 |
+
17364951,
|
| 175 |
+
18234378,
|
| 176 |
+
10829514,
|
| 177 |
+
1881237,
|
| 178 |
+
19017994,
|
| 179 |
+
9309940,
|
| 180 |
+
14840953,
|
| 181 |
+
16154007,
|
| 182 |
+
13316437,
|
| 183 |
+
7450324,
|
| 184 |
+
4014074,
|
| 185 |
+
8107886,
|
| 186 |
+
1271222,
|
| 187 |
+
15681498,
|
| 188 |
+
2560411,
|
| 189 |
+
1716470,
|
| 190 |
+
7520704,
|
| 191 |
+
6852951,
|
| 192 |
+
7635807,
|
| 193 |
+
17333755,
|
| 194 |
+
4953738,
|
| 195 |
+
20007288,
|
| 196 |
+
35021524,
|
| 197 |
+
11650940,
|
| 198 |
+
10552803,
|
| 199 |
+
28592043,
|
| 200 |
+
804646,
|
| 201 |
+
10207354,
|
| 202 |
+
9651898,
|
| 203 |
+
6739258,
|
| 204 |
+
9189120,
|
| 205 |
+
15361632,
|
| 206 |
+
487894,
|
| 207 |
+
18892670,
|
| 208 |
+
7359527,
|
| 209 |
+
2369314,
|
| 210 |
+
21336126,
|
| 211 |
+
13586349,
|
| 212 |
+
10082204,
|
| 213 |
+
20521857,
|
| 214 |
+
14348432,
|
| 215 |
+
20267910,
|
| 216 |
+
5955548,
|
| 217 |
+
8562354,
|
| 218 |
+
21309020,
|
| 219 |
+
8544197,
|
| 220 |
+
30179484,
|
| 221 |
+
1187354,
|
| 222 |
+
6245293,
|
| 223 |
+
26081375,
|
| 224 |
+
10107459,
|
| 225 |
+
10189703,
|
| 226 |
+
9053100,
|
| 227 |
+
26110266,
|
| 228 |
+
25447324,
|
| 229 |
+
1513861,
|
| 230 |
+
5047165,
|
| 231 |
+
13506109,
|
| 232 |
+
3323809,
|
| 233 |
+
8008546,
|
| 234 |
+
29081799,
|
| 235 |
+
2652494,
|
| 236 |
+
2222150,
|
| 237 |
+
10618798,
|
| 238 |
+
1074450,
|
| 239 |
+
4133286,
|
| 240 |
+
10565877,
|
| 241 |
+
3434462,
|
| 242 |
+
2157288,
|
| 243 |
+
1187078,
|
| 244 |
+
33914360,
|
| 245 |
+
17392869,
|
| 246 |
+
19406418,
|
| 247 |
+
21242932,
|
| 248 |
+
6111679,
|
| 249 |
+
24014194,
|
| 250 |
+
91110,
|
| 251 |
+
947404,
|
| 252 |
+
65536137,
|
| 253 |
+
11680815,
|
| 254 |
+
3984824,
|
| 255 |
+
14135027,
|
| 256 |
+
7814205,
|
| 257 |
+
11165182,
|
| 258 |
+
1797906,
|
| 259 |
+
32569032,
|
| 260 |
+
2522677,
|
| 261 |
+
12598916,
|
| 262 |
+
24832458,
|
| 263 |
+
4521162,
|
| 264 |
+
10664542,
|
| 265 |
+
15024561,
|
| 266 |
+
4609949,
|
| 267 |
+
1725265,
|
| 268 |
+
10589929,
|
| 269 |
+
17301683,
|
| 270 |
+
17363030,
|
| 271 |
+
18397698,
|
| 272 |
+
8857705,
|
| 273 |
+
25631989,
|
| 274 |
+
7103863,
|
| 275 |
+
8987257,
|
| 276 |
+
6123915,
|
| 277 |
+
11958369,
|
| 278 |
+
6945621,
|
| 279 |
+
19590980,
|
| 280 |
+
16935127,
|
| 281 |
+
4052253,
|
| 282 |
+
14813145,
|
| 283 |
+
6484340,
|
| 284 |
+
12144158,
|
| 285 |
+
10613643,
|
| 286 |
+
37639496,
|
| 287 |
+
9205669,
|
| 288 |
+
15920276,
|
| 289 |
+
6790631,
|
| 290 |
+
18166552,
|
| 291 |
+
12272065,
|
| 292 |
+
20943025,
|
| 293 |
+
24230117,
|
| 294 |
+
5385234,
|
| 295 |
+
7852132,
|
| 296 |
+
6387907,
|
| 297 |
+
2604964,
|
| 298 |
+
14137353,
|
| 299 |
+
10638538,
|
| 300 |
+
22289522,
|
| 301 |
+
13538772,
|
| 302 |
+
3350223,
|
| 303 |
+
34533893,
|
| 304 |
+
4348166,
|
| 305 |
+
6050766,
|
| 306 |
+
10822809,
|
| 307 |
+
1898553,
|
| 308 |
+
6554066,
|
| 309 |
+
8068203,
|
| 310 |
+
6870111,
|
| 311 |
+
10309968,
|
| 312 |
+
16715373,
|
| 313 |
+
12974162,
|
| 314 |
+
9833948,
|
| 315 |
+
27703776
|
| 316 |
+
]
|
| 317 |
+
},
|
| 318 |
+
"frozen_test_candidates": {
|
| 319 |
+
"ranks": [
|
| 320 |
+
301,
|
| 321 |
+
400
|
| 322 |
+
],
|
| 323 |
+
"question_ids": [
|
| 324 |
+
11687216,
|
| 325 |
+
7990750,
|
| 326 |
+
12178924,
|
| 327 |
+
8323287,
|
| 328 |
+
8394066,
|
| 329 |
+
49614034,
|
| 330 |
+
3874112,
|
| 331 |
+
24427009,
|
| 332 |
+
4109589,
|
| 333 |
+
14826862,
|
| 334 |
+
20568515,
|
| 335 |
+
25491847,
|
| 336 |
+
6181324,
|
| 337 |
+
6284518,
|
| 338 |
+
10754682,
|
| 339 |
+
4614775,
|
| 340 |
+
3576139,
|
| 341 |
+
14072592,
|
| 342 |
+
1412244,
|
| 343 |
+
48226592,
|
| 344 |
+
13202715,
|
| 345 |
+
7006910,
|
| 346 |
+
22159044,
|
| 347 |
+
9191030,
|
| 348 |
+
1227174,
|
| 349 |
+
14402949,
|
| 350 |
+
16297052,
|
| 351 |
+
29760638,
|
| 352 |
+
11146098,
|
| 353 |
+
3140974,
|
| 354 |
+
34576667,
|
| 355 |
+
3576380,
|
| 356 |
+
18539494,
|
| 357 |
+
39648222,
|
| 358 |
+
4448826,
|
| 359 |
+
7760717,
|
| 360 |
+
8991275,
|
| 361 |
+
9394408,
|
| 362 |
+
155934,
|
| 363 |
+
3675169,
|
| 364 |
+
31911179,
|
| 365 |
+
14372645,
|
| 366 |
+
8356958,
|
| 367 |
+
25173267,
|
| 368 |
+
8225822,
|
| 369 |
+
55005360,
|
| 370 |
+
31903432,
|
| 371 |
+
4090194,
|
| 372 |
+
13795196,
|
| 373 |
+
6011661,
|
| 374 |
+
5024357,
|
| 375 |
+
4031441,
|
| 376 |
+
24324350,
|
| 377 |
+
14479535,
|
| 378 |
+
40506782,
|
| 379 |
+
6006132,
|
| 380 |
+
24144440,
|
| 381 |
+
3194534,
|
| 382 |
+
6363328,
|
| 383 |
+
14846304,
|
| 384 |
+
11138434,
|
| 385 |
+
16576197,
|
| 386 |
+
5429840,
|
| 387 |
+
3839454,
|
| 388 |
+
3790101,
|
| 389 |
+
14046878,
|
| 390 |
+
16202900,
|
| 391 |
+
9970124,
|
| 392 |
+
3015645,
|
| 393 |
+
6869449,
|
| 394 |
+
7479686,
|
| 395 |
+
5544322,
|
| 396 |
+
13817798,
|
| 397 |
+
32889645,
|
| 398 |
+
13180057,
|
| 399 |
+
22939323,
|
| 400 |
+
21759562,
|
| 401 |
+
689495,
|
| 402 |
+
5886564,
|
| 403 |
+
6491532,
|
| 404 |
+
20808095,
|
| 405 |
+
28795479,
|
| 406 |
+
21621722,
|
| 407 |
+
15632691,
|
| 408 |
+
18602234,
|
| 409 |
+
3302434,
|
| 410 |
+
38833090,
|
| 411 |
+
6675492,
|
| 412 |
+
9601800,
|
| 413 |
+
3832068,
|
| 414 |
+
5463884,
|
| 415 |
+
13014055,
|
| 416 |
+
1617724,
|
| 417 |
+
13402809,
|
| 418 |
+
4870253,
|
| 419 |
+
39198780,
|
| 420 |
+
14262138,
|
| 421 |
+
9260625,
|
| 422 |
+
45772525,
|
| 423 |
+
10510917
|
| 424 |
+
]
|
| 425 |
+
}
|
| 426 |
+
}
|
review_real_questions.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from sedweave.execution import run_sed
|
| 8 |
+
|
| 9 |
+
EXCLUDE = {
|
| 10 |
+
"so-4078933",
|
| 11 |
+
"so-4198138",
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
COMMAND_FIXES = {
|
| 15 |
+
"so-11568859": "sed -n 's/^[^0-9]*\\([0-9][0-9]*G[0-9][0-9]*\\).*/\\1/p'",
|
| 16 |
+
"so-13242469": "sed 's/^.*Here\\(.*\\)String.*$/\\1/'",
|
| 17 |
+
"so-17511639": "sed -n 's/^.*[^0-9]\\([0-9][0-9]*\\)[ \\t]\\([0-9][0-9]*\\.[0-9][0-9]*\\)[ \\t]*$/\\1 \\2/p'",
|
| 18 |
+
"so-2777579": "sed -n 's/[^0-9][^0-9]*/ /g; s/^ *//; s/ *$//; /[0-9]/p'",
|
| 19 |
+
"so-8822097": "sed 's/^aaa=.*/aaa=xxx/'",
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
REQUEST_FIXES = {
|
| 23 |
+
"so-9953448": "Remove every space and tab character from each input line.",
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def main() -> None:
|
| 28 |
+
parser = argparse.ArgumentParser()
|
| 29 |
+
parser.add_argument("input", type=Path)
|
| 30 |
+
parser.add_argument("output", type=Path)
|
| 31 |
+
args = parser.parse_args()
|
| 32 |
+
rows = [json.loads(line) for line in args.input.open(encoding="utf-8")]
|
| 33 |
+
reviewed = []
|
| 34 |
+
for row in rows:
|
| 35 |
+
if row["id"] in EXCLUDE:
|
| 36 |
+
continue
|
| 37 |
+
row["command"] = COMMAND_FIXES.get(row["id"], row["command"])
|
| 38 |
+
row["request"] = REQUEST_FIXES.get(row["id"], row["request"])
|
| 39 |
+
row["expected_output"] = run_sed(row["command"], row["input_text"])
|
| 40 |
+
row["validation_output"] = run_sed(row["command"], row["validation_input"])
|
| 41 |
+
row["reviewed"] = True
|
| 42 |
+
reviewed.append(row)
|
| 43 |
+
with args.output.open("w", encoding="utf-8") as handle:
|
| 44 |
+
for row in reviewed:
|
| 45 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 46 |
+
print(f"wrote {len(reviewed)} reviewed rows; excluded {len(rows) - len(reviewed)}")
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
if __name__ == "__main__":
|
| 50 |
+
main()
|
review_v2_data.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from sedweave.execution import run_sed
|
| 8 |
+
|
| 9 |
+
EXCLUDE = {
|
| 10 |
+
"so-22099623",
|
| 11 |
+
"so-3832068",
|
| 12 |
+
"so-6245293",
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
COMMAND_FIXES = {
|
| 16 |
+
"so-4348166": "sed -n 's/.*_\\([0-9][0-9]*\\)\\(\\.gz\\)\\{0,1\\}$/\\1/p'",
|
| 17 |
+
"so-6739258": "sed '1,/^nameserver/ { /^nameserver/i\\\nnameserver 127.0.0.1\n}'",
|
| 18 |
+
"so-10754682": "sed 's/\\r$//; s/.*/\"&\"/'",
|
| 19 |
+
"so-28795479": "sed 's/\\([a-z0-9]\\)\\([A-Z]\\)/\\1_\\2/g; s/.*/\\L&/'",
|
| 20 |
+
"so-8225822": "sed -n 's/A/a/gp'",
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
REQUEST_FIXES = {
|
| 24 |
+
"so-1898553": "Replace each line with its first sequence of digits; leave lines without digits unchanged.",
|
| 25 |
+
"so-2957094": "Print only lines whose first two whitespace-separated fields are a number and a value starting with 'LINUX'.",
|
| 26 |
+
"so-3795512": "Remove the first five characters from every line that contains at least five characters.",
|
| 27 |
+
"so-6156259": "Print lines that contain the substring 'teste', optionally preceded by 'www.'. Use POSIX Basic Regular Expressions only.",
|
| 28 |
+
"so-14046878": "Delete from the first line exactly matching '-----THIS STUFF IS USELESS-----' to the end of the input stream.",
|
| 29 |
+
"so-9970124": "Insert the line 'New Inserted Line' immediately after the first occurrence of 'Matched Keyword', before any remaining text on that line.",
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def main() -> None:
|
| 34 |
+
parser = argparse.ArgumentParser()
|
| 35 |
+
parser.add_argument("input", type=Path)
|
| 36 |
+
parser.add_argument("output", type=Path)
|
| 37 |
+
parser.add_argument("--split", choices=("train", "test"), required=True)
|
| 38 |
+
args = parser.parse_args()
|
| 39 |
+
rows = [json.loads(line) for line in args.input.open(encoding="utf-8")]
|
| 40 |
+
reviewed = []
|
| 41 |
+
for row in rows:
|
| 42 |
+
if row["id"] in EXCLUDE:
|
| 43 |
+
continue
|
| 44 |
+
row["command"] = COMMAND_FIXES.get(row["id"], row["command"])
|
| 45 |
+
row["request"] = REQUEST_FIXES.get(row["id"], row["request"])
|
| 46 |
+
row["split"] = args.split
|
| 47 |
+
row["expected_output"] = run_sed(row["command"], row["input_text"])
|
| 48 |
+
row["validation_output"] = run_sed(row["command"], row["validation_input"])
|
| 49 |
+
if not row["expected_output"].strip() or not row["validation_output"].strip():
|
| 50 |
+
raise ValueError(f"Empty output: {row['id']}")
|
| 51 |
+
row["reviewed"] = True
|
| 52 |
+
reviewed.append(row)
|
| 53 |
+
with args.output.open("w", encoding="utf-8") as handle:
|
| 54 |
+
for row in reviewed:
|
| 55 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 56 |
+
print(f"wrote {len(reviewed)} reviewed {args.split} rows; excluded {len(rows) - len(reviewed)}")
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
main()
|
sedweave/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Sedweave: execution-verified natural-language-to-sed tools."""
|
| 2 |
+
|
| 3 |
+
__version__ = "0.1.0"
|
sedweave/execution.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import re
|
| 4 |
+
import resource
|
| 5 |
+
import shlex
|
| 6 |
+
import shutil
|
| 7 |
+
import subprocess
|
| 8 |
+
|
| 9 |
+
MAX_INPUT_BYTES = 1_000_000
|
| 10 |
+
MAX_COMMAND_CHARS = 4_000
|
| 11 |
+
FILE_COMMAND_PATTERN = re.compile(r"(?:^|[;{\s'\"])[rRwWe!|](?:\s|$)")
|
| 12 |
+
SHELL_PATTERN = re.compile(r"[`|]")
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class UnsafeCommandError(ValueError):
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def check_command(command: str) -> list[str]:
|
| 20 |
+
if not command.strip():
|
| 21 |
+
raise UnsafeCommandError("The sed command is empty.")
|
| 22 |
+
if len(command) > MAX_COMMAND_CHARS:
|
| 23 |
+
raise UnsafeCommandError("The sed command is too long.")
|
| 24 |
+
try:
|
| 25 |
+
arguments = shlex.split(command)
|
| 26 |
+
except ValueError as error:
|
| 27 |
+
raise UnsafeCommandError(f"Cannot parse sed command: {error}") from error
|
| 28 |
+
if not arguments or arguments[0] != "sed":
|
| 29 |
+
raise UnsafeCommandError("Only sed commands are allowed.")
|
| 30 |
+
if SHELL_PATTERN.search(command):
|
| 31 |
+
raise UnsafeCommandError("Pipes and shell control operators are not allowed.")
|
| 32 |
+
if FILE_COMMAND_PATTERN.search(command):
|
| 33 |
+
raise UnsafeCommandError("File and process commands are not allowed.")
|
| 34 |
+
index = 1
|
| 35 |
+
scripts = 0
|
| 36 |
+
while index < len(arguments):
|
| 37 |
+
argument = arguments[index]
|
| 38 |
+
if argument in {"-n", "--quiet", "--silent"}:
|
| 39 |
+
index += 1
|
| 40 |
+
elif argument in {"-e", "--expression"}:
|
| 41 |
+
if index + 1 >= len(arguments):
|
| 42 |
+
raise UnsafeCommandError("Missing sed expression.")
|
| 43 |
+
scripts += 1
|
| 44 |
+
index += 2
|
| 45 |
+
elif argument.startswith("-"):
|
| 46 |
+
raise UnsafeCommandError(f"Unsupported sed option: {argument}")
|
| 47 |
+
else:
|
| 48 |
+
scripts += 1
|
| 49 |
+
index += 1
|
| 50 |
+
if scripts != 1:
|
| 51 |
+
raise UnsafeCommandError("Expected exactly one sed expression and no filenames.")
|
| 52 |
+
return arguments
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def limit_resources() -> None:
|
| 56 |
+
resource.setrlimit(resource.RLIMIT_CPU, (2, 2))
|
| 57 |
+
resource.setrlimit(resource.RLIMIT_AS, (256_000_000, 256_000_000))
|
| 58 |
+
resource.setrlimit(resource.RLIMIT_FSIZE, (1_000_000, 1_000_000))
|
| 59 |
+
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
|
| 60 |
+
resource.setrlimit(resource.RLIMIT_NOFILE, (16, 16))
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def run_sed(command: str, input_text: str, timeout: float = 3.0) -> str:
|
| 64 |
+
arguments = check_command(command)
|
| 65 |
+
if len(input_text.encode("utf-8")) > MAX_INPUT_BYTES:
|
| 66 |
+
raise ValueError("Input text exceeds the 1 MB limit.")
|
| 67 |
+
executable = shutil.which("sed")
|
| 68 |
+
if executable is None:
|
| 69 |
+
raise RuntimeError("No sed executable is available on PATH.")
|
| 70 |
+
result = subprocess.run(
|
| 71 |
+
[executable, *arguments[1:]],
|
| 72 |
+
input=input_text,
|
| 73 |
+
text=True,
|
| 74 |
+
capture_output=True,
|
| 75 |
+
timeout=timeout,
|
| 76 |
+
env={"LC_ALL": "C", "PATH": "/usr/bin:/bin"},
|
| 77 |
+
preexec_fn=limit_resources,
|
| 78 |
+
start_new_session=True,
|
| 79 |
+
check=False,
|
| 80 |
+
)
|
| 81 |
+
if result.returncode != 0:
|
| 82 |
+
raise ValueError(result.stderr.strip() or f"sed exited with status {result.returncode}")
|
| 83 |
+
return result.stdout
|
train_sft.py
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import hashlib
|
| 5 |
+
import importlib.metadata
|
| 6 |
+
import inspect
|
| 7 |
+
import json
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
from datasets import load_dataset
|
| 12 |
+
from peft import LoraConfig, get_peft_model
|
| 13 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, Trainer, TrainingArguments
|
| 14 |
+
|
| 15 |
+
from sedweave.prompts import messages
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class Collator:
|
| 19 |
+
def __init__(self, pad_token_id: int):
|
| 20 |
+
self.pad_token_id = pad_token_id
|
| 21 |
+
|
| 22 |
+
def __call__(self, features: list[dict]) -> dict[str, torch.Tensor]:
|
| 23 |
+
max_length = max(len(feature["input_ids"]) for feature in features)
|
| 24 |
+
input_ids, labels, attention_mask = [], [], []
|
| 25 |
+
for feature in features:
|
| 26 |
+
padding = max_length - len(feature["input_ids"])
|
| 27 |
+
input_ids.append(feature["input_ids"] + [self.pad_token_id] * padding)
|
| 28 |
+
labels.append(feature["labels"] + [-100] * padding)
|
| 29 |
+
attention_mask.append([1] * len(feature["input_ids"]) + [0] * padding)
|
| 30 |
+
return {
|
| 31 |
+
"input_ids": torch.tensor(input_ids, dtype=torch.long),
|
| 32 |
+
"labels": torch.tensor(labels, dtype=torch.long),
|
| 33 |
+
"attention_mask": torch.tensor(attention_mask, dtype=torch.long),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def main() -> None:
|
| 38 |
+
parser = argparse.ArgumentParser()
|
| 39 |
+
parser.add_argument("--data", required=True)
|
| 40 |
+
parser.add_argument("--output", required=True)
|
| 41 |
+
parser.add_argument("--base-model", default="Qwen/Qwen2.5-Coder-0.5B-Instruct")
|
| 42 |
+
parser.add_argument("--max-length", type=int, default=1024)
|
| 43 |
+
parser.add_argument("--max-rows", type=int)
|
| 44 |
+
parser.add_argument("--eval-rows", type=int, default=500)
|
| 45 |
+
parser.add_argument("--epochs", type=float, default=1.0)
|
| 46 |
+
parser.add_argument("--batch-size", type=int, default=32)
|
| 47 |
+
parser.add_argument("--gradient-accumulation", type=int, default=2)
|
| 48 |
+
parser.add_argument("--learning-rate", type=float, default=5e-5)
|
| 49 |
+
parser.add_argument("--precision", choices=("bf16", "fp32"), default="bf16")
|
| 50 |
+
parser.add_argument("--eval-steps", type=int, default=250)
|
| 51 |
+
parser.add_argument("--logging-steps", type=int, default=20)
|
| 52 |
+
parser.add_argument("--seed", type=int, default=42)
|
| 53 |
+
args = parser.parse_args()
|
| 54 |
+
if not torch.cuda.is_available():
|
| 55 |
+
raise RuntimeError("A working CUDA GPU is required for BF16 training.")
|
| 56 |
+
|
| 57 |
+
output = Path(args.output)
|
| 58 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 59 |
+
tokenizer = AutoTokenizer.from_pretrained(args.base_model)
|
| 60 |
+
if tokenizer.pad_token_id is None:
|
| 61 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 62 |
+
|
| 63 |
+
dataset = load_dataset("json", data_files=args.data, split="train")
|
| 64 |
+
dataset = dataset.filter(lambda row: row["split"] == "train", num_proc=8)
|
| 65 |
+
dataset = dataset.shuffle(seed=args.seed)
|
| 66 |
+
if args.max_rows:
|
| 67 |
+
dataset = dataset.select(range(min(args.max_rows, len(dataset))))
|
| 68 |
+
eval_dataset = load_dataset("json", data_files=args.data, split="train")
|
| 69 |
+
eval_dataset = eval_dataset.filter(lambda row: row["split"] == "validation", num_proc=8)
|
| 70 |
+
if len(eval_dataset) == 0:
|
| 71 |
+
raise ValueError("Input data must include at least one row with split='validation'.")
|
| 72 |
+
eval_dataset = eval_dataset.shuffle(seed=args.seed)
|
| 73 |
+
if args.eval_rows:
|
| 74 |
+
eval_dataset = eval_dataset.select(range(min(args.eval_rows, len(eval_dataset))))
|
| 75 |
+
|
| 76 |
+
def tokenize(row: dict) -> dict:
|
| 77 |
+
prompt = tokenizer.apply_chat_template(
|
| 78 |
+
messages(row["request"], row["input_text"]),
|
| 79 |
+
tokenize=False,
|
| 80 |
+
add_generation_prompt=True,
|
| 81 |
+
)
|
| 82 |
+
prompt_ids = tokenizer(prompt, add_special_tokens=False)["input_ids"]
|
| 83 |
+
target_ids = tokenizer(row["command"].strip() + tokenizer.eos_token + "\n", add_special_tokens=False)["input_ids"]
|
| 84 |
+
input_ids = (prompt_ids + target_ids)[: args.max_length]
|
| 85 |
+
labels = ([-100] * len(prompt_ids) + target_ids)[: args.max_length]
|
| 86 |
+
return {"input_ids": input_ids, "labels": labels, "length": len(input_ids)}
|
| 87 |
+
|
| 88 |
+
columns = dataset.column_names
|
| 89 |
+
dataset = dataset.map(tokenize, remove_columns=columns, num_proc=8, desc="Tokenizing train")
|
| 90 |
+
eval_dataset = eval_dataset.map(tokenize, remove_columns=eval_dataset.column_names, num_proc=8, desc="Tokenizing validation")
|
| 91 |
+
|
| 92 |
+
dtype = torch.bfloat16 if args.precision == "bf16" else torch.float32
|
| 93 |
+
model = AutoModelForCausalLM.from_pretrained(args.base_model, torch_dtype=dtype)
|
| 94 |
+
model.config.use_cache = False
|
| 95 |
+
lora_config = LoraConfig(
|
| 96 |
+
r=32,
|
| 97 |
+
lora_alpha=64,
|
| 98 |
+
lora_dropout=0.05,
|
| 99 |
+
bias="none",
|
| 100 |
+
task_type="CAUSAL_LM",
|
| 101 |
+
target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
|
| 102 |
+
)
|
| 103 |
+
model = get_peft_model(model, lora_config)
|
| 104 |
+
model.print_trainable_parameters()
|
| 105 |
+
|
| 106 |
+
options = dict(
|
| 107 |
+
output_dir=str(output / "checkpoints"),
|
| 108 |
+
num_train_epochs=args.epochs,
|
| 109 |
+
per_device_train_batch_size=args.batch_size,
|
| 110 |
+
per_device_eval_batch_size=args.batch_size,
|
| 111 |
+
gradient_accumulation_steps=args.gradient_accumulation,
|
| 112 |
+
learning_rate=args.learning_rate,
|
| 113 |
+
lr_scheduler_type="cosine",
|
| 114 |
+
warmup_ratio=0.03,
|
| 115 |
+
weight_decay=0.0,
|
| 116 |
+
max_grad_norm=0.5,
|
| 117 |
+
bf16=args.precision == "bf16",
|
| 118 |
+
tf32=True,
|
| 119 |
+
gradient_checkpointing=True,
|
| 120 |
+
gradient_checkpointing_kwargs={"use_reentrant": False},
|
| 121 |
+
optim="adamw_torch",
|
| 122 |
+
logging_steps=args.logging_steps,
|
| 123 |
+
save_steps=500,
|
| 124 |
+
save_total_limit=2,
|
| 125 |
+
eval_steps=args.eval_steps,
|
| 126 |
+
report_to=[],
|
| 127 |
+
seed=args.seed,
|
| 128 |
+
data_seed=args.seed,
|
| 129 |
+
group_by_length=True,
|
| 130 |
+
remove_unused_columns=False,
|
| 131 |
+
dataloader_num_workers=4,
|
| 132 |
+
save_safetensors=True,
|
| 133 |
+
)
|
| 134 |
+
parameters = inspect.signature(TrainingArguments.__init__).parameters
|
| 135 |
+
if "warmup_ratio" not in parameters:
|
| 136 |
+
options.pop("warmup_ratio")
|
| 137 |
+
steps = args.epochs * len(dataset) / (args.batch_size * args.gradient_accumulation)
|
| 138 |
+
options["warmup_steps"] = max(1, round(steps * 0.03))
|
| 139 |
+
if "overwrite_output_dir" in parameters:
|
| 140 |
+
options["overwrite_output_dir"] = True
|
| 141 |
+
if "eval_strategy" in parameters:
|
| 142 |
+
options["eval_strategy"] = "steps"
|
| 143 |
+
else:
|
| 144 |
+
options["evaluation_strategy"] = "steps"
|
| 145 |
+
unsupported = sorted(set(options) - set(parameters))
|
| 146 |
+
if unsupported:
|
| 147 |
+
print(f"Ignoring unsupported TrainingArguments options: {unsupported}", flush=True)
|
| 148 |
+
options = {key: value for key, value in options.items() if key in parameters}
|
| 149 |
+
training_args = TrainingArguments(**options)
|
| 150 |
+
trainer = Trainer(
|
| 151 |
+
model=model,
|
| 152 |
+
args=training_args,
|
| 153 |
+
train_dataset=dataset,
|
| 154 |
+
eval_dataset=eval_dataset,
|
| 155 |
+
data_collator=Collator(tokenizer.pad_token_id),
|
| 156 |
+
)
|
| 157 |
+
result = trainer.train()
|
| 158 |
+
trainer.save_metrics("train", result.metrics)
|
| 159 |
+
trainer.save_state()
|
| 160 |
+
unhealthy = [name for name, parameter in model.named_parameters() if not torch.isfinite(parameter).all().item()]
|
| 161 |
+
if unhealthy:
|
| 162 |
+
raise RuntimeError(f"Non-finite model parameters after training: {unhealthy[:10]}")
|
| 163 |
+
|
| 164 |
+
merged = model.merge_and_unload()
|
| 165 |
+
if args.precision == "fp32":
|
| 166 |
+
merged = merged.to(torch.bfloat16)
|
| 167 |
+
merged.config.use_cache = True
|
| 168 |
+
merged.generation_config.do_sample = False
|
| 169 |
+
merged.generation_config.temperature = None
|
| 170 |
+
merged.generation_config.top_p = None
|
| 171 |
+
merged.generation_config.top_k = None
|
| 172 |
+
merged.generation_config.max_new_tokens = 192
|
| 173 |
+
merged.save_pretrained(output / "model", safe_serialization=True)
|
| 174 |
+
tokenizer.save_pretrained(output / "model")
|
| 175 |
+
config = vars(args).copy()
|
| 176 |
+
config.update({
|
| 177 |
+
"lora_r": 32,
|
| 178 |
+
"lora_alpha": 64,
|
| 179 |
+
"lora_dropout": 0.05,
|
| 180 |
+
"target_modules": lora_config.target_modules,
|
| 181 |
+
"train_rows": len(dataset),
|
| 182 |
+
"validation_rows": len(eval_dataset),
|
| 183 |
+
"train_metrics": result.metrics,
|
| 184 |
+
"data_sha256": hashlib.sha256(Path(args.data).read_bytes()).hexdigest(),
|
| 185 |
+
"library_versions": {
|
| 186 |
+
name: importlib.metadata.version(name)
|
| 187 |
+
for name in ("torch", "transformers", "datasets", "peft", "accelerate")
|
| 188 |
+
},
|
| 189 |
+
})
|
| 190 |
+
with (output / "training_config.json").open("w", encoding="utf-8") as handle:
|
| 191 |
+
json.dump(config, handle, indent=2, default=str)
|
| 192 |
+
print(f"Saved merged model to {output / 'model'}")
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
if __name__ == "__main__":
|
| 196 |
+
main()
|
v2-mix-summary.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"output": "sedweave-v2-mix.jsonl",
|
| 3 |
+
"sha256": "cd97d93d0c33d46884dbbe3fd45e19fd61787cf701e2b1626dc1e14d1dad78a5",
|
| 4 |
+
"train_rows": 6926,
|
| 5 |
+
"validation_rows": 42,
|
| 6 |
+
"synthetic_replay_rows": 5984,
|
| 7 |
+
"real_expansion_rows": 942,
|
| 8 |
+
"real_unique_rows": 157,
|
| 9 |
+
"real_repeat": 6,
|
| 10 |
+
"replay_per_family": 176,
|
| 11 |
+
"families": 34,
|
| 12 |
+
"seed": 42,
|
| 13 |
+
"train_dev_input_overlap": 0,
|
| 14 |
+
"train_dev_request_command_overlap": 0
|
| 15 |
+
}
|
validate_dataset.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import collections
|
| 5 |
+
import concurrent.futures
|
| 6 |
+
import hashlib
|
| 7 |
+
import json
|
| 8 |
+
import shutil
|
| 9 |
+
import subprocess
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
from sedweave.execution import run_sed
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def sed_version() -> str:
|
| 16 |
+
executable = shutil.which("sed")
|
| 17 |
+
if executable is None:
|
| 18 |
+
return "sed unavailable"
|
| 19 |
+
result = subprocess.run([executable, "--version"], capture_output=True, text=True, check=False)
|
| 20 |
+
output = (result.stdout or result.stderr).strip().splitlines()
|
| 21 |
+
if result.returncode == 0 and output:
|
| 22 |
+
return output[0]
|
| 23 |
+
return "unknown sed"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def validate_row(row: dict) -> tuple[str, str | None]:
|
| 27 |
+
try:
|
| 28 |
+
if run_sed(row["command"], row["input_text"]) != row["expected_output"]:
|
| 29 |
+
return row["id"], "primary output mismatch"
|
| 30 |
+
if run_sed(row["command"], row["validation_input"]) != row["validation_output"]:
|
| 31 |
+
return row["id"], "validation output mismatch"
|
| 32 |
+
return row["id"], None
|
| 33 |
+
except Exception as error:
|
| 34 |
+
return row["id"], str(error)[:500]
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def main() -> None:
|
| 38 |
+
parser = argparse.ArgumentParser()
|
| 39 |
+
parser.add_argument("data", type=Path)
|
| 40 |
+
parser.add_argument("--workers", type=int, default=8)
|
| 41 |
+
parser.add_argument("--output", type=Path)
|
| 42 |
+
args = parser.parse_args()
|
| 43 |
+
rows = [json.loads(line) for line in args.data.open(encoding="utf-8")]
|
| 44 |
+
ids = [row["id"] for row in rows]
|
| 45 |
+
if len(ids) != len(set(ids)):
|
| 46 |
+
raise ValueError("Duplicate row IDs")
|
| 47 |
+
by_id = {row["id"]: row for row in rows}
|
| 48 |
+
for row in rows:
|
| 49 |
+
if row.get("paraphrase_of"):
|
| 50 |
+
original = by_id.get(row["paraphrase_of"])
|
| 51 |
+
if original is None:
|
| 52 |
+
raise ValueError(f"Missing paraphrase source: {row['id']}")
|
| 53 |
+
for key in ("command", "input_text", "expected_output", "validation_input", "validation_output", "split"):
|
| 54 |
+
if row[key] != original[key]:
|
| 55 |
+
raise ValueError(f"Paraphrase changed {key}: {row['id']}")
|
| 56 |
+
if row["split"] != "train":
|
| 57 |
+
raise ValueError(f"Paraphrase outside train split: {row['id']}")
|
| 58 |
+
|
| 59 |
+
errors = []
|
| 60 |
+
with concurrent.futures.ProcessPoolExecutor(max_workers=args.workers) as executor:
|
| 61 |
+
for completed, (row_id, error) in enumerate(executor.map(validate_row, rows, chunksize=20), 1):
|
| 62 |
+
if error:
|
| 63 |
+
errors.append({"id": row_id, "error": error})
|
| 64 |
+
if completed % 5000 == 0:
|
| 65 |
+
print(f"validated {completed}/{len(rows)}", flush=True)
|
| 66 |
+
split_integrity = {}
|
| 67 |
+
for left, right in (
|
| 68 |
+
("train", "validation"), ("train", "test"), ("validation", "test"),
|
| 69 |
+
("train", "challenge"), ("validation", "challenge"), ("test", "challenge"),
|
| 70 |
+
):
|
| 71 |
+
left_rows = [row for row in rows if row["split"] == left and not row.get("paraphrase_of")]
|
| 72 |
+
right_rows = [row for row in rows if row["split"] == right and not row.get("paraphrase_of")]
|
| 73 |
+
split_integrity[f"{left}-{right}"] = {
|
| 74 |
+
"input_overlap": len({row["input_text"] for row in left_rows} & {row["input_text"] for row in right_rows}),
|
| 75 |
+
"request_command_overlap": len(
|
| 76 |
+
{(row["request"], row["command"]) for row in left_rows}
|
| 77 |
+
& {(row["request"], row["command"]) for row in right_rows}
|
| 78 |
+
),
|
| 79 |
+
}
|
| 80 |
+
summary = {
|
| 81 |
+
"data": str(args.data),
|
| 82 |
+
"sha256": hashlib.sha256(args.data.read_bytes()).hexdigest(),
|
| 83 |
+
"rows": len(rows),
|
| 84 |
+
"executions": len(rows) * 2,
|
| 85 |
+
"sed_version": sed_version(),
|
| 86 |
+
"errors": errors,
|
| 87 |
+
"splits": dict(collections.Counter(row["split"] for row in rows)),
|
| 88 |
+
"sources": dict(collections.Counter(row["source"] for row in rows)),
|
| 89 |
+
"families": dict(collections.Counter(row["family"] for row in rows)),
|
| 90 |
+
"unique_requests": len({row["request"] for row in rows}),
|
| 91 |
+
"unique_commands": len({row["command"] for row in rows}),
|
| 92 |
+
"split_integrity": split_integrity,
|
| 93 |
+
}
|
| 94 |
+
text = json.dumps(summary, indent=2)
|
| 95 |
+
if args.output:
|
| 96 |
+
args.output.write_text(text, encoding="utf-8")
|
| 97 |
+
print(text)
|
| 98 |
+
if errors:
|
| 99 |
+
raise SystemExit(1)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
if __name__ == "__main__":
|
| 103 |
+
main()
|
validation.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"data": "sedweave-real-data.jsonl",
|
| 3 |
+
"sha256": "8403229c08a5e86312aaf6aa502e269a0a7acff12cf21c151ac808aace03391c",
|
| 4 |
+
"rows": 236,
|
| 5 |
+
"executions": 472,
|
| 6 |
+
"sed_version": "/usr/bin/sed (GNU sed) 4.9",
|
| 7 |
+
"errors": [],
|
| 8 |
+
"splits": {
|
| 9 |
+
"train": 157,
|
| 10 |
+
"validation": 42,
|
| 11 |
+
"test": 37
|
| 12 |
+
},
|
| 13 |
+
"sources": {
|
| 14 |
+
"stackoverflow-accepted-answer": 154,
|
| 15 |
+
"openrouter-paraphrase": 78,
|
| 16 |
+
"openrouter-input-variation": 4
|
| 17 |
+
},
|
| 18 |
+
"families": {
|
| 19 |
+
"real-stackoverflow": 236
|
| 20 |
+
},
|
| 21 |
+
"unique_requests": 231,
|
| 22 |
+
"unique_commands": 150,
|
| 23 |
+
"split_integrity": {
|
| 24 |
+
"train-validation": {
|
| 25 |
+
"input_overlap": 0,
|
| 26 |
+
"request_command_overlap": 0
|
| 27 |
+
},
|
| 28 |
+
"train-test": {
|
| 29 |
+
"input_overlap": 0,
|
| 30 |
+
"request_command_overlap": 0
|
| 31 |
+
},
|
| 32 |
+
"validation-test": {
|
| 33 |
+
"input_overlap": 0,
|
| 34 |
+
"request_command_overlap": 0
|
| 35 |
+
},
|
| 36 |
+
"train-challenge": {
|
| 37 |
+
"input_overlap": 0,
|
| 38 |
+
"request_command_overlap": 0
|
| 39 |
+
},
|
| 40 |
+
"validation-challenge": {
|
| 41 |
+
"input_overlap": 0,
|
| 42 |
+
"request_command_overlap": 0
|
| 43 |
+
},
|
| 44 |
+
"test-challenge": {
|
| 45 |
+
"input_overlap": 0,
|
| 46 |
+
"request_command_overlap": 0
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
vary_real_inputs.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import concurrent.futures
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
import re
|
| 8 |
+
import time
|
| 9 |
+
import urllib.request
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
from sedweave.execution import run_sed
|
| 13 |
+
|
| 14 |
+
MODEL = "qwen/qwen3.7-plus"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def request_batch(rows: list[dict]) -> list[dict]:
|
| 18 |
+
context = [
|
| 19 |
+
{
|
| 20 |
+
"id": row["id"],
|
| 21 |
+
"request": row["request"],
|
| 22 |
+
"command": row["command"],
|
| 23 |
+
"example_input": row["input_text"],
|
| 24 |
+
}
|
| 25 |
+
for row in rows
|
| 26 |
+
]
|
| 27 |
+
payload = {
|
| 28 |
+
"model": MODEL,
|
| 29 |
+
"messages": [
|
| 30 |
+
{
|
| 31 |
+
"role": "system",
|
| 32 |
+
"content": (
|
| 33 |
+
"Create fresh representative inputs for natural-language-to-sed training tasks. Return only valid "
|
| 34 |
+
"JSON with a variations array containing exactly two objects per input task. Each object must have "
|
| 35 |
+
"id, input_text, and validation_input. Both inputs must exercise the requested operation, use up to "
|
| 36 |
+
"8 lines, differ from each other and from the example input, and include realistic values rather than "
|
| 37 |
+
"the expected output. Keep the same schema as the example while varying values and edge cases. Every "
|
| 38 |
+
"literal pattern, marker, key name, and delimiter used by the command must remain unchanged; do not "
|
| 39 |
+
"invent different markers. Both new inputs must exercise the operation. Use the original task id exactly "
|
| 40 |
+
"as id. Do not change the command or request. Expected outputs will be computed by execution."
|
| 41 |
+
),
|
| 42 |
+
},
|
| 43 |
+
{"role": "user", "content": json.dumps(context, ensure_ascii=False)},
|
| 44 |
+
],
|
| 45 |
+
"response_format": {"type": "json_object"},
|
| 46 |
+
"temperature": 0.7,
|
| 47 |
+
"max_tokens": 6000,
|
| 48 |
+
"reasoning": {"enabled": False},
|
| 49 |
+
}
|
| 50 |
+
request = urllib.request.Request(
|
| 51 |
+
os.environ["OPENROUTER_BASE_URL"].rstrip("/") + "/chat/completions",
|
| 52 |
+
data=json.dumps(payload).encode("utf-8"),
|
| 53 |
+
headers={"Authorization": "Bearer " + os.environ["OPENROUTER_API_KEY"], "Content-Type": "application/json"},
|
| 54 |
+
)
|
| 55 |
+
for attempt in range(4):
|
| 56 |
+
try:
|
| 57 |
+
with urllib.request.urlopen(request, timeout=180) as response:
|
| 58 |
+
data = json.load(response)
|
| 59 |
+
return json.loads(data["choices"][0]["message"]["content"])["variations"]
|
| 60 |
+
except Exception:
|
| 61 |
+
if attempt == 3:
|
| 62 |
+
raise
|
| 63 |
+
time.sleep(2 ** attempt)
|
| 64 |
+
raise AssertionError("unreachable")
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def main() -> None:
|
| 68 |
+
parser = argparse.ArgumentParser()
|
| 69 |
+
parser.add_argument("input", type=Path)
|
| 70 |
+
parser.add_argument("output", type=Path)
|
| 71 |
+
args = parser.parse_args()
|
| 72 |
+
originals = [json.loads(line) for line in args.input.open(encoding="utf-8")]
|
| 73 |
+
if any(row["split"] != "train" for row in originals):
|
| 74 |
+
raise ValueError("Input variations are allowed only for training rows")
|
| 75 |
+
by_id = {row["id"]: row for row in originals}
|
| 76 |
+
batches = [originals[index:index + 4] for index in range(0, len(originals), 4)]
|
| 77 |
+
candidates = []
|
| 78 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
| 79 |
+
futures = [executor.submit(request_batch, batch) for batch in batches]
|
| 80 |
+
for future in concurrent.futures.as_completed(futures):
|
| 81 |
+
try:
|
| 82 |
+
candidates.extend(future.result())
|
| 83 |
+
except Exception as error:
|
| 84 |
+
print("batch failed", error, flush=True)
|
| 85 |
+
|
| 86 |
+
raw_path = args.output.parent / ".tmp" / "so-v2" / "variations-raw.json"
|
| 87 |
+
raw_path.parent.mkdir(parents=True, exist_ok=True)
|
| 88 |
+
raw_path.write_text(json.dumps(candidates, indent=2), encoding="utf-8")
|
| 89 |
+
variants = []
|
| 90 |
+
seen_inputs = {row["input_text"] for row in originals}
|
| 91 |
+
counts = {row["id"]: 0 for row in originals}
|
| 92 |
+
for candidate in candidates:
|
| 93 |
+
row_id = re.sub(r"-var\d+$", "", str(candidate.get("id")))
|
| 94 |
+
if row_id not in by_id or counts[row_id] >= 2:
|
| 95 |
+
continue
|
| 96 |
+
try:
|
| 97 |
+
input_text = candidate["input_text"]
|
| 98 |
+
validation_input = candidate["validation_input"]
|
| 99 |
+
if input_text == validation_input or input_text in seen_inputs or validation_input in seen_inputs:
|
| 100 |
+
raise ValueError("Duplicate input")
|
| 101 |
+
literals = [next(value for value in groups if value) for groups in re.findall(r"'([^']+)'|\"([^\"]+)\"|`([^`]+)`", by_id[row_id]["request"])]
|
| 102 |
+
if literals and not any(any(literal in text for literal in literals) for text in (input_text, validation_input)):
|
| 103 |
+
raise ValueError("No request literal appears in either input")
|
| 104 |
+
row = dict(by_id[row_id])
|
| 105 |
+
row["input_text"] = input_text
|
| 106 |
+
row["validation_input"] = validation_input
|
| 107 |
+
row["expected_output"] = run_sed(row["command"], input_text)
|
| 108 |
+
row["validation_output"] = run_sed(row["command"], validation_input)
|
| 109 |
+
if not row["expected_output"].strip() or not row["validation_output"].strip():
|
| 110 |
+
raise ValueError("Empty output")
|
| 111 |
+
if row["expected_output"] == input_text and row["validation_output"] == validation_input:
|
| 112 |
+
raise ValueError("No transformation")
|
| 113 |
+
counts[row_id] += 1
|
| 114 |
+
row["id"] = f"{row_id}-v{counts[row_id]}"
|
| 115 |
+
row["variation_of"] = row_id
|
| 116 |
+
row["source"] = "openrouter-input-variation"
|
| 117 |
+
row["variation_model"] = MODEL
|
| 118 |
+
seen_inputs.update((input_text, validation_input))
|
| 119 |
+
variants.append(row)
|
| 120 |
+
except Exception as error:
|
| 121 |
+
print("variant skipped", row_id, str(error)[:160], flush=True)
|
| 122 |
+
|
| 123 |
+
rows = originals + variants
|
| 124 |
+
rows.sort(key=lambda row: row["id"])
|
| 125 |
+
with args.output.open("w", encoding="utf-8") as handle:
|
| 126 |
+
for row in rows:
|
| 127 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 128 |
+
print(f"wrote {len(originals)} originals and {len(variants)} input variations")
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
if __name__ == "__main__":
|
| 132 |
+
main()
|