tscripter 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/tscripter/version.rb +1 -1
- data/lib/tscripter.rb +45 -12
- data/test_input.txt +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07b2b5f211bd76bacfce348ca69be7b641dd7163
|
4
|
+
data.tar.gz: 10456f0151e1d6e577628060c08ceb8901190039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1bd2a76d12c8a504fc198aa402efd5f7fdf768c377d73bc517b8752f8ab886cd6b5a34fa1542f68dd2d6d17587173836b86c69e224ad7758baa363a6c0d9bd2
|
7
|
+
data.tar.gz: b989478276db9c255961944df33f551f52a3c1ce17ec7b0d61f537bf6000ecf54de3d9c6563d7678b15bd7abe78785d76a1dcbd23d8fd710f38f0ff5c8a8a57e
|
data/README.md
CHANGED
@@ -4,10 +4,12 @@ This gem edits transcript files, given that they are in the expected format.
|
|
4
4
|
|
5
5
|
Current features:
|
6
6
|
- Prepends alternating IDs to spoken lines
|
7
|
-
|
8
|
-
Planned features:
|
9
7
|
- Detect spoken lines that start with stage directions
|
10
8
|
- Implement notation for consecutive lines by the same speaker
|
9
|
+
- If a line starts with `^`, then the speaker is the same as the previous line
|
10
|
+
- The pattern `*i 00:00` (where 00:00 is any timestamp) is replaced with `inaudible [00:00]
|
11
|
+
|
12
|
+
Planned features:
|
11
13
|
- Accept multiple filenames
|
12
14
|
- Accept wildcard filenames
|
13
15
|
|
data/lib/tscripter/version.rb
CHANGED
data/lib/tscripter.rb
CHANGED
@@ -4,10 +4,10 @@ require "tscripter/version"
|
|
4
4
|
module Tscripter
|
5
5
|
class Runner
|
6
6
|
def go
|
7
|
-
puts(go_with_args(ARGV))
|
7
|
+
puts(go_with_args(*ARGV))
|
8
8
|
end
|
9
9
|
|
10
|
-
def go_with_args(args)
|
10
|
+
def go_with_args(*args)
|
11
11
|
if filename = args[0]
|
12
12
|
file_basename = File.basename(filename, File.extname(filename))
|
13
13
|
id1 = args[1]
|
@@ -33,25 +33,58 @@ module Tscripter
|
|
33
33
|
|
34
34
|
def generate_edited_text(text, id1, id2)
|
35
35
|
edited_text = ""
|
36
|
-
|
36
|
+
ids = [id1, id2]
|
37
|
+
count = 0
|
37
38
|
|
38
|
-
text.split("\n").each do |line
|
39
|
-
|
40
|
-
edited_text << "#{line}\n"
|
41
|
-
next
|
42
|
-
end
|
39
|
+
text.split("\n").each do |line|
|
40
|
+
curr_id = ids[count % ids.length]
|
43
41
|
|
44
|
-
if
|
45
|
-
|
42
|
+
if line[0] == "["
|
43
|
+
if /^\[.*\].*\w+/ =~ line
|
44
|
+
edited_text << process_line(curr_id, line)
|
45
|
+
count += 1
|
46
|
+
else
|
47
|
+
edited_text << "#{line}\n"
|
48
|
+
end
|
49
|
+
elsif line.strip == ""
|
50
|
+
edited_text << "#{line}\n"
|
51
|
+
elsif line[0] == "^"
|
52
|
+
curr_id = ids[(count % ids.length) - 1]
|
53
|
+
edited_text << process_line(curr_id, line)
|
46
54
|
else
|
47
|
-
edited_text <<
|
55
|
+
edited_text << process_line(curr_id, line)
|
56
|
+
count += 1
|
48
57
|
end
|
49
58
|
|
50
|
-
|
59
|
+
# edited_text << "\n"
|
51
60
|
end
|
52
61
|
|
53
62
|
edited_text
|
54
63
|
end
|
55
64
|
|
65
|
+
private
|
66
|
+
|
67
|
+
def process_line(id, line)
|
68
|
+
line = remove_markup(line)
|
69
|
+
line = add_inaudible_notation(line)
|
70
|
+
"#{id}: #{line}\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
def remove_markup(line)
|
74
|
+
if line[0] == '^'
|
75
|
+
line = line.slice(/\^\s(.*)/, 1)
|
76
|
+
else
|
77
|
+
line
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_inaudible_notation(line)
|
82
|
+
line.scan(/\*[iI]\s\d{1,2}\:\d{1,2}/) do |inaud_markup|
|
83
|
+
timestamp = inaud_markup.match(/(\d{1,2}\:\d{1,2})/)[1]
|
84
|
+
inaudible_notation = "[inaudible #{timestamp}]"
|
85
|
+
line = line.gsub(inaud_markup, inaudible_notation)
|
86
|
+
end
|
87
|
+
line
|
88
|
+
end
|
56
89
|
end
|
57
90
|
end
|
data/test_input.txt
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tscripter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A. M.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|