emorynlp / nlp4j-old

NLP tools developed by Emory University.
Other
60 stars 19 forks source link

How to speed up the dependency parser by reworking one method #35

Closed benson-basis closed 8 years ago

benson-basis commented 8 years ago

Changing this method in ColumnMajorVector got the time on 10MB of English wikipedia from:

Decode: 0:04:08.748

to

Decode: 0:03:17.926

    @Override
    public void addScores(SparseVector x, float[] scores)
    {
        List<SparseItem> itemVector = x.getVector();
        int featureSize = getFeatureSize();
        itemVector.stream().filter(p -> p.getIndex() < featureSize)
                .forEach(p -> {
                    int index = p.getIndex() * label_size;
                    for (int i = 0; i < scores.length; i++) {
                        scores[i] += get(index++) * p.getValue();
                    }
                });
    }
jdchoi77 commented 8 years ago

Could you please make a pull request with your change? I'll review and merge the change. Thanks.

benson-basis commented 8 years ago

I added the PR to the core project where the class lives, so I'm closing this issue.