-
Notifications
You must be signed in to change notification settings - Fork 0
/
twika.js
212 lines (205 loc) · 4.51 KB
/
twika.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
var endsign = '(。|。|.|!|!|?|\\?|\\)|」|』|…|―|$)';
var s_endsign = '(。|。|.|!|!|?|\\?|\\)|」|』|…|―)';
/* 置換候補の正規表現と結果の辞書 */
var dictionaries = [
{
"id" : "100",
"pattern" : "(だろうか|じゃねーか|じゃねーよ|かな|でしょうか)" + endsign,
"option" : "gm",
"replace" : "じゃなイカ$2"
},
{
"id" : "101",
"pattern" : "するか",
"option" : "gm",
"replace" : "するめイカ"
},
{
"id" : "102",
"pattern" : "じゃん" + endsign,
"option" : "gm",
"replace" : "じゃなイカ$1"
},
{
"id" : "200",
"pattern" : "ありません" + endsign,
"option" : "gm",
"replace" : "ないんじゃなイカ$1"
},
{
"id" : "200",
"pattern" : "しれません|しれない" + endsign,
"option" : "gm",
"replace" : "しれないんじゃなイカ$1"
},
/* {
"id" : "300",
"pattern" : "である",
"option" : "gm",
"replace" : "でゲソ"
},*/
{
"id" : "400",
"pattern" : "いか|以下|医科|異化|烏賊|医家|伊香",
"option" : "gm",
"replace" : "イカ"
},
/* {
"id" : "500",
"pattern" : "(でした|だった)",
"option" : "gm",
"replace" : "$1ゲソ"
},*/
{
"id" : "600",
"pattern" : "ください" + endsign,
"option" : "gm",
"replace" : "くれでゲソ$1"
},
{
"id" : "700",
"pattern" : "します" + endsign,
"option" : "gm",
"replace" : "するでゲソ$1"
},
{
/* 着せます: 着せるでゲソ */
"id" : "701",
"pattern" : "せます" + endsign,
"option" : "gm",
"replace" : "せるでゲソ$1"
},
{
/* 思われます: 思われるでゲソ */
"id" : "702",
"pattern" : "れます" + endsign,
"option" : "gm",
"replace" : "れるでゲソ$1"
},
{
/* ありました: なりましたでゲソ */
"id" : "703",
"pattern" : "ありました" + endsign,
"option" : "gm",
"replace" : "あったでゲソ$1"
},
{
"id" : "704",
"pattern" : "います" + endsign,
"option" : "gm",
"replace" : "いますでゲソ$1"
},
{
"id" : "800",
"pattern" : "(でき|出来)ます" + endsign,
"option" : "gm",
"replace" : "できるでゲソ$2"
},
{
"id" : "801",
"pattern" : "(あり|有り)ます" + endsign,
"option" : "gm",
"replace" : "あるでゲソ$2"
},
{
"id" : "900",
"pattern" : "あなた|あんた|貴方|貴女|キミ",
"option" : "gm",
"replace" : "おまえ"
},
{
"id" : "901",
"pattern" : "(で|ま)すね" + endsign,
"option" : "gm",
"replace" : "$1ゲソね$2"
},
{
"id" : "902",
"pattern" : "(だ)(ね|な)" + endsign,
"option" : "gm",
"replace" : "ゲソね$3"
},
{
"id" : "903",
"pattern" : "(だ|です)よね" + endsign,
"option" : "gm",
"replace" : "でゲソね$2"
},
{
"id" : "904",
"pattern" : "ですよ" + endsign,
"option" : "gm",
"replace" : "でゲソね$1"
},
{
"id" : "1000",
"pattern" : "(で)(す|ある)" + endsign,
"option" : "gm",
"replace" : "$1ゲソ$3"
},
{
/* ないぞ: ないでゲソ
ですぞ: でゲソ */
"id" : "1001",
"pattern" : "(い|す)ぞ" + endsign,
"option" : "gm",
"replace" : "$1でゲソ$2"
},
{
/* あるんだ: あるんでゲソ
あるのだぞ: あるのでゲソ */
"id" : "1002",
"pattern" : "(ん|の)(だ|だよ|だぞ)" + endsign,
"option" : "gm",
"replace" : "$1でゲソ$3"
},
{
/* その他の文末 */
"id" : "1101",
"pattern" : "(ません|あり|なし|はず|かも|でも|だけ|こと|べし|べき|以上|万歳|方)" + endsign,
"option" : "gm",
"replace" : "$1でゲソ$2"
},
{
/* 文末 (2) */
"id" : "1102",
"pattern" : "(だ|で|だろ)" + s_endsign,
"option" : "gm",
"replace" : "でゲソ$2"
},
{
/* 文末 (3) */
"id" : "1200",
"pattern" : "でろ" + endsign,
"option" : "gm",
"replace" : "でるでゲソ$1"
},
{
/* 連続する漢字で終わる文 */
"id" : "1300",
"pattern" : "([一-龠]{2,})" + s_endsign,
"option" : "gm",
"replace" : "$1でゲソ$2"
},
{
/* 文末で */
"id" : "1500",
"pattern" : "(る|た|だ|す|い|う|く|つ|む|ぐ|ぶ|ふ|だけ|ぬ)" + s_endsign,
"option" : "gm",
"replace" : "$1でゲソ$2"
}
];
var regexpCache = [];
$('#tweeting_button').mousedown(function(){
var status = $("#status").val();
var post = "";
for(var i = 0; i < dictionaries.length; i++){
var d = dictionaries[i];
if(!(i in regexpCache)){
regexpCache[i] = new RegExp(d.pattern, d.option);
}
var r = regexpCache[i];
status = status.replace(r, d.replace);
}
$("#status").val(status);
});