{"record":{"id":"4e5d3061a38b28b1","repo":"stanfordnlp/CoreNLP","slug":"phrasetext-not-added","errorCode":null,"errorMessage":"${phraseText} not added","messagePattern":"(.+?) not added","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java","lineNumber":452,"sourceCode":"                addPhrase(newMap, oldphrase, i+1);\n              } else  {\n                throw new RuntimeException(\"Unexpected class in list \" + obj.getClass() + \" while converting list to map\");\n              }\n            }\n            tree.put(word,newMap);\n          }\n        }\n      } else {\n        throw new RuntimeException(\"Unexpected class in list \" + node.getClass() + \" while adding word \"\n                + i + \"(\" + word + \") in phrase \" + phraseText);\n      }\n      if (phraseAdded) {\n        break;\n      }\n    }\n    if (!phraseAdded) {\n      if (wordList.size() == 0) {\n        log.warn(phraseText + \" not added\");\n      } else {\n        Phrase oldphrase = (Phrase) tree.get(PHRASE_END);\n        if (oldphrase != null) {\n          int matchedTokenEnd = checkWordListMatch(\n                  oldphrase, wordList, 0, wordList.size(), wordList.size(), true);\n          if (matchedTokenEnd >= 0) {\n            oldPhraseNewFormAdded = oldphrase.addForm(phraseText);\n          } else {\n            // create list with this phrase and other and put it here\n            Phrase newphrase = new Phrase(wordList, phraseText, tag, phraseData);\n            List<Phrase> list = new ArrayList<>(2);\n            list.add(oldphrase);\n            list.add(newphrase);\n            tree.put(PHRASE_END, list);\n            newPhraseAdded = true;\n          }\n        } else {\n          Phrase newphrase = new Phrase(wordList, phraseText, tag, phraseData);","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java#L434-L470","documentation":"PhraseTable.addPhrase inserts a phrase into a trie. If after trying all insertion strategies nothing was added and the token list is empty (the phrase produced no words), a warning '<phraseText> not added' is logged. Non-empty duplicate phrases are handled separately via the oldphrase branch.","triggerScenarios":"Calling addPhrase with a phraseText that normalizes/splits to zero tokens (empty string, only delimiters/whitespace), so wordList.size()==0 and no trie node can be created.","commonSituations":"Loading a phrase file with blank lines or lines whose first field is empty after splitting; passing empty strings programmatically from user input.","solutions":["Skip blank/whitespace-only lines when loading the phrase file.","Trim and validate phraseText before calling addPhrase.","Sanitize the source file so each record has a non-empty first field."],"exampleFix":"// before\nfor (String line : lines) table.addPhrase(line, null, null);\n// after\nfor (String line : lines) {\n  if (line == null || line.trim().isEmpty()) continue;\n  table.addPhrase(line, null, null);\n}","handlingStrategy":"validation","validationCode":"if (phraseText == null || phraseText.trim().isEmpty()) {\n  return; // nothing to add\n}","typeGuard":"static boolean isBlank(String s) { return s == null || s.trim().isEmpty(); }","tryCatchPattern":null,"preventionTips":["Filter blank lines when loading phrase files.","Trim phrases before insertion.","Log and count skipped lines at load time."],"tags":["java","tokensregex","phrase-table","input-validation"],"backgroundTag":"empty-required-field","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}