Text As Data - Lecture 2

Analysis

Machine Learning and Big Data

Vincent Bagilet

2025-12-03

Summary from last class

NLP in Economics

  • Measuring document similarity
  • Concept detection
  • Relation between concepts
  • Associating text with metadata

Overal Approach

  • Get text data (ready-made, scrap, OCR, etc)
  • Pre-process the data
  • Transform data into useful format (a numeric array)
  • Run analysis. Several methods:
    • Dictionary-based
    • Rule-based
    • Machine Learning
    • Deep Learning
  • Use output in an econometric analysis

Pre-processing

  • Capitalization
  • Punctuation
  • Stop words
  • Stemming and lemmatizing

Transforming your data

From text to numbers

  • Transform data to be able to use it in algorithms

  • Main data structures for documents in NLP:

    • As raw text
    • As a sequence of tokens for each document
    • As a vector, stored in a matrix (document-term matrix, embedding matrix)

Occurrences and counts


  • Raw count of occurrences of each term by document

  • Term Frequency (tf) of word \(w\) in document \(d\) (weight by the length of the document):

\[tf_{wd} = \dfrac{\text{Number of occurences of w in d}}{\text{Total number of tokens in d}}\]

  • Account for the specificity of the term for the document: tf-idf (multiplying the term frequency (tf) and its idf)

\[ idf(term) = \ln \left(\dfrac{n_{\text{documents}}}{n_{\text{documents containing term}}}\right) \]

  • idf decreases the weight of commonly used words and increases that of words that are rarely used in the corpus

  • Can also use other transformations: dummy indicator of presence of a word in a document, log counts, etc

Matrices


  • Then create Document-Term Matrices that represent each document and each word in the vocabulary (ie in the corpus)
economy policy growth
Doc1 3 1 0
Doc2 0 2 4
Doc3 1 0 1
Doc4 2 3 1
  • These are bag-of-words (BoW) approaches:

    • Put all the term in a document together, regarding of their order (and count them)
    • Loose information about order between terms

Tf-idf implementation

import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer

assemblee_2018 = pd.read_csv("../../../data/assemblee_2018.csv")

assemblee_small = assemblee_2018.head(20)
assemblee_small = assemblee_small[['speaker_name', 'date', 'text']]

vectorizer = TfidfVectorizer()
X = vectorizer.fit_transform(assemblee_small['text'])
X
<20x254 sparse matrix of type '<class 'numpy.float64'>'
    with 400 stored elements in Compressed Sparse Row format>
pd.DataFrame(data = X.toarray()).style.set_table_attributes('style="display:block; max-height:300px; overflow-y:auto;"')
  0 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
0 0.000000 0.000000 0.204050 0.000000 0.204050 0.204050 0.204050 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204050 0.000000 0.000000 0.204050 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204050 0.204050 0.000000 0.000000 0.224947 0.000000 0.000000 0.119645 0.000000 0.000000 0.000000 0.000000 0.000000 0.239290 0.000000 0.000000 0.204050 0.204050 0.000000 0.000000 0.000000 0.000000 0.148261 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.112474 0.000000 0.000000 0.000000 0.204050 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.161847 0.000000 0.000000 0.204050 0.000000 0.000000 0.358935 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204050 0.000000 0.148261 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204050 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204050 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204050 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366948 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366948 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.244774 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366948 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.417454 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.230103 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.417454 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366948 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
2 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.361225 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.240957 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.410943 0.000000 0.325950 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.240957 0.000000 0.226514 0.226514 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.361225 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.276232 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.410943 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
3 0.000000 0.234636 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.234636 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.387998 0.000000 0.000000 0.137579 0.000000 0.000000 0.000000 0.000000 0.000000 0.137579 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.170485 0.000000 0.000000 0.000000 0.000000 0.157720 0.000000 0.258665 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.234636 0.000000 0.000000 0.000000 0.234636 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.258665 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.186107 0.000000 0.000000 0.000000 0.234636 0.000000 0.170485 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.186107 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.234636 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.234636 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.234636 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.206248 0.000000 0.000000 0.000000 0.000000 0.206248
4 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.451358 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.451358 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.769774 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
5 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.175289 0.121815 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.148552 0.000000 0.121815 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.220997 0.000000 0.220997 0.175289 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.121815 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.148552 0.000000 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.175289 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.220997 0.000000 0.220997 0.000000 0.000000 0.000000 0.220997 0.000000 0.220997 0.000000 0.220997 0.000000 0.000000 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.194259 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.220997 0.220997 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
6 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.505812 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.862644 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
7 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102046 0.102046 0.000000 0.080940 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.000000 0.000000 0.089700 0.000000 0.074146 0.089700 0.000000 0.000000 0.000000 0.204092 0.102046 0.000000 0.089700 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.102046 0.000000 0.000000 0.102046 0.000000 0.000000 0.000000 0.161881 0.281242 0.000000 0.089700 0.179504 0.102046 0.000000 0.000000 0.102046 0.000000 0.239339 0.000000 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.102046 0.148292 0.000000 0.000000 0.000000 0.000000 0.068594 0.119670 0.000000 0.089700 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.080940 0.000000 0.161881 0.000000 0.000000 0.000000 0.074146 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.102046 0.000000 0.000000 0.000000 0.119670 0.000000 0.168745 0.168745 0.000000 0.080940 0.000000 0.102046 0.000000 0.102046 0.000000 0.000000 0.000000 0.000000 0.102046 0.080940 0.000000 0.000000 0.000000 0.000000 0.000000 0.074146 0.000000 0.000000 0.000000 0.089700 0.000000 0.000000 0.000000 0.000000 0.089700 0.102046 0.000000 0.000000 0.000000 0.074146 0.000000 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.000000 0.102046 0.102046 0.000000 0.000000 0.068594 0.000000 0.000000 0.000000 0.161881 0.102046 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.089700 0.089700 0.000000 0.068594 0.204092 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102046 0.000000 0.102046 0.089700 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102046 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.068594 0.000000 0.089700 0.000000 0.102046 0.102046 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102046 0.204092 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.168745 0.102046 0.000000 0.000000 0.000000 0.000000 0.000000 0.161881 0.089700
8 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.388596 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.662737 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.365305 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.525667 0.000000
9 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.113255 0.128843 0.000000 0.000000 0.102195 0.000000 0.000000 0.128843 0.000000 0.128843 0.000000 0.113255 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.284077 0.000000 0.000000 0.075547 0.000000 0.000000 0.000000 0.000000 0.000000 0.151095 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.093617 0.000000 0.000000 0.128843 0.000000 0.086607 0.075547 0.071019 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.204391 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.102195 0.000000 0.000000 0.000000 0.093617 0.000000 0.000000 0.128843 0.000000 0.204391 0.000000 0.000000 0.000000 0.128843 0.000000 0.302189 0.000000 0.071019 0.071019 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.113255 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.113255 0.093617 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.128843 0.000000 0.000000 0.102195 0.000000 0.000000 0.128843 0.000000 0.128843 0.000000 0.000000 0.000000 0.113255 0.000000 0.000000 0.086607 0.000000 0.113255 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.086607 0.128843 0.113255 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.128843 0.000000 0.257687 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.128843 0.000000 0.000000 0.000000 0.000000 0.000000 0.284077 0.000000 0.000000 0.000000 0.000000 0.000000 0.113255 0.000000 0.000000
10 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.707107 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.707107 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
11 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.110404 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.110404 0.000000 0.139192 0.000000 0.000000 0.000000 0.101136 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.230171 0.000000 0.122352 0.163231 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.093564 0.000000 0.153447 0.122352 0.000000 0.000000 0.000000 0.000000 0.122352 0.000000 0.000000 0.000000 0.000000 0.110404 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.122352 0.000000 0.122352 0.139192 0.000000 0.101136 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.076724 0.139192 0.110404 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.122352 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.000000 0.110404 0.000000 0.278385 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.000000 0.101136 0.000000 0.000000 0.000000 0.139192 0.000000 0.122352 0.000000 0.139192 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.139192 0.187128 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.139192 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.093564 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.122352 0.000000 0.000000 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.000000 0.230171 0.000000 0.000000 0.000000 0.139192 0.000000 0.000000 0.110404 0.000000
12 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.197184 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.149588 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.159125 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.159125 0.149588 0.000000 0.000000 0.271382 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.215254 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.318250 0.000000 0.149588 0.149588 0.000000 0.215254 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.430508 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.238549 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.271382 0.000000 0.000000 0.000000 0.000000 0.182421 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.271382 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.271382 0.000000 0.000000 0.000000 0.238549 0.000000 0.000000
13 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.707107 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.707107 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
14 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.365175 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.365175 0.000000 0.000000 0.000000 0.000000 0.365175 0.000000 0.365175 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.402573 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.265333 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.245467 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.365175 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.201286 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
15 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.388607 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.341592 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.388607 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.388607 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.341592 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.341592 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.388607 0.214203 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
16 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.129892 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.129892 0.163762 0.000000 0.000000 0.000000 0.000000 0.118988 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.143949 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.192043 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.090266 0.000000 0.000000 0.000000 0.000000 0.163762 0.143949 0.143949 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.143949 0.000000 0.143949 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.129892 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.090266 0.090266 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.118988 0.163762 0.163762 0.129892 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.143949 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.143949 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.129892 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.163762 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.110079 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.143949 0.287898 0.000000 0.000000 0.163762 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.090266 0.000000 0.000000 0.143949 0.000000 0.000000 0.000000 0.000000 0.000000
17 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.505812 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.862644 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.108100 0.000000 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.108100 0.122978 0.000000 0.122978 0.122978 0.122978 0.000000 0.000000 0.000000 0.122978 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.097543 0.271145 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.216325 0.135573 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.097543 0.000000 0.000000 0.000000 0.178710 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.144217 0.000000 0.000000 0.271145 0.000000 0.000000 0.122978 0.000000 0.122978 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.108100 0.000000 0.122978 0.122978 0.000000 0.216199 0.000000 0.000000 0.000000 0.108100 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.247994 0.000000 0.000000 0.108100 0.000000 0.000000 0.245956 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.165329 0.000000 0.000000 0.195086 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.122978 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.245956 0.000000 0.000000 0.000000
19 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.504425 0.000000 0.000000 0.000000 0.000000 0.443397 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.400097 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.339070 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.443397 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.278042 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

Dimensionality reduction

  • Massive matrices (\(n_{docs} \times n_{vocab}\))

  • Even if sparse (contains mostly zeros), it might take up a lot of RAM to run algorithms on these

  • Plus, we often do not care about the words in a document but about the underlying meaning

  • Want vectors to be able to capture meaning

  • Reduce the dimensionality of the matrices to capture this meaning and lower computing load:

    • Apply Principal Component Analysis (PCA) to the matrix: called Latent Semantic Analysis
    • Latent Dirichlet Allocation (LDA)
    • Word embeddings: many approaches. We will discuss them a bit later.

Usefulness

  • After transformation, documents are represented as sequences of tokens or as vectors

  • Can now use these representations for our intended tasks

  • Compute document similarity, for instance by calculating cosine between two document-vectors (cosine-similarity)

  • Identify presence of concepts:

    • Count occurrences of words or dictionaries, build RegEx, train a ML algorithm, etc
    • Identify clusters of documents (ie of vectors)
    • Some of theses tasks only involve matrix products

Application of similarity analysis

  • Bertrand et al. (2021): Hall of Mirrors: Corporate Philanthropy and Strategic Advocacy

The paper in one line

  • Show that when nonprofits receive donations from firms, they tend to comment more on the same US federal regulatory rules but also adopt a closer type of comments
  • Approach to similarity analysis:

    1. Collapse the documents to organization-rule-year-level observations
    2. Apply LSA with tf-idf weighting to the matrix
    3. Compute cosine similarity between documents
    4. Regress similarity measure on dummy for donnation (and FEs and controls)
  • Compare LSA to a Doc2vec and LDA on a similar task: predicting if two documents come from the same docket (documents pertaining to a same narrow topic)

On your own data set






On your own dataset

What similarity question could you ask on you own data?

Dictionary-based methods

Overview

  • Methods that use predefined lists of words or phrases for analysis

  • Applications:

    • Count (co-)occurrences of certain words/dictionaries
    • Compute metrics based on values associated to each gram (eg sentiment score)
    • Classify text into categories defined by dictionaries
  • Match your text data with the dictionary, typically with RegEx

Occurrences


  • Tools that allow some similar analyses?

On your own dataset

  • What question could you ask with this?

  • When would you use this as the end-goal of your analysis?

  • What information do you loose?

Example

Co-occurrences



  • Terms that appear together. Where/at which level?

    • In a document
    • In a sentence
    • In a n-gram

On your own dataset

  • What question could you ask with occurrences?

  • When would you use occurrences as the end-goal of your analysis?

  • What information do you loose?

Example of co-occurrences

Building a dictonary

  • Defining your dictionary:

    • Using external sources

    • Using domain expertise (pre-existing topic specific dictionaries)

    • Choosing terms depending on how well they predict human-annotation

  • Use of pre-existing dictionaries:

    • AFINN, NRC, bing for sentiment analysis

    • WordNet (synonyms, antonyms, etc)

    • LIWC (Linguistic Inquiry and Word Counts): words sorted into categories (eg anger, familly, etc)

  • Expanding dictionaries:

    • With words that are close by in an embedding space
    • Use LLMs

Pros and Cons

  • Advantages:

    • Interpretable

    • Straightforward to implement (once dictonary built)

    • No training data

  • Limitations:

    • May miss some terms, etc

    • Cannot take polysemy into account

    • May not be scalable

Application of a dictionary method

  • Hassan et al. (2019): Firm-Level Political Risk: Measurement and Effects

The paper in one line

  • “Build a measure of political risk faced by individual US firms: the share of their quarterly earnings conference calls devoted to political risk”
  • Approach to quantify political risk faced by a firm:

    1. Identify political terms: bigrams that are in political science textbooks but not in general financial texts
    2. Count the number of co-occurrences of these bigrams with a dictionary for risk and uncertainty
    3. Compute the share of the earning calls dedicated to political risks

Sentiment analysis

  • Goal:

    • Get to the “tone” dimension of a document (positive, negative, neutral)
  • Sentiment score for a document: average of scores of all grams

word value
clean 2
cleaner 2
withdrawal -3
petrified -2
rejecting -1
dear 2
inspiration 2
embittered -2
enlighten 2
touted -2
exonerates 2
great 3
best 3
prosperous 3
promoted 1
sarcastic -2
lifesaver 4
usefulness 2
disregards -2
scorn -2
hero 2
suffers -2
degrade -2
some kind 0
interrupting -2
oversimplification -2
abhors -3
assassinations -3
struggling -2
lonely -2
postpones -1
exaggerates -2
deceived -3
calm 2
absolving 2
honor 2
punished -2
noob -2
unjust -2
drowned -2
worn -1
helpless -2
irrational -1
piss -4
cheer 2
n00b -2
acquits 2
destruction -3
piteous -2
somber -2
innovate 1
congratulate 2
agreed 1
abusive -3
hysterics -3
disparaging -2
greenwash -3
easy 1
slam -2
extend 1
poor -2
worry -3
gleeful 3
doom -2
conciliate 2
disappears -1
mumpish -2
endorse 2
doubt -1
bargain 2
beaten -2
entrusted 2
boycott -2
liar -3
dizzy -1
nonsense -2
deniers -2
choke -2
welcome 2
shit -4
agree 1
thrilled 5
kind 2
unhealthy -2
cover-up -3
cruel -3
not working -3
saved 2
fire -2
poorer -2
piqued -2
smog -2
innovates 1
dumbass -3
protected 1
criticized -2
fervent 2
shares 1
green wash -3
stalled -2

Sentiment analysis

  • How would you implement it on your data set? Which question?
  • Implementation with TextBlob (that upweights adjectives for instance)
from textblob import TextBlob

sentence_sentiment =  "Beautiful is better than ugly."
sent = TextBlob(sentence_sentiment)
print(sent.sentiment.polarity)
0.2166666666666667
  • Can also implement non-dictionary based sentiment analyses (eg with transformers)

Warning

Such analyses (and many other NLP analyses) can be biased!

eg “Let’s go get Italian VS Mexican food”

Application of a sentiment analysis

  • Almond, Du, and Papp (2022): Favourability towards natural gas relates to funding source of university energy centres

The paper in one line

  • Use lexicon and rule-based sentiment analysis to show that fossil-funded energy centres from universities are more favourable in their reports towards natural gas than towards renewable energy
  • Approach to sentiment analysis:

    1. Use Vader dictionary
    2. Regress the score of each sentence on a dummy for whether the sentence includes keywords related a fuels type with report FEs

Word Embeddings

General idea

  • Project documents into a vector space

  • Building dense matrices, ie non-sparse

  • Uses the context

    • Words that often occur jointly will be close in the embedding space

    • eg we probably want pen and pencil to be relatively close in the space

  • Captures relations between words

  • “Classic” embeddings do not take polysemy into account: collapse each word to one vector

  • We are going to talk about more complex, deep learning based, embeddings later in this session

Visual intuition

Pre-trained embeddings

  • Ready to use, capture relationships between words in common language

  • Trained on large corpora (Common Crawl, Wikipedia)

  • Different algorithms: FastText (Facebook), word2vec (Google), GloVe (Stanford)

  • Computation methods:

    • CBOW (Continuous Bag Of Words), Skip-gram
    • Basically, compute words that co-occur in a \(k\)-words window

Train your own embedding

  • Will capture the relationships between words in your corpus

  • Take specificities of your corpus into account

  • Need a lot of text data to train properly train your own embeddings

  • Use the algorithms (FastText, word2vec, GloVe) and methods (CBOW, skipgram) described above to train you embedding

  • Specify:

    • Desired dimension of the embedding space
    • Number of words in the training window

Applications

  • Find nearest-neighbors of words

    • Can be used to build dictionaries
    • Describe relationships between words
  • Identify clusters of words

    • Can be used for topic modeling (\(k\)-nearest neighbors in the embedding space)
  • Identify specific dimension

    • eg difference between “man” and “woman” will give you some sort of “gender” direction (see next example)

On your own dataset

What type of analysis could you do with embeddings?

Application of WEAT

  • Ash, Chen, and Ornaghi (2024): Gender Attitudes in the Judiciary: Evidence from US Circuit Courts

The paper in one line

  • Use judge-specific embedding to determine judges gender attitudes and show that it correlates with gendered-biased behavior
  • Approach to compute gender attitudes:

    1. Train judge-specific embeddings (wih GloVe algorithm)
    2. Identify a gender dimension (vector) in the space by taking the difference between words annotaded as “male” or “female” in the LIWC Dictionary
    3. Same for a stereotypical career-family vector
    4. Compute the cosine similarity between these vectors = gender attitudes

Machine Learning

Supervised ML



  • Classification model: predict a class label or group membership

  • Regression model: predict a numeric or continuous value

  • We learned how to transform our data from unstructured to structured format

  • We can now apply what you learn in the rest of the class to this text data

    \(\to\) will not go into more details here

On your own dataset

  • Examples of applications?

  • How to build validation sets?

Unsupervised ML

  • Use unlabeled data \(\neq\) many of the algorithms discussed in class

  • Do not try to fit to make the model predict a “ground truth”

  • For text data, unsupervised ML is mostly used for topic models :

    • They infer latent topics in the corpus
    • Supervised: define topics, write algorithms to predict which category they belong to
    • Semi-supervised: give anchor-words (eg CorEx)
    • Unsupervised: let the algorithm discover topics by itself (eg LDA)

Latent Dirichlet Allocation (LDA)

  • Every document is a mixture of topics

    • eg doc 1 is 20% topic A, 80% topic B
  • Every topic is a mixture of words

    • eg topic A is composed of words “banana”, “apple”, etc
  • LDA estimate both at the same time, it is probabilistic ML

  • Only one parameter to specify: the number of topics (\(k\))

Example LDA

from sklearn.decomposition import LatentDirichletAllocation
from wordcloud import WordCloud
import matplotlib.pyplot as plt

vocab = vectorizer.get_feature_names_out()
lda = LatentDirichletAllocation(n_components=5, random_state=12)
lda.fit(X) #X is the tf-idf matrix from earlier
LatentDirichletAllocation(n_components=5, random_state=12)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
(-0.5, 799.5, 599.5, -0.5)

Structural Topic Model (STM)

  • LDA + Metadata

  • Includes contextual information by:

    • Making topic prevalence vary with metadata, eg left wing parties talk more about inequality than right wing parties

    • Topic content can vary with metadata, eg left wing parties talk more about education inequality than right wing parties

Application of a topic model



  • Noailly et al. (2024): Heard the news? Environmental policy and clean investments

The paper in one line

  • Develop a news index of US env and climate policy and look at link with actual regulations and financial investments
  • Approach to topic modelling

    • Use LDA
    • Use a supervised approach (with SVM)

Deep Learning

BERT-like models

  • Bidirectional Encoder Representation from Transformers

  • Introduced by Google in 2018

  • Masked Language Model: trained by trying to discover words that are randomly masked

  • Good at text classification, answering questions

  • Mainly focused on understanding language

GPT-like models

  • Generative Pretrained Transformer

  • Introduced by OpenAI in 2018

  • Good at text generation, having conversations

  • Autoregressive Language Modeling: trained to predict the next word

  • Mainly focus on generating language

Using LLMs in economics text analysis

  • Very good at certain tasks

  • Easily accessible but might be expensive to run

  • May not be a good option for sensitive private data (need to share data)

  • Can use models installed locally

  • Computationally intensive

  • Not that interpretable (black-boxy) but can be validated against hand-labelled data

  • May not be very robust to prompt variations + non-replicable

Application of BERT

  • Moreno-Medina et al. (2025): Officer-Involved: The Media Language of Police Killings

The paper in one line

The forms of language used by the media to report on police killings affects how the readers hold them morally responsible

  • Uses of BERT to identify:

    • All words that reference the same individual using Span-BERT; it clusters all the tokens that describe the same entity
    • Who did what to whom in sentences about the shooting using another BERT-like model to annotate semantic roles
  • Then, based on that identify structures that appear in each sentence: an active-voice verb, a passive-voice verb, a nominalization, no agent, or an intransitive verb.

Conclusion

Summary of the lecture

  • Need to transform unstructured text data to numeric format (typically to sequences of grams or matrices)

  • Embeddings and dense vector representations allow to capture relations between words

  • These representations allow to apply:

    • Direct analyses on these representations, eg similarity analyses via cosine-similarity
    • Supervised ML models learned in the rest of the class
    • Unsupervised ML algorithms such as topic modeling (eg LDA)
  • Recent developments in NLP allow to compute context-specific representations and to implement more complex analyses

Summary of the class

  • Typically, NLP allows to build new metrics to plug into econometrics models

  • There are many steps involved in text analysis

  • Gathering data may be one of the most time consuming ones

  • Once we have transformed our text data, we can apply other typical ML tools to these representations

  • There are currently tons of developments in NLP, hard to keep up

  • Nowadays, we can basically do anything we want on text data \(\Rightarrow\) importance of identifying good research questions

Back to your own question




On your own dataset

  • What type of text data? What source?

  • How would you get the data?

  • Which research question?

  • How would you go about studying this?

References

Almond, Douglas, Xinming Du, and Anna Papp. 2022. “Favourability Towards Natural Gas Relates to Funding Source of University Energy Centres.” Nature Climate Change 12 (12): 1122–28. https://doi.org/10.1038/s41558-022-01521-3.
Ash, Elliott, Daniel L. Chen, and Arianna Ornaghi. 2024. “Gender Attitudes in the Judiciary: Evidence from US Circuit Courts.” American Economic Journal: Applied Economics 16 (1): 314–50. https://doi.org/10.1257/app.20210435.
Bertrand, Marianne, Matilde Bombardini, Raymond Fisman, Brad Hackinen, and Francesco Trebbi. 2021. “Hall of Mirrors: Corporate Philanthropy and Strategic Advocacy.” The Quarterly Journal of Economics 136 (4): 2413–65. https://doi.org/10.1093/qje/qjab023.
Hassan, Tarek A, Stephan Hollander, Laurence van Lent, and Ahmed Tahoun. 2019. “Firm-Level Political Risk: Measurement and Effects.” The Quarterly Journal of Economics 134 (4): 2135–2202. https://doi.org/10.1093/qje/qjz021.
Moreno-Medina, Jonathan, Aurélie Ouss, Patrick Bayer, and Bocar A Ba. 2025. “Officer-Involved: The Media Language of Police Killings.” The Quarterly Journal of Economics 140 (2): 1525–80. https://doi.org/10.1093/qje/qjaf004.
Noailly, Joëlle, Laura Nowzohour, Matthias van den Heuvel, and Ireneu Pla. 2024. “Heard the News? Environmental Policy and Clean Investments.” Journal of Public Economics 238 (October): 105190. https://doi.org/10.1016/j.jpubeco.2024.105190.