You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "Prachi Prakash (JIRA)" <ji...@apache.org> on 2017/12/31 11:29:00 UTC
[jira] [Created] (OPENNLP-1176)
opennlp.tools.ngram.NGramGenerator.java
Prachi Prakash created OPENNLP-1176:
---------------------------------------
Summary: opennlp.tools.ngram.NGramGenerator.java
Key: OPENNLP-1176
URL: https://issues.apache.org/jira/browse/OPENNLP-1176
Project: OpenNLP
Issue Type: Question
Reporter: Prachi Prakash
Priority: Trivial
Hello All,
I am new to opennlp and was looking to NGramGenerator.java where I found this piece of code which creates a list of n-grams from a list of words or characters.
for (int i = 0; i < input.size() - (n - 1); i++) {
final StringBuilder sb = new StringBuilder();
for (int x = i; x < (n + i); x++) {
sb.append(input.get(x));
sb.append(separator);
}
String gram = sb.toString();
gram = gram.substring(0, gram.lastIndexOf(separator));
outGrams.add(gram);
}
which can be modified to
for (int i = 0; i < input.size() - (n - 1); i++) {
final StringBuilder sb = new StringBuilder();
for (int x = i; x < (n + i); x++) {
sb.append(input.get(x));
sb.append(separator);
}
String gram = sb.toString();
gram = gram.substring(0, gram.lastIndexOf(separator));
outGrams.add(gram);
}
which will save some comparison can anyone please guide this is not being done.
Thanks,
Prachi Prakash
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)