Approximate search for LaTeX formulae
scattered-thoughts.net
scattered-thoughts.net
I've used a variety of spatial index trees in previous versions but this method improved perfomance by 80-100x on typical input. I think the main problem is that the equation space has an incredibly high dimension and the vast majority of pairs of formulae have no elements in common so most comparisons give you little information.
I was thinking as I was going over the article again that you could represent you formulae as trees instead of strings. This might yield more accurate/interesting distances. I recently used the PQ-gram distance[1] to compare subsets of ASTs with great success. PQ-gram is a really fast approximation of tree edit distance. I also tried using exact edit distance with the Zhang-Shasha algorithm[2], but in general the PQ-gram was so much faster the greater accuracy of ZSS didn't matter.
[1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.149.... [2] https://github.com/timtadh/zhang-shasha
Yes, thats a better way of putting it. The variance is so low that the tree always ended up very deep. I put a lot of effort into tuning bucket sizes etc but in the end it just didn't work out.
> ... you could represent you formulae as trees instead of strings ...
For some definitions of edit distance, the edit distance between two trees is equivalent to the Levenshtein distance between the in-order traversals of the trees. In any case, the tree structure of LaTeX itself tends to be quite flat and non-useful and the the tree structure of the equations themselves is hard to derive in general. ArXMLiv is working on this, among others, but its still a hard research problem. If I could get my hands on the tree structure I would be doing more sophisticated searches than edit distance, cf hoogle and uniquation.