Skip to content

A question about adding a custom dict. #675

Closed Answered by wannaphong
kmining asked this question in Q&A
Discussion options

You must be logged in to vote
  1. No, attacut can't apply a custom dict. The custom_dict can be provided as an argument only for newmm, longest, and deepcut engine. https://pythainlp.github.io/docs/3.0/api/tokenize.html#pythainlp.tokenize.word_tokenize
  2. Now, POS can't apply a custom dict. You can create new function.
def pos_tag_new(pythai_tag,custom):
 _temp = []
 for w,t in pythai_tag:
  if w in custom.keys():
   t = custom[w]
  _temp.append((w,t))
 return _temp

custom = {"ทะเลาะกัน":"Noun"}
tag = [("พวกเรา","Noun"),("ทะเลาะกัน","Verb")]
print(pos_tag_new(tag ,custom))
# [('พวกเรา', 'Noun'), ('ทะเลาะกัน', 'Noun')]

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kmining
Comment options

@kmining
Comment options

@bact
Comment options

Answer selected by bact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants