Printable version here

Content and relational coding

We start by loading the debate package:

library(debate)

Preparation of the text

txt <- debate.pdftotext("r-package-debate-science-slam-example-text-printable.pdf")
txt <- debate.txt.clean(txt)

txt <- gsub("nnnn","", txt)

Definition of stopping criteria

stakeholders <- list(
  list(
    name = c("Archetto"),
    pattern.start = c("\nMonsieur Archetto"),
    pattern.stop = c("\nMonsieur")

  ),
  list(
    name = c("Kemp"),
    pattern.start = c("\nMonsieur Kemp"),
    pattern.stop = c("\nMadame")
  ),
  list(
    name = c("Schadegg"),
    pattern.start = c("\nMadame Schadegg"),
    pattern.stop = c("\nMonsieur")
  ),
  list(
    name = c("Paggi"),
    pattern.start = c("\nMadame Paggi"),
    pattern.stop = c("\nPrésident.")
  )
)

Definition of the dictionary

dic <- list(
  list(
    name = "visibilité",
    match = c("visibilité")
  ),
  list(
    name = "dynamisme",
    match = c("dynamisme", "redynamiser") 
  ),
  list(
    name = "compétitivité",
    match = c("compétitive")
  ),
  list(
    name = "projet académique",
    match = c("projet académique", "projet facultaire")
  ),
  list(
    name = "pensée",
    match = c("pensée globale","pensée économique")
  ),
  list(
    name = "spécialisation",
    match = c("spécialisation")
  ),
  list(
    name = "structure",
    match = c("structure")
  ),
  list(
    name = "genève",
    match = c("particularité genevoise")
  ),
  list(
    name = "finances",
    match = c("milieux financiers" )
  ),
  list(
    name = "délimitation",
    match = c("disciplines proches","domaines de compétences")
  ),
  list(
    name = "échange",
    match = c("passerelle","collaborations interfacultaires")
  )
)

Definition of relational indicators

Definition of nodes

nodes <- list(
  list(
    name = "Archetto",
    match = c("M. Archetto")
  ),
  list(
    name = "Kemp",
    match = c("M. Kemp") 
  ),
  list(
    name = "Schadegg",
    match = c("Mme Schadegg")
  ),
  list(
    name = "Paggi",
    match = c("Mme Paggi")
  ),
  list(
    name = "Partisants",
    match = c("partisants de l'ouverture")
  ),
  list(
    name = "Opposants",
    match = c("partisants de l'inertie", "partisants d'un status quo
              insatisfaisant", "opposants")
  ),
  list(
    name = "Rappaz",
    match = c("William Rappaz")
  )
)

Definition of markers

marker <- list(
  list(
    name = "Approval",
    match = c("tout à fait d'accord", "Comme l'a dit", "partisants de l'ouverture")
  ),
  list(
    name = "Disapproval",
    match = c("Je ne suis pas d'accord", "accusations des", 
              "lucidité défaillante", "forme jusque là défaillante de lucidité",
              "partisants d'un statu quo insatisfaisant", "partisants de l'inertie") 
  )
)  

Extraction of databases

content.overall <- debate.content.extract.dictionary(txt, dic)

# content.individual <- debate.txt.extract.contributors(
#   txt=txt,
#   contrib=stakeholders,
#   dictionary = dic
# )
# summarize(content.individual, count.by="intervention")

# summarize(content.individual, count.by="occurence")

Setting up the graphical representation

Loading the debate package

library(debate)

Building the debate room

We design the room using a matrix representation

col <- 5
row <- 5

m <- matrix(rep(-1, col*row), nrow =row)

m[1,2] <- 1
m[1,4] <- 2
m[2,1] <- 3
m[2,5] <- 4
m[4,2] <- 5
m[4,4] <- 6
m[5,3] <- 7
dimnames(m) <- list(
  c('E', 'E', 'E', 'E', 'E' ),
  c('E', 'E', 'E', 'E', 'E')
)
m
##    E  E  E  E  E
## E -1  1 -1  2 -1
## E  3 -1 -1 -1  4
## E -1 -1 -1 -1 -1
## E -1  5 -1  6 -1
## E -1 -1  7 -1 -1

Then we convert the matrix object to a SpatialPolygon object

slam_room <- room.create.grid(m, seat.width=1, seat.height=1)

Creating the spnet object

node <- c('Paggi', 'Archetto', 'Schadegg', 'Kemp',  'Opposants', 'Partisants', 'Rappaz')
position <- c(1,2,3,4,5,6,7)
netslam <- spnet.create(data.frame(
  'NODE' = node,
  'POSITION' = position
))
spnet.map(netslam) <- slam_room

Setting colors according to affiliations

netslam$fac <- c('Sociologie', 'Statistiques', 'Geographie', 'Economie','autre','autre','autre')
spnet.color.variable(netslam) <- 'fac'
spnet.color.legend(netslam) <- c(
  'Sociologie' = '#ABA4F3',
  'Statistiques' = '#F3A4C4',
  'Geographie' ='#A4F3D3',
  'Economie' = '#ECF3A4',
  'autre' = 'grey95'
)

Setting symbols according to individual status

netslam$symbol <- c('Professeur', 'Professeur', 'Etudiant', 'Assistant', '', '', '')
spnet.symbol.variable(netslam) <- 'symbol'
spnet.symbol.legend(netslam) <- c(
  'Professeur' = 'triangle.up',
  'Assistant' = 'circle', 
  'Etudiant' = 'square.rotated'
)

We also change the y position and increase symbol size

spnet.symbol.shift.y(netslam) <- -0.25
spnet.symbol.cex(netslam) <- 3

Defining the networks: “approval”, “disapproval”, and “neutral references”

spnet.networks.add(netslam) <- 'app'
spnet.network.label(netslam, 'app') <- "Approbations"
spnet.network.arrow.color(netslam, 'app') <- '#1A9C67'
spnet.network.arrow.thickness(netslam, 'app') <- 3
spnet.network.arrow.shorten(netslam, 'app') <- 0.55
spnet.network.arrow.head.lth(netslam, 'app') <- 0.4

spnet.networks.add(netslam) <- 'desapp'
spnet.network.label(netslam, 'desapp') <- "Désapprobations"
spnet.network.arrow.color(netslam, 'desapp') <- '#9C1A4F'
spnet.network.arrow.thickness(netslam, 'desapp') <- 3
spnet.network.arrow.shorten(netslam, 'desapp') <- 0.55
spnet.network.arrow.head.lth(netslam, 'desapp') <- 0.4

spnet.networks.add(netslam) <- 'neutre'
spnet.network.label(netslam, 'neutre') <- "Références neutres"
spnet.network.arrow.color(netslam, 'neutre') <- '#666666'
spnet.network.arrow.thickness(netslam, 'neutre') <- 3
spnet.network.arrow.shorten(netslam, 'neutre') <- 0.55
spnet.network.arrow.head.lth(netslam, 'neutre') <- 0.4

Before the debate starts there are no references. The initial situation is an 0-filled matrix

reference_init <- matrix(
  rep(0, length(node)^2),
  nrow = length(node),
  dimnames = list(node, node)
)
reference_init
##            Paggi Archetto Schadegg Kemp Opposants Partisants Rappaz
## Paggi          0        0        0    0         0          0      0
## Archetto       0        0        0    0         0          0      0
## Schadegg       0        0        0    0         0          0      0
## Kemp           0        0        0    0         0          0      0
## Opposants      0        0        0    0         0          0      0
## Partisants     0        0        0    0         0          0      0
## Rappaz         0        0        0    0         0          0      0

We set the data attribute of each network with the inital matrix

spnet.network.data(netslam, 'app') <- reference_init
spnet.network.data(netslam, 'desapp') <- reference_init
spnet.network.data(netslam, 'neutre') <- reference_init

Setting up the barplot to render content

netslam$content <- c(0,0,0,0,0,0,0) # initial situation, no one talk so content is 0 for every one
spnet.barplot.variable(netslam) <- "content"

We also adjust barplot rendering

spnet.barplot.bound.lower(netslam) <- c(-0.493,-0.443)
spnet.barplot.bound.upper(netslam) <- c(0.493,-0.443)
spnet.barplot.bgcolor(netslam) <- 'grey95'
spnet.barplot.width(netslam) <- 11

Customizing/Adjusting rendering

spnet.title.main(netslam) <- ''
spnet.label.cex(netslam) <- 1.6
spnet.legend.ncol(netslam) <- 2
spnet.legend.cex(netslam) <- 1.6
spnet.legend.line.width(netslam) <- 1

Plotting the debate room

Before the debate begins, here is how our debate room looks like

plot(netslam)

plot of chunk unnamed-chunk-24

Running into the debate

First intervention

spnet.network.data(netslam, 'neutre')['Archetto', 'Schadegg'] <- 1
netslam[node == "Archetto", "content"] <- 0.2

plot of chunk unnamed-chunk-26

Relations: Archetto made a “neutral reference” to Schadegg

Content: “dynamisme” and “visibilité”

Second intervention

spnet.network.data(netslam, 'app')['Kemp', 'Archetto'] <- 1
spnet.network.data(netslam, 'desapp')['Kemp', 'Schadegg'] <- 1
spnet.network.data(netslam, 'desapp')['Kemp', 'Paggi'] <- 1
netslam[node == "Kemp", "content"] <- 0.1

plot of chunk unnamed-chunk-28

Relations: Kemp made an “approval” to Archetto and a “disapproval” to Schadegg and Paggi

Content: “redynamiser”

Third intervention

spnet.network.data(netslam, 'desapp')['Schadegg', 'Kemp'] <- 1
spnet.network.data(netslam, 'neutre')['Schadegg', 'Rappaz'] <- 1
netslam[node == "Schadegg", "content"] <- 0.3

plot of chunk unnamed-chunk-30

Relations: Schadegg made a “disapproval” to Kemp and a “neutral reference” to Rappaz

Content: “particularité genevoise” “spécialisation” “pensée globale”

Fourth intervention

spnet.network.data(netslam, 'desapp')['Archetto', 'Schadegg'] <- 1
spnet.network.data(netslam, 'neutre')['Archetto', 'Partisants'] <- 1
spnet.network.data(netslam, 'desapp')['Archetto', 'Opposants'] <- 2
spnet.network.data(netslam, 'app')['Archetto', 'Kemp'] <- 2
netslam[node == "Archetto", "content"] <- 0.5

plot of chunk unnamed-chunk-32

Relations: Archetto made a “disapproval”" to Schadegg, a “disapproval” and an attack to the oppponents as a group

Content: “dynamisme” “visibilité” “compétitive”

Fifth intervention

spnet.network.data(netslam, 'desapp')['Kemp', 'Opposants'] <- 2
netslam[node == "Kemp", "content"] <- 0.2

plot of chunk unnamed-chunk-34

Relations: Kemp made two “disapprovals” to opponents

Content: “Milieux financiers”

Sixth intervention

spnet.network.data(netslam, 'desapp')['Schadegg', 'Kemp'] <- 2

plot of chunk unnamed-chunk-36

Relations: Schadegg made a affront to “partisants”, personally directed to Kemp

Content: none

Seventh intervention

spnet.network.data(netslam, 'desapp')['Kemp', 'Schadegg'] <- 11

plot of chunk unnamed-chunk-38

Relations: Kemp sends a glass of water to Schadegg (“disapproval” weighted 10 plus 1 “disapproval” at the begining of the debate = 11)

Eighth intervention

spnet.network.data(netslam, 'neutre')['Paggi', 'Rappaz'] <- 1
netslam[node == "Paggi", "content"] <- 0.7

plot of chunk unnamed-chunk-40

Relations: Paggi made a “neutral reference” to Rappaz

Content: “projet académique” “disciplines proches” “pensée de l’économie” “passerelle” “collaborations interfacultaires” “domaines de compétences” “structure”





comments powered by Disqus