KoichiYasuoka / spaCy-Thai

Dependency parser on Thai language
MIT License
24 stars 2 forks source link

Add Blackboard Treebank #2

Closed wannaphong closed 1 year ago

wannaphong commented 2 years ago

Hello. Today NECTEC released Blackboard Treebank. Can you train this corups?

Facebook post about Blackboard Treebank: https://web.facebook.com/dancearmy/posts/10158423653343284 Blackboard Treebank's bitbucket: https://bitbucket.org/kaamanita/blackboard-treebank/

KoichiYasuoka commented 2 years ago

Thank you @wannaphong for the information. Now I'm trying to convert Tree 1:

# Tree 1
#   .---<---*
#   |       |
#   |       *-------->---------.
#   |       |                  |
#   |       |                  *->-.
#   |       |                  |   |
#   |       |                  |   *---->----.
#   |       |                  |   |         |
#   |       *---R----.         |   |   .--<--*
#   |       |        |         |   |   |     |
#   |       |        *-->--.   |   |   |     *-->---.
#   |       |        |     |   |   |   |     |      |
# สุรยุทธ์  ยัน|ปฏิเสธ  ลงนาม  MOU  กับ  อียู  ไม่  กระทบ  สัมพันธ์
#  NN       VV      VV    NN   PS  NN  NG   VV     NN
1   สุรยุทธ์    สุรยุทธ์    NN  NN  _   2   HEAD    _   np
2   ยัน|ปฏิเสธ  ยัน|ปฏิเสธ  VV  VV|VV   _   0   ROOT    _   s\>np
3   ลงนาม   ลงนาม   VV  VV  _   2   SERIAL  _   s\>np/<np
4   MOU MOU NN  NN  _   3   HEAD    _   np
5   กับ กับ PS  PS  _   2   HEAD    _   s\>np\<(s\>np)/<np
6   อียู    อียู    NN  NN  _   5   HEAD    _   np
7   ไม่ ไม่ NG  NG  _   8   HEAD    _   np\<np/>(np\<np)
8   กระทบ   กระทบ   VV  VV  _   6   HEAD    _   np\<np/<np
9   สัมพันธ์    สัมพันธ์    NN  NN  _   8   HEAD    _   np

into CoNLL-U of Universal Dependencies:

1   สุรยุทธ์    สุรยุทธ์    NOUN    NCMN    _   3   nsubj   _   SpaceAfter=No
2   ยัน ยัน VERB    VACT    _   3   advcl   _   SpaceAfter=No
3   ปฏิเสธ  ปฏิเสธ  VERB    VACT    _   0   root    _   SpaceAfter=No
4   ลงนาม   ลงนาม   NOUN    NCMN    _   3   obj _   _
5   MOU MOU NOUN    NCMN    _   4   appos   _   _
6   กับ กับ ADP RPRE    _   7   case    _   SpaceAfter=No
7   อียู    อียู    NOUN    NCMN    _   3   obl _   SpaceAfter=No
8   ไม่ ไม่ PART    NEG _   9   advmod  _   SpaceAfter=No
9   กระทบ   กระทบ   VERB    VACT    _   7   acl _   SpaceAfter=No
10  สัมพันธ์    สัมพันธ์    NOUN    NCMN    _   9   obj _   SpaceAfter=No

But it seems very hard task for me...

wannaphong commented 2 years ago

Thank you @wannaphong for the information. Now I'm trying to convert Tree 1:

# Tree 1
#   .---<---*
#   |       |
#   |       *-------->---------.
#   |       |                  |
#   |       |                  *->-.
#   |       |                  |   |
#   |       |                  |   *---->----.
#   |       |                  |   |         |
#   |       *---R----.         |   |   .--<--*
#   |       |        |         |   |   |     |
#   |       |        *-->--.   |   |   |     *-->---.
#   |       |        |     |   |   |   |     |      |
# สุรยุทธ์  ยัน|ปฏิเสธ  ลงนาม  MOU  กับ  อียู  ไม่  กระทบ  สัมพันธ์
#  NN       VV      VV    NN   PS  NN  NG   VV     NN
1 สุรยุทธ์    สุรยุทธ์    NN  NN  _   2   HEAD    _   np
2 ยัน|ปฏิเสธ  ยัน|ปฏิเสธ  VV  VV|VV   _   0   ROOT    _   s\>np
3 ลงนาม   ลงนาม   VV  VV  _   2   SERIAL  _   s\>np/<np
4 MOU MOU NN  NN  _   3   HEAD    _   np
5 กับ กับ PS  PS  _   2   HEAD    _   s\>np\<(s\>np)/<np
6 อียู    อียู    NN  NN  _   5   HEAD    _   np
7 ไม่ ไม่ NG  NG  _   8   HEAD    _   np\<np/>(np\<np)
8 กระทบ   กระทบ   VV  VV  _   6   HEAD    _   np\<np/<np
9 สัมพันธ์    สัมพันธ์    NN  NN  _   8   HEAD    _   np

into CoNLL-U of Universal Dependencies:

1 สุรยุทธ์    สุรยุทธ์    NOUN    NCMN    _   3   nsubj   _   SpaceAfter=No
2 ยัน ยัน VERB    VACT    _   3   advcl   _   SpaceAfter=No
3 ปฏิเสธ  ปฏิเสธ  VERB    VACT    _   0   root    _   SpaceAfter=No
4 ลงนาม   ลงนาม   NOUN    NCMN    _   3   obj _   _
5 MOU MOU NOUN    NCMN    _   4   appos   _   _
6 กับ กับ ADP RPRE    _   7   case    _   SpaceAfter=No
7 อียู    อียู    NOUN    NCMN    _   3   obl _   SpaceAfter=No
8 ไม่ ไม่ PART    NEG _   9   advmod  _   SpaceAfter=No
9 กระทบ   กระทบ   VERB    VACT    _   7   acl _   SpaceAfter=No
10    สัมพันธ์    สัมพันธ์    NOUN    NCMN    _   9   obj _   SpaceAfter=No

But it seems very hard task for me...

ํYes, It is very hard. It's Blackboard-Treebank (thai-10 version). It has thai-20 version but It's not free.

wannaphong commented 2 years ago

I suggest you wait for the full version. (at this late oct 2021) This treebank may change.

wannaphong commented 2 years ago

@KoichiYasuoka Now, backboard treebank is available but it can download from aiforthai.in.th. I uploaded mirror file. You can download from https://github.com/wannaphong/corpus_mirror/releases/tag/blackboard

KoichiYasuoka commented 2 years ago

@wannaphong I've just built up Blackboard Treebank into single file th_blackboard.conllu introducing MWE (multiword expression) and CLS_HEAD (clausal head). However it is still far from the annotation rules of Universal Dependencies...

wannaphong commented 2 years ago

@KoichiYasuoka Now, NECTEC release Thai Link Parser. https://github.com/kaamanita/link-grammar

FB: https://web.facebook.com/dancearmy/posts/10158750221558284

KoichiYasuoka commented 1 year ago

@wannaphong I've just released deberta-base-thai-ud-head trained by th_blackboard.conllu, working with transformers 4.22.0 and ufal.chu-liu-edmonds. Please enjoy.

wannaphong commented 1 year ago

@wannaphong I've just released deberta-base-thai-ud-head trained by th_blackboard.conllu, working with transformers 4.22.0 and ufal.chu-liu-edmonds. Please enjoy.

Awesome! Thank you for your model and your dataset!

I was post about your model and dataset at https://www.facebook.com/groups/thainlp/posts/1669184650129685/.

wannaphong commented 1 year ago

@KoichiYasuoka Can you tell me about how to train the model?

KoichiYasuoka commented 1 year ago

@wannaphong I used run_qa.py for the training of head-detection. For training example, typical Question-Answering pairs for "หลายหัวดีกว่าหัวเดียว" look like this:

{ context="หลายหัวดีกว่าหัวเดียว", question="หลาย", answer="หัว" }
{ context="หลายหัวดีกว่าหัวเดียว", question="หัว", answer="ดี" }
{ context="หลายหัวดีกว่าหัวเดียว", question="ดี", answer="ดี" }
{ context="หลายหัวดีกว่าหัวเดียว", question="กว่า", answer="หัว" }
{ context="หลายหัวดีกว่าหัวเดียว", question="หัว", answer="ดี" }
{ context="หลายหัวดีกว่าหัวเดียว", question="เดียว", answer="หัว" }

In the practical point of view "หลายหัวดีกว่าหัวเดียว" includes two หัว's, so I needed to make the context [MASK]ed by the question, and to make the answer indicated by token number(s):

{ context="[MASK]หัวดีกว่าหัวเดียว", question="หลาย", answer="หัว" (2nd token) }
{ context="หลาย[MASK]ดีกว่าหัวเดียว", question="หัว", answer="ดี" (3rd token) }
{ context="หลายหัว[MASK]กว่าหัวเดียว", question="ดี", answer="[MASK]" (3rd token) }
{ context="หลายหัวดี[MASK]หัวเดียว", question="กว่า", answer="หัว" (5th token) }
{ context="หลายหัวดีกว่า[MASK]เดียว", question="หัว", answer="ดี" (3rd token) }
{ context="หลายหัวดีกว่าหัว[MASK]", question="เดียว", answer="หัว" (5th token) }
wannaphong commented 1 year ago

@wannaphong I used run_qa.py for the training of head-detection. For training example, typical Question-Answering pairs for "หลายหัวดีกว่าหัวเดียว" look like this:

{ context="หลายหัวดีกว่าหัวเดียว", question="หลาย", answer="หัว" }
{ context="หลายหัวดีกว่าหัวเดียว", question="หัว", answer="ดี" }
{ context="หลายหัวดีกว่าหัวเดียว", question="ดี", answer="ดี" }
{ context="หลายหัวดีกว่าหัวเดียว", question="กว่า", answer="หัว" }
{ context="หลายหัวดีกว่าหัวเดียว", question="หัว", answer="ดี" }
{ context="หลายหัวดีกว่าหัวเดียว", question="เดียว", answer="หัว" }

In the practical point of view "หลายหัวดีกว่าหัวเดียว" includes two หัว's, so I needed to make the context [MASK]ed by the question, and to make the answer indicated by token number(s):

{ context="[MASK]หัวดีกว่าหัวเดียว", question="หลาย", answer="หัว" (2nd token) }
{ context="หลาย[MASK]ดีกว่าหัวเดียว", question="หัว", answer="ดี" (3rd token) }
{ context="หลายหัว[MASK]กว่าหัวเดียว", question="ดี", answer="[MASK]" (3rd token) }
{ context="หลายหัวดี[MASK]หัวเดียว", question="กว่า", answer="หัว" (5th token) }
{ context="หลายหัวดีกว่า[MASK]เดียว", question="หัว", answer="ดี" (3rd token) }
{ context="หลายหัวดีกว่าหัว[MASK]", question="เดียว", answer="หัว" (5th token) }

Thank you!