branch develop updated (e9f2ed5 -> 76578df)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from e9f2ed5 fixes #7922 dot not have word with less than 3 letters in cloud tag new 76578df refs #7922 extract cleanly map value comparator class The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 76578dfa2a197df1dcffb629f193ed4e023aa066 Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 29 13:09:36 2016 +0100 refs #7922 extract cleanly map value comparator class Summary of changes: .../services/StringLongMapValueComparator.java | 25 ++++++++++++++++++++++ .../indexation/TransverseIndexationService.java | 21 ++---------------- 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 coselmar-rest/src/main/java/fr/ifremer/coselmar/services/StringLongMapValueComparator.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 76578dfa2a197df1dcffb629f193ed4e023aa066 Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 29 13:09:36 2016 +0100 refs #7922 extract cleanly map value comparator class --- .../services/StringLongMapValueComparator.java | 25 ++++++++++++++++++++++ .../indexation/TransverseIndexationService.java | 21 ++---------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/StringLongMapValueComparator.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/StringLongMapValueComparator.java new file mode 100644 index 0000000..0482b45 --- /dev/null +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/StringLongMapValueComparator.java @@ -0,0 +1,25 @@ +package fr.ifremer.coselmar.services; + +import java.util.Comparator; +import java.util.Map; + +/** + * @author ymartel (martel@codelutin.com) + */ +public class StringLongMapValueComparator implements Comparator<String> { + Map<String, Long> base; + + public StringLongMapValueComparator(Map<String, Long> base) { + this.base = base; + } + + // Note: this comparator imposes orderings that are inconsistent with + // equals. + public int compare(String a, String b) { + if (base.get(a) >= base.get(b)) { + return -1; + } else { + return 1; + } // returning 0 would merge keys + } +} diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/TransverseIndexationService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/TransverseIndexationService.java index c193ed9..db6ae9b 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/TransverseIndexationService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/TransverseIndexationService.java @@ -26,6 +26,7 @@ package fr.ifremer.coselmar.services.indexation; import fr.ifremer.coselmar.beans.QuestionBean; import fr.ifremer.coselmar.services.CoselmarSimpleServiceSupport; +import fr.ifremer.coselmar.services.StringLongMapValueComparator; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.Term; import org.apache.lucene.misc.HighFreqTerms; @@ -103,7 +104,7 @@ public class TransverseIndexationService extends CoselmarSimpleServiceSupport { } indexReader.close(); - MapValueComparator valueComparator = new MapValueComparator(topWords); + StringLongMapValueComparator valueComparator = new StringLongMapValueComparator(topWords); TreeMap<String, Long> sortedResult = new TreeMap(valueComparator); sortedResult.putAll(topWords); @@ -119,22 +120,4 @@ public class TransverseIndexationService extends CoselmarSimpleServiceSupport { return result; } -} - -class MapValueComparator implements Comparator<String> { - Map<String, Long> base; - - public MapValueComparator(Map<String, Long> base) { - this.base = base; - } - - // Note: this comparator imposes orderings that are inconsistent with - // equals. - public int compare(String a, String b) { - if (base.get(a) >= base.get(b)) { - return -1; - } else { - return 1; - } // returning 0 would merge keys - } } \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm