Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
c0nstantine
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
1.
▲
by
c0nstantine
1y ago
Working on trre - extension of regex for text editing. I'm redesigning the underlying engine to operate on deterministic automata (transducers) for most expressions. Theoretically, it should outperform AWK in complex text-processing ta
2.
▲
by
c0nstantine
2y ago
I have a minimalistic one (7 lines in Python) using convolutions: https://c0stya.github.io/articles/game_of_life.html ### The code ### import numpy as np from scipy.signal import convolve2d field = np.random.r
3.
▲
by
c0nstantine
2y ago
Thank you for your feedback. There is a bunch of deterministic methods to infer regex from samples (positive and negative). There are ml-based as well. But it is a different story.
4.
▲
by
c0nstantine
2y ago
Let me know if you need any help. Not it is still raw but I hope I'll polish it soon.
5.
▲
by
c0nstantine
2y ago
Hi. Missed your message initially. Helix is a great project. Let me know if/how I can help. The trre is a bit raw. But hope I can polish it within a month or two.
6.
▲
by
c0nstantine
2y ago
Did it solve the problem? I guess the issue is the process substitution construction of bash "<()". Not all shells support this.
7.
▲
by
c0nstantine
2y ago
Epsilon injection appears whenever right or left side of ':' has no operand. E.g. (:a) (a:) a:|b a|b: etc I will try to change the precedence and see how it works. Btw what do you think about explicit operators '>' &
8.
▲
by
c0nstantine
2y ago
Thank you for the detailed comment. So Unicode is something on a top of my TODO list. Boundaries is a very interesting topic. Maybe I'll extend the doc to include the details. > what's your driver? curiosity? or some itch? It&#
9.
▲
by
c0nstantine
2y ago
I agree with the point that precedence is arbitrary. The current version looks like this: 1 Escaped characters 2 [] 3 () 4 * + ? {m,n} 5 : 6 . (implicit concatenation) 7 | I have some reasons to put it that way. I want : to be somewhat 
10.
▲
by
c0nstantine
2y ago
Thank you for doing my work! :)
11.
▲
by
c0nstantine
2y ago
Hi, If I understand it correctly you want to change something inside the "..." block and change the quotas to single '. It can be done by this expression: echo '"hello world" "hello again!"' | .&
12.
▲
by
c0nstantine
2y ago
Oh, I've learnt a lot. Initially wanted to complete the whole project in two weeks and it took a few months. The hardest part was the DFT determinization algorithm design. Thanks for your feedback!
13.
▲
by
c0nstantine
2y ago
The right side is a normal regex language syntactically. Semantically it is a generator instead of a parser (consumer). But I got your point. Maybe there could be some ways to do it in consistent way. Just straight tr-like syntax won't
14.
▲
by
c0nstantine
2y ago
Thank you! Still a lot of work to do. I really like the jq style.
15.
▲
by
c0nstantine
2y ago
The grammar is underspecified. The full grammar is more complex. I guess I need just remove the current version from docs. Now it is confusing indeed. > Why is "c" not being replaced with "da"? It is all about precede
16.
▲
by
c0nstantine
2y ago
The '-g' flag is obsolete. Somehow it got into my new docs. The right way is to use '-ma' flags where '-m' is for matching the whole string and '-a' stands for all the outputs. You got the idea correc
17.
▲
by
c0nstantine
2y ago
That's true. Thank you for elaborating. There is a hidden operator of concatenation as for usual regular expressions. In the code I denote it as lower dot '.' (as in the old Thompson's implementation).
18.
▲
by
c0nstantine
2y ago
[a-z] is equivalent to 'a|b|...|z' in the normal regex language. So if we do [a-z]:[A-Z] it should be expanded to: (a|b|...|z):(A|B|...|Z) which is pretty legal in trre but has different meaning of mapping any a-z to ALL the A-Z (
19.
▲
by
c0nstantine
2y ago
Thank you for the link. I think I came across it some years ago. They implement weighted transducers. Nice tool for things like morphology from the era before the LLMs. I've implemented something similar 8 years ago: https://
20.
▲
by
c0nstantine
2y ago
I guess folks generally more interested in searching for the pattern then modifying it. > Tools like sed build a transducer around the whole automaton: s/this/that/g. That sounds reasonable. Could you provide any links on
21.
▲
by
c0nstantine
2y ago
Hey, I didn't claim it is something groundbreaking. The idea is quite old, indeed. You don not need AI or LLMs here. The sed is superior, actually. I do not cover all the functions sed provides. I think of it more like 'tr' +
22.
▲
by
c0nstantine
2y ago
Are you using MAC? For tests please try: $ make && bash test.sh with 'bash' instead. For the second part it is a bug in the README. Thank you for pointing this out! I had to be more careful before the publication. Fixed. T
23.
▲
by
c0nstantine
2y ago
Thank you for the feedback. Yes, the precedence is a question for me. Maybe I will change this. If I shift it behind concatenation there could be another problem. E.g. with non-associative : should be illegal. And I am not sure how to treat
24.
▲
by
c0nstantine
2y ago
Can't reproduce. I have the following: > echo 'cat dog' | ./trre 'c:bat|d:hog' bat hog
25.
▲
by
c0nstantine
2y ago
>> E.g. what if I want to turn xyz into zYx? echo 'zyx' | ./trre 'xy:Yz|zy:Yx' It is still a regular language. I do not introduce references. You are right in sense the `sed` is far superior editor. But here
26.
▲
by
c0nstantine
2y ago
Thank you! For the feedback and pointing to the typo. Fixed. Actually my C is very rusty and I am bit uncomfortable about this.
27.
▲
by
c0nstantine
2y ago
yeah. Transducers are very old topic. For some reason they were not connected to a specific language like regex. > wrt syntax, are you sure you want ':' to bind stronger than concatenation 'ab' ? That's something
28.
▲
by
c0nstantine
2y ago
Fair point. I agree. Now it is better to disable it. The rationale was to implement a fun operation called transducer composition. It is possible to do simple operation on strings and compose trre's like filters. But I haven't fin
29.
▲
by
c0nstantine
2y ago
Fair point. The most explicit example if you need to change something in context. For example if we need to change 'y' to 'Y' only if it occurs between x and y you would do something like this in python. pattern = r'
30.
▲
by
c0nstantine
2y ago
The second line actually is an output. I've modified the README. The last example is a typo. Fixed. Thanks!
More ›