4 ms·
Can one write a tree-sitter grammar for English (or any other natural language), that basically labels each sentence as a statement, so I can use difftastic to
by abdullahkhalids 3y ago
Can one write a tree-sitter grammar for English (or any other natural language), that basically labels each sentence as a statement, so I can use difftastic to show changes on sentences rather than visual lines?
This is because visual line diffs for an essay is bonkers. Usually the sentence changed starts in the middle of a visual line.
- fragmede 3y agoword diff gets you halfway without that complexity
- abdullahkhalids 3y agoDo you mean the diff system inbuilt into Microsoft Word or Google docs etc?
- senknvd 3y agoThere is a --word-diff flag in git diff. It can also be customized using --word-diff-regex to possibly match sentences.
- abdullahkhalids 3y agoI see. From the docs [1] --word-diff-regex=<regex> ... A match that contains a newline is silently truncated(!) at the newline. If I understand this correctly, if you use newlines inside a sentence (if you are writing a fixed width document, for example), this won't work. [1] https://git-scm.com/docs/git-diff https://git-scm.com/docs/git-diff
- mzs 3y agopipe through "fmt -sw999999999999" first
- pxeger1 3y agoThe common advice[0] is to just write one sentence per line. I usually split at commas etc as well. Then use editor soft wrapping instead of fixing a maximum line length - but if your lines get longer than the screen width that might be a sign your sentences are too complex. [0]: anyone have a good source for this? I’m not sure where I first encountered it
- meatmanek 3y agohttps://news.ycombinator.com/item?id=31808093 https://news.ycombinator.com/item?id=31808093
- bpeebles 3y agohttps://rhodesmill.org/brandon/2012/one-sentence-per-line/ https://rhodesmill.org/brandon/2012/one-sentence-per-line/ is one possibility. And discusses a Kernighan Unix memo from 1974 advocating for the practice. "UNIX for Beginners" https://web.archive.org/web/20130108163017if_/http://miffy.tom-yam.or.jp:80/2238/ref/beg.pdf https://web.archive.org/web/20130108163017if_/http://miffy.t... (PDF)
- abdullahkhalids 3y agoI am not a slave of the machine. The machine is my tool. The machine will conform to what I want. Not the other way around. There is no philosophy more important in this age.
- antonvs 3y agoIn my work I encounter quite a few people beating their heads against walls trying to make the machine "conform to what they want". You can often achieve your goals much more quickly by using tools they way they best support being used.
- alpaca128 3y agoAnd often there is a middleground. In this case one could write a script that outputs a reformatted file with one sentence per line. In Vim this could even be a simple macro as the editor already has a key for jumping to the next sentence.