You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/07/31 02:14:00 UTC

[incubator-nlpcraft] branch master updated: WIP on NLPCRAFT-382.

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/master by this push:
     new 72b18af  WIP on NLPCRAFT-382.
72b18af is described below

commit 72b18af67d380102f0c2cd166e147942126399c2
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Fri Jul 30 19:13:55 2021 -0700

    WIP on NLPCRAFT-382.
---
 LICENSE                                            |  2 +-
 .../apache/nlpcraft/common/util/NCIdGenerator.java | 26 +++++++++++-----------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/LICENSE b/LICENSE
index 0d6545d..7d59ef4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -224,6 +224,6 @@ Files in src/main/resources/moby folder are released by Grady Ward into the publ
    - http://cs.sru.edu/~ddailey/whence.html
 
 File org.apache.nlpcraft.common.util.NCIdGenerator.java
-is based on https://github.com/peet/Hashids.java that is licensed under MIT license:
+is loosely based on https://github.com/peet/Hashids.java that is licensed under MIT license:
    - Copyright (C) Ivan Akimov
    - Copyright (C) Peet Goddard
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCIdGenerator.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCIdGenerator.java
index dbd2b7d..4e505fd 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCIdGenerator.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCIdGenerator.java
@@ -20,7 +20,7 @@ package org.apache.nlpcraft.common.util;
 import java.util.*;
 
 /**
- * Implementation is based on https://github.com/peet/hashids.java/blob/master/src/HashidsJava/Hashids.java
+ * Implementation is loosely based on https://github.com/peet/hashids.java/blob/master/src/HashidsJava/Hashids.java
  */
 public class NCIdGenerator {
     private static final String DEFAULT_ALPHABET = "xcS4F6h89aUbideAI7tkynuopqrXCgTE5GBKHLMjfRsz";
@@ -278,10 +278,10 @@ public class NCIdGenerator {
         StringBuilder ret = new StringBuilder();
 
         if (!alphabet.isEmpty()) {
-            List<String> alphabetArr = charArrayToStringList(alphabet.toCharArray());
+            List<String> alphaArr = charArrayToStringList(alphabet.toCharArray());
 
             if (salt == null || salt.isEmpty())
-                salt = new String(new char[]{'\0'});
+                salt = String.valueOf('\0');
 
             int[] sortArr = new int[salt.length()];
 
@@ -307,15 +307,15 @@ public class NCIdGenerator {
 
             int i = 0;
 
-            while (alphabetArr.size() > 0) {
+            while (alphaArr.size() > 0) {
                 int pos = sortArr[i];
 
-                if (pos >= alphabetArr.size())
-                    pos %= alphabetArr.size();
+                if (pos >= alphaArr.size())
+                    pos %= alphaArr.size();
 
-                ret.append(alphabetArr.get(pos));
+                ret.append(alphaArr.get(pos));
 
-                alphabetArr.remove(pos);
+                alphaArr.remove(pos);
 
                 i = ++i % sortArr.length;
             }
@@ -403,16 +403,16 @@ public class NCIdGenerator {
         Iterator<?> iter = s.iterator();
 
         if (iter.hasNext()) {
-            StringBuilder builder = new StringBuilder(s.size());
+            StringBuilder bldr = new StringBuilder(s.size());
 
-            builder.append(iter.next());
+            bldr.append(iter.next());
 
             while (iter.hasNext()) {
-                builder.append(del);
-                builder.append(iter.next());
+                bldr.append(del);
+                bldr.append(iter.next());
             }
 
-            return builder.toString();
+            return bldr.toString();
         }
         
         return "";