collect_statements() creates a network by coding a text interactively.
It shows each sentence (or paragraph, or document) of the text in turn,
and asks which concepts it is about,
who says so, and whether they agree or disagree.
A unit can hold several statements, or none.
Where the coder names who speaks, the result is a discourse network:
a two-mode, signed network of speakers and concepts,
in the form of irps_nuclear.
Each statement is one tie from a speaker to a concept,
with its sign, +1 (agreement) or -1 (disagreement), as its weight.
Where the coder names no speaker, the tie is from the document itself,
as in the qualitative coding of a literature review,
where each abstract is coded for the topics it is about.
Where the coder gives no sign, the tie has none.
The result is then a two-mode network of documents and concepts,
and to_mode(.data, "concepts") gives the concepts that the same
documents are about.
Coding can stop at any unit and continue later:
pass the network that was coded so far as .data,
and coding starts again after the last unit that holds a statement.
A coder who is unsure can enter "?" to come back to a unit or a sign later.
A unit skipped in this way is shown again at the end of the pass.
Where it is still skipped, or coding stops first,
the network records it in info$uncoded,
and shows it again first where the network is given as .data.
info$uncoded is removed once every unit is coded.
collect_statements(text, unit = "sentence", roster = NULL, .data = NULL)The text to code, as one or more documents. A character vector, each element of which is one document, named by its names if it has any, or a data frame with a 'text' column, each row of which is one document, named by its 'doc_id', 'document', or 'id' column if it has one, and dated by its 'date' or 'time' column if it has one.
The unit of text to show at each step. One of "sentence" (the default), "paragraph", or "document".
The names of nodes to offer for each mode.
A list of two character vectors, the speakers and the concepts,
named by their modes or in that order.
One character vector, or a network such as from collect_text(),
gives only the concepts.
By default NULL, only the nodes of .data and those coded so far.
A network that is coded in part,
such as an earlier result of collect_statements().
By default NULL, a new network.
A stocnet object.
A two-mode network of speakers (or documents) and concepts,
signed where the coder gives signs.
Paragraphs and sentences are found as in collect_text():
paragraphs are separated by a blank line,
and sentences end with a full stop, a question mark, or an
exclamation mark that is followed by a space.
For each statement, enter:
the concept, as a name, or the number of a name in the roster that is shown, or nothing (press [Enter]) to go to the next unit;
who says so, in the same way, or nothing for the document itself; or "?" at either, to skip the rest of the unit and come back to it;
"+" (or "agree", "yes", "1") or "-" (or "disagree", "no", "-1") for the sign, nothing for no sign, or "?" where the sign is unclear.
Where a name is part of names that are already known, these names are shown, so that one of them can be chosen by its number. Enter the same name again to add it as a new name. Enter "q" at any prompt to stop coding and return the network coded so far.
The roster holds the speakers and concepts given in roster,
those of .data, and those coded so far.
The names of a roster are numbered where it holds 20 names or fewer.
Each tie records the 'document' of its statement,
and the number of its 'sentence' or 'paragraph' in the document.
The 'date' (or 'time') of a document is the 'time' of its ties,
where text gives one.
Statements are events that add to the discourse,
so to_time(.data, as.Date("2011-06-01")) gives the discourse up to
that date.
Where some ties are signed and others not, the ties without a sign
have a missing weight, as do the ties of an unknown sign.
A tie of missing weight is present, but of unknown value.
So in a signed network given as .data,
every tie of missing weight is shown again to be coded,
with its unit where text holds it.
Enter "?" or nothing to leave the sign unknown.
A network given as .data is coded in this order:
first the units in info$uncoded, with the statements coded in them
already, then the ties of unknown sign,
then the units after the last one that holds a statement or is
still to code, and last, once more, the units skipped in this pass.
A unit still to code that is not in text is dropped, with a warning,
so give the same text each time.
Where both speakers and documents make statements,
the network has three modes: documents, speakers, and concepts.
Coding by hand is slow, but the coder reads what a text means,
and not only the words it uses.
collect_text() is fast, and finds the words that a text uses.
The two can be used in sequence:
collect the terms of a text first,
and offer them to the coder as the roster of concepts,
so that the coder picks from the same names throughout.
A network in roster gives the nodes of its last mode as the concepts.
The ties of speakers who make the same statements
form a network of discourse coalitions.
to_mode() projects the statements onto the speakers,
with similarity = "agreement" counting the pairs of statements
in which two speakers agree about a concept,
"disagreement" the pairs in which they disagree,
and "signed" the difference.
A projection does not keep the time of the statements,
so take moving windows of the statements with to_times() first,
and project each window:
dates <- seq(as.Date("2011-03-15"), as.Date("2011-06-15"), by = "month")
windows <- to_times(irps_nuclear, dates, window = 30)
coalitions <- lapply(windows, to_mode, "speakers", similarity = "agreement")Each window holds the statements of the 30 days up to its date.
dates <- seq(as.Date("2011-03-15"), as.Date("2011-06-15"), by = "month")
windows <- to_times(irps_nuclear, dates, window = 30)
lapply(windows, to_mode, "speakers", similarity = "agreement")
#> $`2011-03-15`
#>
#> ── # Projection of German nuclear discourse network ────────────────────────────
#> # A labelled, weighted, undirected network of 337 nodes and 348 ties
#> # Transformed by projection: mode 1 (agreement)
#>
#> ── Nodes
#> # A tibble: 337 × 9
#> label active politician govt coalition office org party power
#> <chr> <lgl> <lgl> <lgl> <lgl> <lgl> <chr> <chr> <int>
#> 1 VfEW TRUE FALSE FALSE NA FALSE VfEW NA 0
#> 2 Angela Merkel TRUE TRUE TRUE TRUE TRUE CDU 31 2
#> 3 Sunday Times TRUE FALSE FALSE NA FALSE Sunday T… NA 0
#> 4 SPD TRUE TRUE FALSE FALSE FALSE SPD 32 1
#> 5 Norbert Röttgen TRUE TRUE TRUE TRUE TRUE CDU 31 1
#> 6 Torsten Krauel TRUE FALSE FALSE NA FALSE Die Welt NA 0
#> # ℹ 331 more rows
#>
#> ── Ties
#> # A tibble: 348 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 1 44 1
#> 2 2 4 4
#> 3 2 5 4
#> 4 2 6 1
#> 5 2 8 1
#> 6 2 9 4
#> # ℹ 342 more rows
#>
#>
#> $`2011-04-15`
#> ── # Projection of German nuclear discourse network ────────────────────────────
#> # A labelled, weighted, undirected network of 337 nodes and 1798 ties
#> # Transformed by projection: mode 1 (agreement)
#>
#> ── Nodes
#> # A tibble: 337 × 9
#> label active politician govt coalition office org party power
#> <chr> <lgl> <lgl> <lgl> <lgl> <lgl> <chr> <chr> <int>
#> 1 VfEW TRUE FALSE FALSE NA FALSE VfEW NA 0
#> 2 Angela Merkel TRUE TRUE TRUE TRUE TRUE CDU 31 2
#> 3 Sunday Times TRUE FALSE FALSE NA FALSE Sunday T… NA 0
#> 4 SPD TRUE TRUE FALSE FALSE FALSE SPD 32 1
#> 5 Norbert Röttgen TRUE TRUE TRUE TRUE TRUE CDU 31 1
#> 6 Torsten Krauel TRUE FALSE FALSE NA FALSE Die Welt NA 0
#> # ℹ 331 more rows
#>
#> ── Ties
#> # A tibble: 1,798 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 2 4 6
#> 2 2 5 38
#> 3 2 9 15
#> 4 2 10 3
#> 5 2 14 5
#> 6 2 17 11
#> # ℹ 1,792 more rows
#>
#>
#> $`2011-05-15`
#> ── # Projection of German nuclear discourse network ────────────────────────────
#> # A labelled, weighted, undirected network of 337 nodes and 445 ties
#> # Transformed by projection: mode 1 (agreement)
#>
#> ── Nodes
#> # A tibble: 337 × 9
#> label active politician govt coalition office org party power
#> <chr> <lgl> <lgl> <lgl> <lgl> <lgl> <chr> <chr> <int>
#> 1 VfEW TRUE FALSE FALSE NA FALSE VfEW NA 0
#> 2 Angela Merkel TRUE TRUE TRUE TRUE TRUE CDU 31 2
#> 3 Sunday Times TRUE FALSE FALSE NA FALSE Sunday T… NA 0
#> 4 SPD TRUE TRUE FALSE FALSE FALSE SPD 32 1
#> 5 Norbert Röttgen TRUE TRUE TRUE TRUE TRUE CDU 31 1
#> 6 Torsten Krauel TRUE FALSE FALSE NA FALSE Die Welt NA 0
#> # ℹ 331 more rows
#>
#> ── Ties
#> # A tibble: 445 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 2 4 2
#> 2 2 9 2
#> 3 2 28 2
#> 4 2 32 1
#> 5 2 42 1
#> 6 2 53 1
#> # ℹ 439 more rows
#>
#>
#> $`2011-06-15`
#> ── # Projection of German nuclear discourse network ────────────────────────────
#> # A labelled, weighted, undirected network of 337 nodes and 887 ties
#> # Transformed by projection: mode 1 (agreement)
#>
#> ── Nodes
#> # A tibble: 337 × 9
#> label active politician govt coalition office org party power
#> <chr> <lgl> <lgl> <lgl> <lgl> <lgl> <chr> <chr> <int>
#> 1 VfEW TRUE FALSE FALSE NA FALSE VfEW NA 0
#> 2 Angela Merkel TRUE TRUE TRUE TRUE TRUE CDU 31 2
#> 3 Sunday Times TRUE FALSE FALSE NA FALSE Sunday T… NA 0
#> 4 SPD TRUE TRUE FALSE FALSE FALSE SPD 32 1
#> 5 Norbert Röttgen TRUE TRUE TRUE TRUE TRUE CDU 31 1
#> 6 Torsten Krauel TRUE FALSE FALSE NA FALSE Die Welt NA 0
#> # ℹ 331 more rows
#>
#> ── Ties
#> # A tibble: 887 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 2 5 5
#> 2 2 9 9
#> 3 2 10 4
#> 4 2 14 4
#> 5 2 17 28
#> 6 2 18 4
#> # ℹ 881 more rows
#>
#>
if (FALSE) { # \dontrun{
speeches <- data.frame(doc_id = c("a", "b"),
date = as.Date(c("2011-03-14", "2011-03-15")),
text = c("Merkel wants a moratorium. Greens agree.",
"Industry rejects any exit."))
coded <- collect_statements(speeches, roster = "nuclear exit")
# stop with "q", then continue later
coded <- collect_statements(speeches, .data = coded)
} # }