You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by "rzo1 (via GitHub)" <gi...@apache.org> on 2026/08/04 13:02:33 UTC
Re: [PR] OPENNLP-1885: Pure-Java SentencePiece inference with exact original-text spans (opennlp-subword) (opennlp)
rzo1 commented on code in PR #1165:
URL: https://github.com/apache/opennlp/pull/1165#discussion_r3712745997
##########
opennlp-extensions/opennlp-subword/src/main/java/opennlp/subword/sentencepiece/DoubleArrayTrie.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package opennlp.subword.sentencepiece;
+
+import java.io.Serializable;
+
+/**
+ * Read-only lookup over a serialized Darts-clone double-array trie, the dictionary format
+ * embedded in a SentencePiece model's precompiled character map.
+ *
+ * <p>Each unit is one little-endian 32-bit word encoding a label, an offset to the unit's
+ * children, and a leaf flag; traversal XORs the offset with the next key byte. Only the longest
+ * prefix match is needed here, so this walks the byte key once and remembers the last accepting
+ * state. Out-of-range unit references, which a well-formed trie never produces, fail loudly
+ * rather than reading arbitrary memory.</p>
+ *
+ * @see <a href="https://github.com/s-yata/darts-clone">Darts-clone</a>
Review Comment:
This is BSD-2 licensed. What of this impl is a copy? Is this a re-impl from the repo? Plz ellaborate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opennlp.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org