-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphrase_level_annotations.vim
More file actions
46 lines (32 loc) · 1.34 KB
/
phrase_level_annotations.vim
File metadata and controls
46 lines (32 loc) · 1.34 KB
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
map zn :py3 make_negative()<CR>
map zp :py3 make_positive()<CR>
map zq :py3 clear_sentiment()<CR>
py3 << EOF
def column_of(t):
header_vec = vim.current.buffer[0].strip().split("\t")
index_mapping = { header: index for index, header in enumerate(header_vec) }
return index_mapping[t]
def clear_sentiment():
import vim
index_of_sentiment_orientation = column_of("sentiment_orientation")
(row, col) = vim.current.window.cursor
lineVec = vim.current.buffer[row - 1].split("\t")
lineVec[index_of_sentiment_orientation] = ""
vim.current.buffer[row - 1] = "\t".join(lineVec)
def make_negative():
import vim
index_of_text = column_of("text")
index_of_sentiment_orientation = column_of("sentiment_orientation")
(row, col) = vim.current.window.cursor
lineVec = vim.current.buffer[row - 1].split("\t")
lineVec[index_of_sentiment_orientation] = "neg"
vim.current.buffer[row - 1] = "\t".join(lineVec)
def make_positive():
import vim
index_of_text = column_of("text")
index_of_sentiment_orientation = column_of("sentiment_orientation")
(row, col) = vim.current.window.cursor
lineVec = vim.current.buffer[row - 1].split("\t")
lineVec[index_of_sentiment_orientation] = "pos"
vim.current.buffer[row - 1] = "\t".join(lineVec)
EOF