We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent de84655 commit 4335d55Copy full SHA for 4335d55
hanlp/utils/span_util.py
@@ -80,3 +80,18 @@ def bmes_of(sentence, segmented):
80
chars = list(sentence)
81
tags = ['S'] * len(chars)
82
return chars, tags
83
+
84
85
+def iobes_to_bilou(src, dst):
86
+ with open(src) as src, open(dst, 'w') as out:
87
+ for line in src:
88
+ line = line.strip()
89
+ if not line:
90
+ out.write('\n')
91
+ continue
92
+ word, tag = line.split('\t')
93
+ if tag.startswith('E-'):
94
+ tag = 'L-' + tag[2:]
95
+ elif tag.startswith('S-'):
96
+ tag = 'U-' + tag[2:]
97
+ out.write(f'{word}\t{tag}\n')
0 commit comments