add Names exceptions
This commit is contained in:
@@ -3,6 +3,13 @@
|
|||||||
(var libPath (Prelude.libPath "bad-nlp"))
|
(var libPath (Prelude.libPath "bad-nlp"))
|
||||||
(var namesPath (joinPath libPath "name-database"))
|
(var namesPath (joinPath libPath "name-database"))
|
||||||
|
|
||||||
|
(var :Map<String,Bool> notNames (for notName [
|
||||||
|
"he" // This is in the name database.
|
||||||
|
"she"
|
||||||
|
] =>notName true))
|
||||||
|
|
||||||
|
(var :Map<String,Bool> yesNames (new Map))
|
||||||
|
|
||||||
(function loadFilesForToken [:String token]
|
(function loadFilesForToken [:String token]
|
||||||
(let [firstLetter (token.charAt 0)
|
(let [firstLetter (token.charAt 0)
|
||||||
firstTwoLetters (token.substr 0 2)
|
firstTwoLetters (token.substr 0 2)
|
||||||
@@ -24,7 +31,10 @@
|
|||||||
(function isName [:String token]
|
(function isName [:String token]
|
||||||
(let [token (token.toLowerCase)]
|
(let [token (token.toLowerCase)]
|
||||||
(loadFilesForToken token)
|
(loadFilesForToken token)
|
||||||
(loadedNames.exists token)))
|
(or (yesNames.exists token)
|
||||||
|
(and
|
||||||
|
(loadedNames.exists token)
|
||||||
|
!(notNames.exists token)))))
|
||||||
|
|
||||||
(function containsName [:String text]
|
(function containsName [:String text]
|
||||||
(doFor token (Util.splitTokens text)
|
(doFor token (Util.splitTokens text)
|
||||||
|
|||||||
Reference in New Issue
Block a user