Skip to content

nylqd/word_filtering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

word_filtering

Word filtering demo implement by dfa and trie in Python

dfa

example of dfa while word list is 敏感词 用例 test case tea 敏感

{
 { 敏 : False
	 { 感 : True
		 { 词 : True
		 }
	 }
 }
 { 用 : False
	 { 例 : True
	 }
 }
 { t : False
	 { e : False
		 { s : False
			 { t : True
			 }
		 }
		 { a : True
		 }
	 }
 }
 { c : False
	 { a : False
		 { s : False
			 { e : True
			 }
		 }
	 }
 }
}

trie

example of dfa while word list is 敏感词 用例 test case tea 敏感

{
 { 敏 : None
	 { 感 : 敏感
		 { 词 : 敏感词
		 }
	 }
 }
 { 用 : None
	 { 例 : 用例
	 }
 }
 { t : None
	 { e : None
		 { s : None
			 { t : test
			 }
		 }
		 { a : tea
		 }
	 }
 }
 { c : None
	 { a : None
		 { s : None
			 { e : case
			 }
		 }
	 }
 }
}

About

word filtering demo implement by dfa and trie

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages