forked from dwks/kaldi-grammar-main
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tformat.py
71 lines (46 loc) · 1.6 KB
/
tformat.py
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
# This file is part of Aenea
#
# Aenea is free software: you can redistribute it and/or modify it under
# the terms of version 3 of the GNU Lesser General Public License as
# published by the Free Software Foundation.
#
# Aenea is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with Aenea. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (2014) Alex Roper
# Alex Roper <[email protected]>
def format_snakeword(text):
formatted = text[0][0].upper()
formatted += text[0][1:]
formatted += ('_' if len(text) > 1 else '')
formatted += format_score(text[1:])
return formatted
def format_score(text):
return '_'.join(text)
def format_camel(text):
return text[0] + ''.join([word[0].upper() + word[1:] for word in text[1:]])
def format_proper(text):
return ''.join(word.capitalize() for word in text)
def format_relpath(text):
return '/'.join(text)
def format_abspath(text):
return '/' + format_relpath(text)
def format_scoperesolve(text):
return '::'.join(text)
def format_jumble(text):
return ''.join(text)
def format_dotword(text):
return '.'.join(text)
def format_dashword(text):
return '-'.join(text)
def format_natword(text):
return ' '.join(text)
def format_broodingnarrative(text):
return ''
def format_sentence(text):
return ' '.join([text[0].capitalize()] + text[1:])