-
Notifications
You must be signed in to change notification settings - Fork 4
Annotation graph
Hervé BREDIN edited this page Nov 5, 2013
·
5 revisions
- DVD_sub/TheBigBangTheory.Season01.Episode01.en.srt
00:00:01,239 --> 00:00:03,833
If a photon is directed through a plane
with two slits in it...
import networkx as nx
from tvd.graph import T
g = nx.MultiDiGraph(
uri="TheBigBangTheory.Season01.Episode01",
src="BigBangTrans"
)
t1 = T(1.239)
t2 = T(3.833)
g.add_edge(
t1, t2,
src="BigBangTrans", # optional when unambiguous (inherited)
speech="If a photon [...] two slits in it..."
)
nx.write_gml(g, "/tmp/test.gml")
# /tmp/test.gml
graph [
directed 1
src "BigBangTrans"
uri "TheBigBangTheory.Season01.Episode01"
node [
id 0
label 1.239
]
node [
id 1
label 3.833
]
edge [
source 0
target 1
src "BigBangTrans"
speech "If a photon [...] two slits in it..."
]
]
- WWW_trs/TheBigBangTheory.Season01.Episode01.en.txt
Scene: A corridor at a sperm bank.
Sheldon: So if a photon is directed through a plane with two slits in it and either slit is observed it will not go through both slits. If it’s unobserved it will, however, if it’s observed after it’s left the plane but before it hits its target, it will not have gone through both slits.
Leonard: Agreed, what’s your point?
import networkx as nx
from tvd.graph import T
g = nx.MultiDiGraph(
uri="TheBigBangTheory.Season01.Episode01",
src="BigBangTheoryWiki"
)
# scene, start/end timestamps (not known yet)
sceneStart = T()
sceneEnd = T()
g.add_edge(
sceneStart, sceneEnd,
description="A corridor at a sperm bank."
)
# sheldon starts speaking a little bit after beginning of scene
sheldonStart = T()
sheldonEnd = T()
g.add_edge(sceneStart, sheldonStart)
# two types of edge (speaker and speech)
g.add_edge(
sheldonStart, sheldonEnd,
speaker="Sheldon"
)
g.add_edge(
sheldonStart, sheldonEnd,
speech="So if a photon is [...] through both slits."
)
# leonard starts speaking after sheldon
# but not right after (there might be silence between them)
leonardStart = T()
leonardEnd = T()
g.add_edge(sheldonEnd, leonardStart) # this edge represents silence
# two types of edge (speaker and speech)
g.add_edge(
leonardStart, leonardEnd,
speaker="Leonard"
)
g.add_edge(
leonardStart, leonardEnd,
speech="Agreed, what's your point?"
)
# there might be silence before the end of the scene
g.add_edge(leonardEnd, sceneEnd)
nx.write_gml(g, "/tmp/test.gml")
graph [
directed 1
src "BigBangTheoryWiki"
uri "TheBigBangTheory.Season01.Episode01"
node [
id 0
label A
]
node [
id 1
label C
]
node [
id 2
label B
]
node [
id 3
label E
]
node [
id 4
label D
]
node [
id 5
label F
]
edge [
source 0
target 1
]
edge [
source 0
target 2
description "A corridor at a sperm bank."
]
edge [
source 1
target 4
speaker "Sheldon"
]
edge [
source 1
target 4
speech "So if a photon is [...] through both slits."
]
edge [
source 3
target 5
speaker "Leonard"
]
edge [
source 3
target 5
speech "Agreed, what's your point?"
]
edge [
source 4
target 3
]
edge [
source 5
target 2
]
]
- Temporary alternative structure for easier visualization (graphviz uses label field as default edge text)
import networkx as nx
from tvd.graph import T, TVD_DESCRIPTION, TVD_SPEAKER, TVD_SPEECH
g = nx.MultiDiGraph(
uri="TheBigBangTheory.Season01.Episode01",
src="BigBangTheoryWiki"
)
# scene, start/end timestamps (not known yet)
sceneStart = T()
sceneEnd = T()
g.add_edge(
sceneStart, sceneEnd,
type=TVD_DESCRIPTION,
label="A corridor at a sperm bank."
)
# sheldon starts speaking a little bit after beginning of scene
sheldonStart = T()
sheldonEnd = T()
g.add_edge(sceneStart, sheldonStart)
# two types of edge (speaker and speech)
g.add_edge(
sheldonStart, sheldonEnd,
type=TVD_SPEAKER,
label="Sheldon"
)
g.add_edge(
sheldonStart, sheldonEnd,
type=TVD_SPEECH,
label="So if a photon is [...] through both slits."
)
# leonard starts speaking after sheldon
# but not right after (there might be silence between them)
leonardStart = T()
leonardEnd = T()
g.add_edge(sheldonEnd, leonardStart) # this edge represents silence
# two types of edge (speaker and speech)
g.add_edge(
leonardStart, leonardEnd,
type=TVD_SPEAKER,
label="Leonard"
)
g.add_edge(
leonardStart, leonardEnd,
type=TVD_SPEECH,
label="Agreed, what's your point?"
)
# there might be silence before the end of the scene
g.add_edge(leonardEnd, sceneEnd)
nx.write_gml(g, "/tmp/test.gml")
nx.write_dot(g, "/tmp/test.dot")
# dot file to be used with graphviz for visualization
# dot /tmp/test.dot -Tpng > /tmp/test.png