Skip to content

fix "out of bounds" #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2011
Merged

fix "out of bounds" #2

merged 1 commit into from
May 20, 2011

Conversation

archimag
Copy link
Contributor

@froydnj
Copy link
Owner

froydnj commented Apr 13, 2011

I think this is mostly OK; I don't remember a lot of the details of the algorithm, though. Comments coming inline on the diff itself.

:length 0)

(defun compute-lcs* (original modified)
(declare (optimize (debug 3)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This declaration should be removed.

@froydnj
Copy link
Owner

froydnj commented Apr 13, 2011

As I was commenting, I took a closer look at the code...does all this really stem from the initial creation of FP sharing a snake between all elements of FP? If so, wouldn't it be easier to simply initialize FP differently, by dropping the :INITIAL-ELEMENT and doing:

(loop for i from 0 below (length fp)
do (setf (aref fp i) (make-instance 'snake ...)))

? Like I said, I don't remember all the details of the algorithm, but looking at the code, my use of :INITIAL-ELEMENT there is very suspect.

@archimag
Copy link
Contributor Author

Well, I rewrote the code.

Unfortunately, I'm not familiar with this algorithm and has not had the time
for understand. But I found the code in other language (C)​​ for compare and found
no significant difference with you code. So I made ​​a change that just work.

I use a diff for: http://cliki2.lisper.ru/history/RESTAS/3470385331-3488861177,
but encountered an error: http://cliki2.lisper.ru/history/RESTAS/3470385331-3511295325.
With my patch everything works fine.

P.S. I apologize for my terrible english.

@archimag
Copy link
Contributor Author

I has united my changes on this issue in one commit

@archimag
Copy link
Contributor Author

archimag commented May 3, 2011

I sync this branch with last changes.

@archimag
Copy link
Contributor Author

Hi. I would not want to seem intrusive, but is now important for me to get result on this issue. You could not dedicate this issue a little bit of his time? :)

@froydnj
Copy link
Owner

froydnj commented May 19, 2011

Hi, sorry for not responding. I'm not completely convinced that this can't be solved by simply initializing all the members of the FP array with their own instance of a SNAKE, rather than sharing one between them all. That should be an equivalent solution to what you're doing, but be somewhat clearer. Could you try that solution instead?

@archimag
Copy link
Contributor Author

Oh, I looked at solutions in other languages ​​and found that this bug can be corrected very simple manner.

@froydnj
Copy link
Owner

froydnj commented May 20, 2011

OK, so I agree that fix is quite simple. :) But why does that fix things? Why 3 and not 4, or 2?

@archimag
Copy link
Contributor Author

Yes, I know it does not very impressive, but I found 3 in the Python implementation and test it on their data. 1 or 2 is not enough if the original and modified texts do not have common parts. 3 was sufficient in all cases.

@froydnj
Copy link
Owner

froydnj commented May 20, 2011

Do you have a reference for the Python implementation? I know Python's standard library uses a different algorithm.

Honestly, the code was copied from other implementations originally, so I'm not opposed to a bit more copying. I'd just like to have a shot at understanding why we're copying this bit.

@archimag
Copy link
Contributor Author

https://github.com/cubicdaiya/onp/blob/master/python/onp.py

In addition, this project have the implementation of this algorithm and the other languages.

@froydnj
Copy link
Owner

froydnj commented May 20, 2011

Well, they have a lot of helpful comments, don't they? Pulling; thanks for the fix.

froydnj added a commit that referenced this pull request May 20, 2011
@froydnj froydnj merged commit 4d7075f into froydnj:master May 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants