Skip to content

Commit

Permalink
Merge branch 'main' of github.com:a-ejiri/open_jtalk into 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Aug 5, 2024
2 parents 33d2eb6 + eedc127 commit 213b605
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
13 changes: 9 additions & 4 deletions src/njd_set_accent_phrase/njd_set_accent_phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void njd_set_accent_phrase(NJD * njd)

/* Rule 19 */
if (strcmp(NJDNode_get_pos(node), NJD_SET_ACCENT_PHRASE_MEISHI) == 0 && strcmp(NJDNode_get_pos_group1(node), NJD_SET_ACCENT_PHRASE_HIJIRITSU) == 0) {
if (strcmp(NJDNode_get_pos_group1(node->prev), NJD_SET_ACCENT_PHRASE_JIRITSU) == 0 || strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_JODOUSHI) == 0
if (strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_JODOUSHI) == 0
|| strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_RENTAISHI) == 0
|| strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_JOSHI) == 0
|| strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_DOUSHI) == 0 )
Expand All @@ -255,10 +255,15 @@ void njd_set_accent_phrase(NJD * njd)

/* Rule 21 */
if (strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_MEISHI) == 0
&& strcmp(NJDNode_get_pos_group1(node->prev), NJD_SET_ACCENT_PHRASE_HIJIRITSU) == 0
&& strcmp(NJDNode_get_pos(node), NJD_SET_ACCENT_PHRASE_MEISHI) == 0)
&& (strcmp(NJDNode_get_pos_group1(node->prev), NJD_SET_ACCENT_PHRASE_HIJIRITSU) == 0 ||strcmp(NJDNode_get_pos_group1(node->prev), NJD_SET_ACCENT_PHRASE_DAIMEISHI) == 0)
&& (strcmp(NJDNode_get_pos(node), NJD_SET_ACCENT_PHRASE_MEISHI) == 0 && strcmp(NJDNode_get_pos(node), NJD_SET_ACCENT_PHRASE_IPPAN) == 0))
NJDNode_set_chain_flag(node, 0);

/* Rule 22 */
if (strcmp(NJDNode_get_pos(node->prev), NJD_SET_ACCENT_PHRASE_KANDOUSHI) == 0)
NJDNode_set_chain_flag(node, 0);
if (strcmp(NJDNode_get_pos(node), NJD_SET_ACCENT_PHRASE_KANDOUSHI) == 0)
NJDNode_set_chain_flag(node, 0);

}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/njd_set_accent_phrase/njd_set_accent_phrase_rule_utf_8.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,21 @@ NJD_SET_ACCENT_PHRASE_RULE_H_START;
Rule 16 「*,*,*,姓」の後の「*,*,*,名」は別のアクセント句に
Rule 17 「名詞」の後の「*,*,*,名」は別のアクセント句に
Rule 18 「*,接尾」は前にくっつける
Rule 19 「名詞,非自立」は「動詞」or「*,自立」or「助動詞,体言接続」or 「助詞」or「連体詞」に接続する場合に前にくっつける
Rule 19 「名詞,非自立」は「動詞」or「助動詞,体言接続」or 「助詞」or「連体詞」に接続する場合に前にくっつける
Rule 20 「固有名詞」は前とくっつけない
Rule 21 「名詞,非自立」の後の「名詞」は別のアクセント句に
Rule 21 「名詞,非自立」or「名詞,代名詞」の後の「名詞,一般」は別のアクセント句に
Rule 22 「感動詞」は単独のアクセントに
*/

#define NJD_SET_ACCENT_PHRASE_MEISHI "名詞"
#define NJD_SET_ACCENT_PHRASE_DAIMEISHI "代名詞"
#define NJD_SET_ACCENT_PHRASE_KEIYOUSHI "形容詞"
#define NJD_SET_ACCENT_PHRASE_DOUSHI "動詞"
#define NJD_SET_ACCENT_PHRASE_FUKUSHI "副詞"
#define NJD_SET_ACCENT_PHRASE_SETSUZOKUSHI "接続詞"
#define NJD_SET_ACCENT_PHRASE_RENTAISHI "連体詞"
#define NJD_SET_ACCENT_PHRASE_JODOUSHI "助動詞"
#define NJD_SET_ACCENT_PHRASE_KANDOUSHI "感動詞"
#define NJD_SET_ACCENT_PHRASE_JOSHI "助詞"
#define NJD_SET_ACCENT_PHRASE_KIGOU "記号"
#define NJD_SET_ACCENT_PHRASE_KOYUU_MEISHI "固有名詞"
Expand All @@ -90,6 +93,7 @@ NJD_SET_ACCENT_PHRASE_RULE_H_START;
#define NJD_SET_ACCENT_PHRASE_SETSUBI "接尾"
#define NJD_SET_ACCENT_PHRASE_JIRITSU "自立"
#define NJD_SET_ACCENT_PHRASE_HIJIRITSU "非自立"
#define NJD_SET_ACCENT_PHRASE_IPPAN "一般"
#define NJD_SET_ACCENT_PHRASE_RENYOU "連用"
#define NJD_SET_ACCENT_PHRASE_SETSUZOKUJOSHI "接続助詞"
#define NJD_SET_ACCENT_PHRASE_SAHEN_SETSUZOKU "サ変接続"
Expand Down
14 changes: 8 additions & 6 deletions src/njd_set_accent_type/njd_set_accent_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ void njd_set_accent_type(NJD * njd)
char rule[MAXBUFLEN];
int add_type = 0;
int mora_size = 0;
int top_acc = 0;
int top_mora_size = 0;

if (njd == NULL || njd->head == NULL)
return;
Expand All @@ -153,12 +155,17 @@ void njd_set_accent_type(NJD * njd)
/* store the top node */
top_node = node;
mora_size = 0;
top_acc = NJDNode_get_acc(node);
top_mora_size = NJDNode_get_mora_size(node);

} else if (node->prev != NULL && NJDNode_get_chain_flag(node) == 1) {
/* get accent change type */
get_rule(NJDNode_get_chain_rule(node), NJDNode_get_pos(node->prev), rule, &add_type);

/* change accent type */
if (strcmp(rule, "*") == 0) { /* no chnage */
if (strcmp(NJDNode_get_chain_rule(top_node), "P2") == 0 && top_acc != 0 && top_mora_size > top_acc) {
NJDNode_set_acc(top_node, top_acc);
} else if (strcmp(rule, "*") == 0) { /* no chnage */
} else if (strcmp(rule, "F1") == 0) { /* for ancillary word */
} else if (strcmp(rule, "F2") == 0) {
if (NJDNode_get_acc(top_node) == 0)
Expand All @@ -184,11 +191,6 @@ void njd_set_accent_type(NJD * njd)
NJDNode_set_acc(top_node, 0);
else
NJDNode_set_acc(top_node, mora_size + NJDNode_get_acc(node));
} else if (strcmp(rule, "P2") == 0) {
if (NJDNode_get_acc(node) == 0)
NJDNode_set_acc(top_node, mora_size + 1);
else
NJDNode_set_acc(top_node, mora_size + NJDNode_get_acc(node));
} else if (strcmp(rule, "P6") == 0) {
NJDNode_set_acc(top_node, 0);
} else if (strcmp(rule, "P14") == 0) {
Expand Down

0 comments on commit 213b605

Please sign in to comment.