Skip to content

Commit

Permalink
OPENNLP-421 - Refactoring, renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
rzo1 committed Dec 18, 2023
1 parent 11526c5 commit a9257d1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public CHMStringDeduplicator(double prob) {
* {@inheritDoc}
*/
@Override
public String intern(String s) {
public String intern(String sample) {
if (ThreadLocalRandom.current().nextInt() > prob) {
return s;
return sample;
}
final String exist = map.putIfAbsent(s, s);
return (exist == null) ? s : exist;
final String exist = map.putIfAbsent(sample, sample);
return (exist == null) ? sample : exist;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public CHMStringInterner() {
* {@inheritDoc}
*/
@Override
public String intern(String s) {
final String exist = map.putIfAbsent(s, s);
return (exist == null) ? s : exist;
public String intern(String sample) {
final String exist = map.putIfAbsent(sample, sample);
return (exist == null) ? sample : exist;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public HMStringInterner() {
* {@inheritDoc}
*/
@Override
public String intern(String s) {
final String exist = map.putIfAbsent(s, s);
return (exist == null) ? s : exist;
public String intern(String sample) {
final String exist = map.putIfAbsent(sample, sample);
return (exist == null) ? sample : exist;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
import opennlp.tools.commons.ThreadSafe;

/**
* A {@link StringInterner} implementation based on {@code String.intern()}.
* A {@link StringInterner} implementation based on {@code String.intern()}. Strings interned via
* this implementation are put into PermGen space. If needed, the PermGen memory can be increased by
* the JVM argument {@code -XX:MaxPermSize}.
* <p>
* Using this {@link StringInterner} brings back the default behaviour of OpenNLP before version
* {@code 2.3.2}. You can use it by setting the system property {@code }
* </p>
*/
@Internal
@ThreadSafe
Expand All @@ -29,7 +35,7 @@ class JvmStringInterner implements StringInterner {
* {@inheritDoc}
*/
@Override
public String intern(String s) {
return s.intern();
public String intern(String sample) {
return sample.intern();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NoOpStringInterner implements StringInterner {
* {@inheritDoc}
*/
@Override
public String intern(String s) {
return s;
public String intern(String sample) {
return sample;
}
}

0 comments on commit a9257d1

Please sign in to comment.