[GitHub] lucene-solr pull request #482: LUCENE-8539: fix some typos and improve style...
Github user alessandrobenedetti commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/482#discussion_r227471350 --- Diff: lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java --- @@ -47,58 +48,65 @@ public void testStopFilt() throws IOException { assertTokenStreamContents(stream, new String[] { "Now", "The" }); } + + private void logStopwords(String name, List stopwords){ +// helper method: converts a list +log(String.format("stopword list \"%s:\"", name)); +for (int i = 0; i < stopwords.size(); i++) { + log(String.format("stopword (%d): %s ", i, stopwords.get(i))); +} +log("--"); + } /** * Test Position increments applied by StopFilter with and without enabling this option. */ - public void testStopPositons() throws IOException { + public void testStopPositions() throws IOException { +final int NUMBER_OF_TOKENS = 20; StringBuilder sb = new StringBuilder(); -ArrayList a = new ArrayList<>(); -for (int i=0; i<20; i++) { - String w = English.intToEnglish(i).trim(); - sb.append(w).append(" "); - if (i%3 != 0) a.add(w); +List stopwords = new ArrayList<>(NUMBER_OF_TOKENS); +for (int i = 0; i < NUMBER_OF_TOKENS; i++) { + String token = English.intToEnglish(i).trim(); + sb.append(token).append(' '); + if (i%3 != 0) stopwords.add(token); } log(sb.toString()); -String stopWords[] = a.toArray(new String[0]); -for (int i=0; i a0 = new ArrayList<>(); -ArrayList a1 = new ArrayList<>(); -for (int i=0; i evenStopwords = new ArrayList<>(stopwords.size()); +List oddStopwords = new ArrayList<>(stopwords.size()); +for (int i=0; i < stopwords.size(); i++) { + if (i%2 == 0) { +evenStopwords.add(stopwords.get(i)); } else { -a1.add(a.get(i)); +oddStopwords.add(stopwords.get(i)); } } -String stopWords0[] = a0.toArray(new String[0]); -for (int i=0; i
[GitHub] lucene-solr pull request #482: LUCENE-8539: fix some typos and improve style...
Github user alessandrobenedetti commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/482#discussion_r227469439 --- Diff: lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java --- @@ -47,58 +48,65 @@ public void testStopFilt() throws IOException { assertTokenStreamContents(stream, new String[] { "Now", "The" }); } + + private void logStopwords(String name, List stopwords){ +// helper method: converts a list +log(String.format("stopword list \"%s:\"", name)); +for (int i = 0; i < stopwords.size(); i++) { + log(String.format("stopword (%d): %s ", i, stopwords.get(i))); +} +log("--"); + } /** * Test Position increments applied by StopFilter with and without enabling this option. */ - public void testStopPositons() throws IOException { + public void testStopPositions() throws IOException { +final int NUMBER_OF_TOKENS = 20; StringBuilder sb = new StringBuilder(); -ArrayList a = new ArrayList<>(); -for (int i=0; i<20; i++) { - String w = English.intToEnglish(i).trim(); - sb.append(w).append(" "); - if (i%3 != 0) a.add(w); +List stopwords = new ArrayList<>(NUMBER_OF_TOKENS); +for (int i = 0; i < NUMBER_OF_TOKENS; i++) { + String token = English.intToEnglish(i).trim(); + sb.append(token).append(' '); + if (i%3 != 0) stopwords.add(token); } log(sb.toString()); -String stopWords[] = a.toArray(new String[0]); -for (int i=0; i a0 = new ArrayList<>(); -ArrayList a1 = new ArrayList<>(); -for (int i=0; i evenStopwords = new ArrayList<>(stopwords.size()); +List oddStopwords = new ArrayList<>(stopwords.size()); +for (int i=0; i < stopwords.size(); i++) { + if (i%2 == 0) { +evenStopwords.add(stopwords.get(i)); } else { -a1.add(a.get(i)); +oddStopwords.add(stopwords.get(i)); } } -String stopWords0[] = a0.toArray(new String[0]); -for (int i=0; i
[GitHub] lucene-solr pull request #482: LUCENE-8539: fix some typos and improve style...
Github user alessandrobenedetti commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/482#discussion_r227464824 --- Diff: lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java --- @@ -111,20 +119,24 @@ public void testEndStopword() throws Exception { null); } - private void doTestStopPositons(StopFilter stpf) throws IOException { -CharTermAttribute termAtt = stpf.getAttribute(CharTermAttribute.class); -PositionIncrementAttribute posIncrAtt = stpf.getAttribute(PositionIncrementAttribute.class); -stpf.reset(); -for (int i=0; i<20; i+=3) { - assertTrue(stpf.incrementToken()); - log("Token "+i+": "+stpf); - String w = English.intToEnglish(i).trim(); - assertEquals("expecting token "+i+" to be "+w,w,termAtt.toString()); - assertEquals("all but first token must have position increment of 3",i==0?1:3,posIncrAtt.getPositionIncrement()); + private void doTestStopwordsPositions(StopFilter stopfilter) throws IOException { +final int NUMBER_OF_TOKENS = 20; +final int DELTA = 3; --- End diff -- Given the fact that this was in the original code, and you just refactored, I don't like that much the fact that Delta=3 here is not a method parameter. In fact I doubt this method is really usable if the stop filter you pass is not precisely "all but divisible by 3" stop filter. I would make this method parametric to make it clearly related the numerical nature of the stop filter in input --- - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org
[GitHub] lucene-solr pull request #482: LUCENE-8539: fix some typos and improve style...
Github user alessandrobenedetti commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/482#discussion_r227462125 --- Diff: lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java --- @@ -47,58 +48,65 @@ public void testStopFilt() throws IOException { assertTokenStreamContents(stream, new String[] { "Now", "The" }); } + + private void logStopwords(String name, List stopwords){ +// helper method: converts a list +log(String.format("stopword list \"%s:\"", name)); +for (int i = 0; i < stopwords.size(); i++) { + log(String.format("stopword (%d): %s ", i, stopwords.get(i))); +} +log("--"); + } /** * Test Position increments applied by StopFilter with and without enabling this option. */ - public void testStopPositons() throws IOException { + public void testStopPositions() throws IOException { +final int NUMBER_OF_TOKENS = 20; StringBuilder sb = new StringBuilder(); --- End diff -- Maybe renaming sb -> inputText ? --- - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org
[GitHub] lucene-solr pull request #482: LUCENE-8539: fix some typos and improve style...
Github user alessandrobenedetti commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/482#discussion_r227461971 --- Diff: lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java --- @@ -47,58 +48,65 @@ public void testStopFilt() throws IOException { assertTokenStreamContents(stream, new String[] { "Now", "The" }); } + + private void logStopwords(String name, List stopwords){ +// helper method: converts a list +log(String.format("stopword list \"%s:\"", name)); +for (int i = 0; i < stopwords.size(); i++) { + log(String.format("stopword (%d): %s ", i, stopwords.get(i))); +} +log("--"); + } /** * Test Position increments applied by StopFilter with and without enabling this option. */ - public void testStopPositons() throws IOException { + public void testStopPositions() throws IOException { +final int NUMBER_OF_TOKENS = 20; StringBuilder sb = new StringBuilder(); -ArrayList a = new ArrayList<>(); -for (int i=0; i<20; i++) { - String w = English.intToEnglish(i).trim(); - sb.append(w).append(" "); - if (i%3 != 0) a.add(w); +List stopwords = new ArrayList<>(NUMBER_OF_TOKENS); --- End diff -- Maybe renaming sb -> inputText ? --- - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org
[GitHub] lucene-solr pull request #482: LUCENE-8539: fix some typos and improve style
GitHub user diegoceccarelli opened a pull request: https://github.com/apache/lucene-solr/pull/482 LUCENE-8539: fix some typos and improve style You can merge this pull request into a Git repository by running: $ git pull https://github.com/diegoceccarelli/lucene-solr LUCENE-8539 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/lucene-solr/pull/482.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #482 commit b007debb2ea995c6878c0d74385bf31951710b5a Author: Diego Ceccarelli Date: 2018-10-22T23:08:51Z LUCENE-8539: fix some typos and improve style --- - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org