Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know this is an old thread, but I recently ran into this same problem and was able to solve it and I figure the solution should be here in case anyone in the future runs into it. Like said above, Jython cannot deal with numpy's pre-compiled c files, but within nltk, the use of numpy is very limited and it's fairly straightforward to rewrite the affected bits of code. That's what I did, and I'm sure it's not the most computationally effective solution, but it works. This code is found in nltk.metrics.Segmentation, and I will only paste relevant code, but it will still be a little much.</p> <pre><code>def _init_mat(nrows, ncols, ins_cost, del_cost): mat = [[4.97232652e-299 for x in xrange(ncols)] for x in xrange(nrows)] for x in range(0,ncols): mat[0][x] = x * ins_cost for x in range(0, nrows): mat[x][0] = x * del_cost return mat def _ghd_aux(mat, rowv, colv, ins_cost, del_cost, shift_cost_coeff): for i, rowi in enumerate(rowv): for j, colj in enumerate(colv): shift_cost = shift_cost_coeff * abs(rowi - colj) + mat[i][j] if rowi == colj: # boundaries are at the same location, no transformation required tcost = mat[i][j] elif rowi &gt; colj: # boundary match through a deletion tcost = del_cost + mat[i][j + 1] else: # boundary match through an insertion tcost = ins_cost + mat[i + 1][j] mat[i + 1][j + 1] = min(tcost, shift_cost) </code></pre> <p>Also at the end of ghd, change the return statement to </p> <pre><code>return mat[-1][-1] </code></pre> <p>I hope this helps someone! I don't know if there are other places where this is any issue, but this is the only one that I have encountered. If there are any other issues of this sort they can be solved in the same way(using a list of lists instead of a numpy array), again, you probably lose some efficiency, but it works.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload