-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeature_documentation.Rmd
More file actions
1975 lines (1603 loc) · 118 KB
/
Feature_documentation.Rmd
File metadata and controls
1975 lines (1603 loc) · 118 KB
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Feature_documentation"
author: "Hanna Mahler"
date: "2023-10-01"
output: html_document
---
This R-Markdown contains a documentation of the linguistic features annotated by our Python script.
Most of the features are taken from Biber (1988), some are adapted from Clarke & Grieve (2017), and some are our own additions.
For every feature we will first quote how it is defined in the original source (if known) and provide an example. We will then show how the feature is extracted in our code and what the extraction criteria are. If applicable, we will justify any deviations from the original source. We will also provide an accuracy measurement for each feature: an F-score that was calculated from the comparison of the automatic extraction with a manual coding of the feature in question.
Features that were dropped from the analysis can be found at the end of the file.
Note that the Python code included here is not meant to be run on its own. It is copied out of our main script "Reddit_MDA" and serves illustration purposes only.
*What still needs to be done:*
- add missing accuracy scores after next round of testing
- decide what to do with the features that had 0 hits in our sample data - keep them in the code without reporting an accuracy score? Or remove?
- decide what to do with whquest_013 and caps_204 (did not reach required accuracy level)
- complete the description for caps_204 (after Axel modified it)
- 033 pied piping can be dropped
- we often have the condition "if tagged_sentence[index-1][0] in ALLP" to catch sentence-initial structures. Should this not be " elif tagged_sentence[index-1][0] == "X"" ?? (same for sentence-final positions) -> if we decide to change this: update accuracy scores afterwards!
- someone needs to change this. Update the code in this file as well.
- wordlength_044: what are we replacing here and why?
- regex is fishy, replace in the main code with strip-string-punctuation
- whresub_031: do we have a hierarchy problem here? Condition that the noun needs to precede holds? Combine this and whreobj_032?
- I think this is why this feature does so badly in the accuracy test.
- whreobj_032: do we have a hierarchy problem here? Condition that the noun needs to precede holds?
- I think this is why this feature does so badly in the accuracy test.
- thatresub_029: are we missing the condition: item == "that" ?
- yes, we need to add a condition beforehand. Or restructure code for 029 and 031
- add code for ttratio_043 to main script and in here.
- we decided to not do this feature because of short text lenght. Delete it from the dictionary!
## Verbs in the past tense: vpast_001
- Definition from Biber: "Any past tense form that occurs in the dictionary, or any word not otherwise identified that is longer than six letters and ends in ed%. Past tense forms have been edited by hand to distinguish between those forms with past participial functions and those with past tense functions." (1988: 223)
- Example from Reddit: San Francisco is in America in case you *forgot* LOL.
- Our search stragey: everything that received the tag "VBD" (verb in the past tense) within the function analyze_verb.
```{python}
word_tuple = tagged_sentence[index]
if word_tuple[1] == "VBD":
features_dict["vpast_001"] += 1
```
- Accuracy: F-score of 0.75
## Verbs in the present perfect: vpresperfect_002a
- Definition from Biber:
"(a) HAVE + (ADV) + (ADV) + VBN
(b) HAVE+ N/PRO + VBN (questions)
(includes contracted forms of HAVE)" (1988: 223)
- Example from Reddit: There is no evolution, just a list of animals Chuck Norris *has allowed* to live.
- Our search strategy: Biber's feature 2 "perfect aspect" does not distinguish between present perfect and past perfect. We therefore decided to split this up into two features (002a and 002b). For the present perfect we count combinations of ["have", "'ve", "has"] plus verbs with the tag "VBN" (past participle of verb) within the function analyze_verb. We are allowing for an unspecified number of intervening adverbs and nouns.
```{python}
elif word_tuple[0] in ["have", "'ve", "has"]:
move_on = True
insert_adv = False
x = index
while move_on:
x += 1
if tagged_sentence[x][1] == "VBN":
move_on = False
features_dict["vpresperfect_002a"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
elif tagged_sentence[x][1].startswith("R") and tagged_sentence[x][0] not in ["n't", "not"]:
insert_adv = True
elif tagged_sentence[x][1].startswith("N") or tagged_sentence[x][1].startswith("P"):
move_on = True
else:
move_on = False
```
- Accuracy: F-score of 0.83
## Verbs in the past perfect: vpastperfect_002b
- Definition from Biber:
"(a) HAVE + (ADV) + (ADV) + VBN
(b) HAVE+ N/PRO +VBN (questions)
(includes contracted forms of HAVE)" (1988: 223)
- Example from Reddit: I *had* always *thought* they were great idea, [...]
- Our search strategy: Biber's feature 2 "perfect aspect" does not distinguish between present perfect and past perfect. We therefore decided to split this up into two features (002a and 002b). For the past perfect we count combinations of ["had", "'d"] plus verbs with the tag "VBN" (past participle of verb) within the function analyze_verb. We are allowing for an unspecified number of intervening adverbs and nouns.
```{python}
if word_tuple[0] in ["had", "'d"]:
move_on = True
insert_adv = False
x = index
while move_on:
x += 1
if tagged_sentence[x][1] == "VBN":
move_on = False
features_dict["vpastperfect_002b"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
elif tagged_sentence[x][1].startswith("R") and tagged_sentence[x][0] not in ["n't", "not"]:
insert_adv = True
elif tagged_sentence[x][1].startswith("N") or tagged_sentence[x][1].startswith("P"):
move_on = True
else:
move_on = False
```
- Accuracy: F-score of 0.60
## Verbs in the present tense: vpresent_003
- Definition from Biber: "All VB (base form) or VBZ (third person singular present) verb forms in the dictionary, excluding infinitives." (1988: 224)
- Example from Reddit: Dont even *care* about this game anymore.
- Our search stragey: Within the function analyze_verb we are counting everything with the tag "VBP" (Verb, non-3rd person singular present ) or "VBZ" (Verb, 3rd person singular present ).
```{python}
elif word_tuple[1] in ["VBP","VBZ"]:
features_dict["vpresent_003"] += 1
```
- Accuracy: F-score of 0.89
## Place adverbials: advplace_004
- Definition from Biber: aboard, above, abroad, across, ahead, alongside, around, ashore, astern, away, behind, below, beneath, beside, downhill, downstairs, downstream, east, far, hereabouts, indoors, inland, inshore, inside, locally, near, nearby, north, nowhere, outdoors, outside, overboard, overland, overseas, south, underfoot, underground, underneath, uphill, upstairs, upstream, west (1988: 224)
- Example from Reddit: *Below* it on the same side is what TCL/BlackBerry are calling a [...]
- Our search stragey: Within the function analyze_adverb we are counting everything that is in our list of place adverbials, "placelist". This list is defined beforehand and contains all the items listed by Biber (no further additions).
```{python}
placelist = ["aboard", "above", "abroad", "across", "ahead", "alongside", "anywhere", "ashore", "astern", "away", "behind", "below", "beneath", "between", "beyond", "beside", "down", "downhill", "downstairs", "downstream", "downwind", "east", "eastward", "eastwards", "elsewhere", "everywhere", "far", "here", "hereabouts", "indoors", "inland", "inshore", "inside", "locally", "near", "nearby", "north", "northward", "northwards", "nowhere", "offshore", "opposite", "outdoors", "outside", "overboard", "overhead", "overland", "overseas", "somewhere", "south", "southward", "southwards", "there", "thereabouts", "through", "throughout", "under", "underfoot", "underground", "underneath", "uphill", "upstairs", "upstream", "west", "westward", "westwards", "within"]
elif word_tuple[0] in placelist:
features_dict["advplace_004"] += 1
```
- Accuracy: F-score of 1.00
## Time adverbials on location in time: advtime_position_005a
- Definition from Biber: "afterwards, again, earlier, early, eventually, formerly, immediately, initially, instantly, late, lately, later, momentarily, now, nowadays, once, originally, presently, previously, recently, shortly, simultaneously, soon, subsequently, today, tomorrow, tonight, yesterday" (1988: 224)
- Example from Reddit: *Now* if we're talking about lavo, ovo or lavo-ovo vegetarians, yes, [...]
- Our search strategy: Biber's feature 5, "time adverbials" does not distinguish between adverbials relating to a specific point in time (e.g. "yesterday") and adverbials relating to the frequency of occurrence or duration of an event (e.g. "daily"). We therefore decided to split this feature into two, 005a and 005b. For advtime_position_005a we are looking for items that are in the list "timepoints" within the function analyze_adverb. This list was defined beforehand.
```{python}
timepoints = ["afterwards", "again", "already", "anymore", "before", "currently", "earlier", "early", "eventually", "formerly", "finally", "immediately", "initially", "instantly", "late", "lately", "later", "momentarily", "now", "nowadays", "originally", "presently", "previously", "promptly", "recently", "shortly", "simultaneously", "soon", "subsequently", "today", "tomorrow", "tonight", "yesterday"]
elif word_tuple[0] in timepoints:
features_dict["advtime_position_005a"] += 1
```
- Accuracy: F-score of 0.90
## Time adverbials on frequency: advtime_durfreq_005b
- Definition from Biber: "afterwards, again, earlier, early, eventually, formerly, immediately, initially, instantly, late, lately, later, momentarily, now, nowadays, once, originally, presently, previously, recently, shortly, simultaneously, soon, subsequently, today, tomorrow, tonight, yesterday" (1988: 224)
- Example from Reddit: I think the boxes *usually* ask for oil but you can use the exact same amount in butter.
- Our search strategy: Biber's feature 5, "time adverbials" does not distinguish between adverbials relating to a specific point in time (e.g. "yesterday") and adverbials relating to the frequency of occurrence or duration of an event (e.g. "daily"). We therefore decided to split this feature into two, 005a and 005b. For advtime_durfreq_005b we are looking for items that are in the list "timedurfreq" within the function analyze_adverb. This list was defined beforehand.
```{python}
timedurfreq = ["always", "annually", "ceaselessly", "commonly", "constantly", "continually", "continuously", "customarily", "daily", "eternally", "evermore", "endlessly", "forever", "fortnightly", "frequently", "habitually", "hourly", "infrequently", "intermittently", "irregularly", "invariably", "monthly", "never", "occasionally", "often", "oftentimes", "once", "periodically", "perpetually", "persistently", "rarely", "repeatedly", "routinely", "seldom", "sometimes", "twice", "unceasingly", "usually","weekly", "yearly"]
elif word_tuple[0] in timedurfreq:
features_dict["advtime_durfreq_005b"] += 1
```
- Accuracy: F-score of 0.80
## First-person pronouns: profirpers_006
- Definition from Biber: "I, me, we, us, my, our, myself, ourselves (plus contracted forms)" (1988: 225)
- Example from Reddit: Cool, just let *me* know if you change your mind
- Our search strategy: Within the function analyze_pronoun we are looking for everything that is part of the list "firstpersonlist". This list was defined beforehand, it contains the same items as listed in Biber.
```{python}
firstpersonlist = ["i", "me", "we", "us", "my", "our", "myself", "ourselves"]
elif word_tuple[0] in firstpersonlist:
features_dict["profirpers_006"] += 1
```
- Accuracy: F-score of 0.96
## Second-person pronouns: prosecpers_007
- Definition from Biber: "you, your, yourself, yourselves (plus contracted forms)" (1988: 225)
- Example from Reddit: *You* sound like a smug asshole that likes the smell of his own farts.
- Our search strategy: Within the function analyze_pronoun we are counting everything that is part of the lsit "secondpersonlist". This list was defined beforehand and contains the same items as mentioned in Biber.
```{python}
secondpersonlist = ["you", "yourself", "your", "yourselves"]
elif word_tuple[0] in secondpersonlist:
features_dict["prosecpers_007"] += 1
```
- Accuracy: F-score of 1.00
## Third-person pronouns: prothirper_008
- Definition from Biber: "she, he, they, her, him, them, his, their, himself, herself, themselves (plus contracted forms)" (1988: 225)
- Example from Reddit: People who want a cap in *their* ass that's who.
- Our search strategy: Within the function analyze_pronoun we are counting everything that is in the list "thirdpersonlist". This list was defined beforehand and contains the same items as listed in Biber.
```{python}
thirdpersonlist = ["she", "he", "they", "her", "him", "them", "his", "their", "himself","herself", "themselves"]
elif word_tuple[0] in thirdpersonlist:
features_dict["prothirdper_008"] += 1
```
- Accuracy: F-score of 1.00
## Pronoun 'it': proit_009
- Definition from Biber: not stated, presumably surface form "it" (1988: 225-226)
- Example from Reddit: Not much of a comment, I know, but *it*'s hard to comment on a story that I don't find interesting.
- Our search strategy: Within the function analyze_pronoun we are counting everything with the surface form "it".
```{python}
if word_tuple[0] == "it":
features_dict["proit_009"] += 1
```
- Accuracy: F-score of 0.97
## Demonstrative pronouns: prodemons_010
- Definition from Biber:
"(a) that/this/these/those + V/AUX/CL-P/TS/WHP/W (where that is not a relative pronoun)
(b) that's
(c) T# + that
(that in this last context was edited by hand to distinguish among demonstrative pronouns, relative pronouns, complementizers, etc.)" (1988: 226)
- Example from Reddit: *That*'s not Samuel l Jackson?
- Our search strategy: We first distinguish between ["this", "these", "those"] and the word "that", since "that" has more potential functions in the sentence. We then check whether the following item (with a potential intervening adjective) is a noun to sort out demonstrative determiners (see feature demonstr_051). All remaining items are counted as demonstrative pronouns. This is a slight deviation from Biber's approach. We included this code chunk within the function analyze_pronoun and within analyze_determiner to make sure we catch all cases, irrespective of the POS-tag that was assigned.
```{python}
if word_tuple[0] in ["this", "these", "those"]:
if tagged_sentence[index+1][1].startswith("NN"):
features_dict["demonstr_051"] += 1
elif tagged_sentence[index+1][1].startswith("JJ") and tagged_sentence[index+2][1].startswith("NN"):
features_dict["demonstr_051"] += 1
else:
features_dict["prodemons_010"] += 1
if word_tuple [0] == "that":
if tagged_sentence[index+1][1].startswith("NN"):
features_dict["demonstr_051"] += 1
elif tagged_sentence[index+1][1].startswith("JJ") and tagged_sentence[index+2][1].startswith("NN"):
features_dict["demonstr_051"] += 1
elif tagged_sentence[index+1][0] == "X":
features_dict["prodemons_010"] += 1
elif tagged_sentence[index+1][1].startswith("JJ"):
features_dict["prodemons_010"] += 0
else:
features_dict["prodemons_010"] += 1
```
- Accuracy: F-score of 0.78
## Indefinitve pronouns: proindef_011
- Definition from Biber: "anybody, anyone, anything, everybody, everyone, everything, nobody, none, nothing, nowhere, somebody, someone, something" (1988: 226)
- Example from Reddit: I agree, why would *anyone* outside a marketing department create a giant poster with such a bad pun.
- Our search strategy: We count everything that is in the list "indefpronounlist", which was defined above. The list contains the same items as given by Biber. We included this code within the analyze_noun function and the analyze_pronoun function, because the tagger seemed to be slightly inconsistent in its assignment.
```{python}
indefpronounlist = ["anybody", "anyone", "anything", "everybody", "everyone", "everything", "nobody", "none", "nothing", "nowhere", "somebody", "someone", "something"]
if word_tuple[0] in indefpronounlist:
features_dict["proindef_011"] += 1
```
- Accuracy: F-score of 1.00
## Pro-verb do: pverbdo_012
- Definition from Biber: "DO when NOT in the following constructions:
DO + (ADV) + V (DO as auxiliary)
ALL-P/TS/WHP + DO (DO as question)" (1988: 226)
- Example from Reddit: But when you *do*, he will definitely score for you.
- Our search strategy: Within the function analyze_verb we are first checking for forms of 'do'. Then we are only counting instances that are in sentence-final position, or that are followed by ["too", "this", "that", "it", "so"] in sentence-final position. This is a slight deviation from Biber's strategy.
```{python}
dolist = ["do", "does", "doing", "did", "done"]
if word_tuple[0] in dolist:
if tagged_sentence[index+1][1] == "X" or tagged_sentence[index+1][0] in ALLP:
features_dict["pverbdo_012"] += 1
elif tagged_sentence[index+1][0] in ["too", "this", "that", "it", "so"]:
if tagged_sentence[index+2][1] == "X" or tagged_sentence[index+2][0] in ALLP:
features_dict["pverbdo_012"] += 1
else:
pass
```
- Accuracy: F-score of 0.74
## WH-questions: whquest_013
- Definition from Biber: "CL-P/Tif + WHO + AUX (where AUX is not part of a contracted form)" (1988: 227)
- Example from Reddit: If Redskins get Williams...*where* is he playing?
- Our search strategy: Within the function analyze_wh_word we first select all items that have the tag "WRB" (wh-adverbs) and that occur in sentence-initial position or after punctuation. We count all structures that have a modal verb following ("Where will he go?"). We also count structure that have a form of 'be', 'have', or 'do' following ("When are you leaving?"). Out of all remaining structures we also count those that have "who" as wh-word, that have "what about", or that include the insertion "the hell" or "the fuck".
We decided to use the tag "WRB" instead of Biber's condition (part of "WHO") because it consistently identifies interrogative particles, including "who" if and only if it is an interrogative particle. We also decided that we want to look not only for sentence-initial uses, but for anything following clause-level punctuation (we use the tag "SYM" for that).
```{python}
if word_tuple[1] == "WRB":
if tagged_sentence[index-1][1] in ["X", "SYM"]:
if tagged_sentence[index+1][1] == "MD":
features_dict["whquest_013"] += 1
elif tagged_sentence[index+1][1].startswith("V"):
if tagged_sentence[index+1][0] in belist or tagged_sentence[index+1][0] in havelist or tagged_sentence[index+1][0] in dolist:
features_dict["whquest_013"] += 1
elif word_tuple[0] == "who":
features_dict["whquest_013"] += 1
elif tagged_sentence[index+1] == "the" and tagged_sentence[index+2] in ["hell", "fuck"]:
features_dict["whquest_013"] += 1
elif word_tuple[0] == "what" and tagged_sentence[index+1][0] == "about":
features_dict["whquest_013"] += 1
```
- Accuracy: F-score of
## Nominalisations: nominalis_014
- Definition from Biber: "All words ending in -tion#, -ment#, -ness#, or -ity# (plus plural forms)" (1988: 227)
- Example from Reddit: Denial that racism exists and how most people discuss it on a public forum could also be considered a mental *illness*.
- Our search strategy: Within the function analyze_noun we are checking for items that end in certain suffixes (same list as given in Biber).
```{python}
elif word_tuple[0].endswith("tions") or word_tuple[0].endswith("tion") or word_tuple[0].endswith("ments") or word_tuple[0].endswith("ment") or word_tuple[0].endswith("ness") or word_tuple[0].endswith("ity") or word_tuple[0].endswith("nesses") or word_tuple[0].endswith("ities"):
features_dict["nominalis_014"] += 1
```
- Accuracy: F-score of 0.71
## Nouns: nouns_016
- Definition from Biber: "All nouns included in the dictionary, excluding those forms counted as nominalizations or gerunds." (1988: 228)
- Example from Reddit: Good *lesson*.
- Our search strategy: Within the function analyze_nouns we are counting all items that were not previously identified as gerunds or nominalisations or indefinite pronouns. These are the same criteria as in Biber, except for the indefinite pronouns (which he does not mention).
```{python}
if word_tuple[0] in indefpronounlist:
features_dict["proindef_011"] += 1
if word_tuple[0].endswith("ing"): # or word_tuple[0].endswith("ings"): # removing plural form since gerund nouns only accept sing
if word_tuple[0] not in notgerundlist:
features_dict["gerund_015"] += 1
elif word_tuple[0].endswith("tions") or word_tuple[0].endswith("tion") or word_tuple[0].endswith("ments") or word_tuple[0].endswith("ment") or word_tuple[0].endswith("ness") or word_tuple[0].endswith("ity") or word_tuple[0].endswith("nesses") or word_tuple[0].endswith("ities"):
features_dict["nominalis_014"] += 1
else:
features_dict["nouns_016"] += 1
```
- Accuracy: F-score of 1.00
## Agentless passives: passagentl_017
- Definition from Biber:
"(a) BE + (ADV) + (ADV) + VBN
(b) BE + N/PRO + VBN (question form)" (1988: 228)
- Example from Reddit: Your submission *has been* automatically *removed* because you haven't registered with our steam bot to receive flair.
- Our search strategy: Our search strategy here might look rather complex. We are within the function analyze_verb and we implement two different checks.
- Check 1: We first check whether the item itself is a form of "be". The item needs to be either in sentence-initial position or following a wh-adverb ("WRB") in sentence-initial position (to include wh-questions such as "How was the parcel delivered?"). We then count all instances as agentless passives that have a past participle verb ("VBN") within the next five words and no trace of a by-phrase.
- Check 2: We first check whether the item itself is a form of "be") and eliminate uses as a main verb. Within all remaining structures we count everything that has a past participle following without a by-phrase in the next position.
```{python}
belist = ["be", "am", "are", "is", "was", "were", "been", "being", "'m", "'re"]
elif word_tuple[0] in belist and (index == 3 or (index == 4 and tagged_sentence[index-1][1] == "WRB")): # Questions with BE; the index positions take the three ("x", "x") tuples at the beginning of a sentence into account
add_index = 0
while add_index < 5 and (index + add_index) < (len(tagged_sentence)-1):
add_index+=1
if tagged_sentence[index+add_index][1] == "VBN":
if tagged_sentence[index+add_index+1][0] == "by":
features_dict["passby_018"] += 1
else:
features_dict["passagentl_017"] += 1
elif word_tuple[0] in belist:
if tagged_sentence[index+1][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
elif tagged_sentence[index+1][1] == "RB" and tagged_sentence[index+2][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
else:
move_on = True
insert_adv = False
x = index
while move_on == True:
x += 1
if tagged_sentence[x][1] == "VBN":
move_on = False
if tagged_sentence[x+1][0] == "by":
features_dict["passby_018"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
elif tagged_sentence[x+1][1] == "IN": # Here, provision is made for by-passive with intervening PPs: "was shot in the head by an unidentified suspect"
x += 1
move_on2 = True
while move_on2:
x += 1
if tagged_sentence[x+1][1].startswith("N") or tagged_sentence[x+1][1].startswith("DT"):
pass
elif tagged_sentence[x+1][0] == "by":
features_dict["passby_018"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
move_on2 = False
else:
features_dict["passagentl_017"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
move_on2 = False
else:
features_dict["passagentl_017"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
elif tagged_sentence[x][1].startswith("RB"):
if tagged_sentence[x][0] not in ["n't", "not"]:
insert_adv = True
else:
pass
else:
move_on = False
```
- Accuracy: F-score of 0.82
## By-passives: passby_018
- Definition from Biber:
"(a) BE + (ADV) + (ADV) + VBN + by
(b) BE + N/PRO + VBN + by (question form)" (1988: 228)
- Example from Reddit: [...] the joke that the latest Bin Laden "message" *has been manufactured* by Mediaset in Milan [...]
- Our search strategy: Our search strategy here might look rather complex. We are within the function analyze_verb and we implement two different checks.
- Check 1: We first check whether the item itself is a form of "be". The item needs to be either in sentence-initial position or following a wh-adverb ("WRB") in sentence-initial position (to include wh-questions such as "When was the food delivered by the driever?"). We then count all instances as by-passives that have a past participle verb ("VBN") within the next five words and a by-phrase following immediately afterwards.
- Check 2: We first check whether the item itself is a form of "be") and eliminate uses as a main verb. Within all remaining structures we count everything that has a past participle following and a by-phrase in the next position. We also allow for a prepositional phrase intervening between the verb and the by-phrase ("The food was delivered at lunchtime by the driever").
We therefore include more structures than Biber does.
```{python}
elif word_tuple[0] in belist and (index == 3 or (index == 4 and tagged_sentence[index-1][1] == "WRB")): # Questions with BE; the index positions take the three ("x", "x") tuples at the beginning of a sentence into account
add_index = 0
while add_index < 5 and (index + add_index) < (len(tagged_sentence)-1):
add_index+=1
if tagged_sentence[index+add_index][1] == "VBN":
if tagged_sentence[index+add_index+1][0] == "by":
features_dict["passby_018"] += 1
else:
features_dict["passagentl_017"] += 1
elif word_tuple[0] in belist:
if tagged_sentence[index+1][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
## allow for one intervening adverb for mainvbe_019
elif tagged_sentence[index+1][1] == "RB" and tagged_sentence[index+2][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
else:
move_on = True
insert_adv = False
x = index
while move_on == True:
x += 1
if tagged_sentence[x][1] == "VBN":
move_on = False
if tagged_sentence[x+1][0] == "by":
features_dict["passby_018"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
elif tagged_sentence[x+1][1] == "IN": # Here, provision is made for by-passive with intervening PPs: "was shot in the head by an unidentified suspect"
x += 1
move_on2 = True
while move_on2:
x += 1
if tagged_sentence[x+1][1].startswith("N") or tagged_sentence[x+1][1].startswith("DT"): # One might include adjectives here as well, but prob at the cost of precision.
pass
elif tagged_sentence[x+1][0] == "by":
features_dict["passby_018"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
move_on2 = False
else:
features_dict["passagentl_017"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
move_on2 = False
else:
features_dict["passagentl_017"] += 1
if insert_adv:
features_dict["vsplitaux_063"] += 1
elif tagged_sentence[x][1].startswith("RB"):
if tagged_sentence[x][0] not in ["n't", "not"]:
insert_adv = True
else:
pass
else:
move_on = False
```
- Accuracy: F-score of 0.71
## Main verb use of be: mainvbe_019
- Definition from Biber: "BE + DET/POSSPRO/TITLE/PREP/ADJ" (1988: 229)
- Example from Reddit: Also, they*'re* fake.
- Our search strategy: Within the function analyze_verb we first check whether the item is part of "belist". The list is defined beforehand and contains full and contracted forms of 'be' (except for 's which can serve several functions). We count the structure towards mainvbe_019 if the following item is tagged as ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"] (with one potential intervening adverbial). We then repeat these steps for all items with the surface form 's (since we don't want this as part of our "belist", which is used in several other functions). We therefore deviate from Biber in allowing for intervening adverbials and by giving special attention to 's (which is not part of Biber's list for "BE").
```{python}
belist = ["be", "am", "are", "is", "was", "were", "been", "being", "'m", "'re",]
elif word_tuple[0] in belist:
if tagged_sentence[index+1][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
elif tagged_sentence[index+1][1] == "RB" and tagged_sentence[index+2][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
if word_tuple[0] == "'s" or word_tuple[0] == "s":
if tagged_sentence[index+1][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
elif tagged_sentence[index+1][1] == "RB" and tagged_sentence[index+2][1] in ["DT", "PRP$", "JJ", "JJR", "JJS", "NN", "NNS", "NNP"]:
features_dict["mainvbe_019"] += 1
```
- Accuracy: F-score of 0.80
## Exitential 'there': exthere_020
- Definition from Biber:
"(a) there + (xxx) + BE
(b) there's" (1988: 229)
- Example from Reddit: I just wished *there* was other UHQ pics from that photoshoot.. Closeups would be nice too!
- Our search strategy: Within the function analyze_there we count everything with the tag "EX" (tag for existential there). We are therefore not implementing Biber's conditions, since the tag set contains a special tag for existential there.
```{python}
if tagged_sentence[index][1] == "EX":
features_dict["exthere_020"] += 1
```
- Accuracy: F-score of 0.95
## 'that' verb complements thatvcom_021
- Definition from Biber:
"(a) and/nor/but/or/also/ALL-P + that + DET/PRO/there/plural noun/proper noun/TITLE (these are that-clauses in clause-initial positions)
(b) PUB/PRV/SUA/SEEM/APPEAR + that + xxx (where xxx is NOT: V/AUX/CL-P/T#/and) (that-clauses as complements to verbs which are not included in the above verb classes are not counted - see Quirk et al. 1985:1179ff.)
(c) PUB/PRV/SUA + PREP + xxx + N + that (where xxx is any number of words, but NOT = N) (This algorithm allows an intervening prepositional phrase between a verb and its complement.)
(d) T# + that (This algorithm applies only to spoken texts. Forms in this context are checked by hand, to distinguish among that complements, relatives, demonstrative pronouns and subordinators.)" (1988: 230)
- Example from Reddit: Movies and TV shows have shown *that* weapon movement is independent from head movement.
- Our search strategy: Within the function analyze_preposition we first check whether the item is "that". If yes, we count the structure if it is in sentence-initial position or preceded by ["and", "nor", "but", "or", "who"], and it is followed by a noun phrase or title or the word "there". Alternatively, we count the structure if it is preceded by public, private, or suasive verb (or a form of 'seem' or 'appear'), and the item is not followed by "and", a verb or sentence-final punctuation.
We decided against implementing Biber's condition c) as it seems marginal to us and complicated to count correctly.
```{python}
if tagged_sentence[index][0] == "that":
# (a) and\nor\but\or\aho\ALL-P + that + DET/PRO/there/plural noun/proper noun/TITLE (these are i/za£-clauses in clause-initial positions)
if tagged_sentence[index-1][0] in ALLP or tagged_sentence[index-1][0] in ["and", "nor", "but", "or", "who"]:
if tagged_sentence[index+1][1] in ["DT", "PRP", "NNS", "NNP"] or tagged_sentence[index+1][0] in titlelist or tagged_sentence[index+1][0] == "there":
features_dict["thatvcom_021"] += 1
# (b) PUB/PRV/SUA/SEEM/APPEAR + that + xxx (where xxx is NOT: V/AUX/CL-P/and)
elif (tagged_sentence[index-1][0] in suasivelist) or (tagged_sentence[index-1][0] in privatelist) or (tagged_sentence[index-1][0] in publiclist):
if not tagged_sentence[index+1][1].startswith("V"):
if tagged_sentence[index+1][0] not in [ALLP, "and"]:
features_dict["thatvcom_021"] += 1
elif (tagged_sentence[index-1][0].startswith("seem")) or (tagged_sentence[index-1][0].startswith("appear")):
if not tagged_sentence[index+1][1].startswith("V"):
if tagged_sentence[index+1][0] not in [ALLP, "and"]:
features_dict["thatvcom_021"] += 1
```
- Accuracy: F-score of 0.80
## 'that' adjective complements thatacom_022
- Definition from Biber: "ADJ + (T#) + that (complements across intonation boundaries were edited by hand)" (1988: 231)
- Example from Reddit: I live in the country of reddit and I feel absolutely lucky *that* I see these exotic views everymorning.
- Our search strategy: Within the function analyze_preposition we count all cases where the item has the surface form "that" and the preceding item is tagged as an adjective. We sort out cases of verbal complementation beforehand.
```{python}
if tagged_sentence[index][0] == "that":
if tagged_sentence[index-1][0] in ALLP or tagged_sentence[index-1][0] in ["and", "nor", "but", "or", "who"]:
if tagged_sentence[index+1][1] in ["DT", "PRP", "NNS", "NNP"] or tagged_sentence[index+1][0] in titlelist or tagged_sentence[index+1][0] == "there":
features_dict["thatvcom_021"] += 1
elif (tagged_sentence[index-1][0] in suasivelist) or (tagged_sentence[index-1][0] in privatelist) or (tagged_sentence[index-1][0] in publiclist):
if not tagged_sentence[index+1][1].startswith("V"):
if tagged_sentence[index+1][0] not in [ALLP, "and"]:
features_dict["thatvcom_021"] += 1
elif (tagged_sentence[index-1][0].startswith("seem")) or (tagged_sentence[index-1][0].startswith("appear")):
if not tagged_sentence[index+1][1].startswith("V"):
if tagged_sentence[index+1][0] not in [ALLP, "and"]:
features_dict["thatvcom_021"] += 1
if tagged_sentence[index-1][1].startswith("J"):
features_dict["thatacom_022"] += 1
```
- Accuracy: F-score of 0.73
## WH-clauses: whclause_023
- Definition from Biber: "PUB/PRV/SUA + WHP/WHO + xxx (where xxx is NOT = AUX - this excludes WH questions)" (1988: 231)
- Example from Reddit: When the time comes, you will remember *where* to go.
- Our search strategy: Within the function analyze_verb we first select only cases in which the verb is a public verb (part of the list "publiclist" defined beforehand). If yes, we first exclude cases of that-deletion. If the following item is part of the list WHP or WHO (see definition below), and the item after that is not a modal verb we count it towards whclause_023.
This procedure is repeated for private verbs and suasive verbs.
```{python}
WHP = ["who", "whom", "whose", "which"]
WHO = ["what", "where", "when", "how", "whether", "why", "whoever", "whomever", "whichever", "whenever", "whatever", "however"]
if word_tuple[0] in publiclist:
features_dict["vpublic_055"] += 1
if tagged_sentence[index + 1][0] in ["this", "these", "those", "I", "we", "he", "she", "they"]:
features_dict["thatdel_060"] += 1
elif tagged_sentence[index + 1][1].startswith("NN") or tagged_sentence[index + 1][1].startswith("PR"):
if tagged_sentence[index + 2][1].startswith("V") or tagged_sentence[index + 2][1] == "MD":
features_dict["thatdel_060"] += 1
elif tagged_sentence[index + 1][1] in ["JJ", "JJR", "JJS", "RB", "RBR", "RBS", "PRP$", "DT"]:
if tagged_sentence[index + 2][1].startswith("NN"):
if tagged_sentence[index + 3][1].startswith("V") or tagged_sentence[index + 3][1] == "MD":
features_dict["thatdel_060"] += 1
if tagged_sentence[index + 1][0] in WHP or tagged_sentence[index + 1][0] in WHO:
if tagged_sentence[index + 2][1] != "MD":
features_dict["whclause_023"] += 1
else:
pass
if word_tuple[0] in privatelist:
features_dict["vprivate_056"] += 1
if tagged_sentence[index + 1][0] in ["this", "these", "that", "those", "I", "we", "he", "she", "they"]:
features_dict["thatdel_060"] += 1
elif tagged_sentence[index + 1][1].startswith("NN") or tagged_sentence[index + 1][1].startswith("PR"):
if tagged_sentence[index + 2][1].startswith("V") or tagged_sentence[index + 2][1] == "MD":
features_dict["thatdel_060"] += 1
elif tagged_sentence[index + 1][1] in ["JJ", "JJR", "JJS", "RB", "RBR", "RBS", "PRP$", "DT"]:
if tagged_sentence[index + 2][1].startswith("NN"):
if tagged_sentence[index + 3][1].startswith("V") or tagged_sentence[index + 3][1] == "MD":
features_dict["thatdel_060"] += 1
if tagged_sentence[index + 1][0] in WHP or tagged_sentence[index + 1][0] in WHO:
if tagged_sentence[index + 2][1] != "MD":
features_dict["whclause_023"] += 1
else:
pass
if word_tuple[0] in suasivelist:
features_dict["vsuasive_057"] += 1
if tagged_sentence[index + 1][0] in ["this", "these", "that", "those", "I", "we", "he", "she", "they"]:
features_dict["thatdel_060"] += 1
elif tagged_sentence[index + 1][1].startswith("NN") or tagged_sentence[index + 1][1].startswith("PR"):
if tagged_sentence[index + 2][1].startswith("V") or tagged_sentence[index + 2][1] == "MD":
features_dict["thatdel_060"] += 1
elif tagged_sentence[index + 1][1] in ["JJ", "JJR", "JJS", "RB", "RBR", "RBS", "PRP$", "DT"]:
if tagged_sentence[index + 2][1].startswith("NN"):
if tagged_sentence[index + 3][1].startswith("V") or tagged_sentence[index + 3][1] == "MD":
features_dict["thatdel_060"] += 1
if tagged_sentence[index + 1][0] in WHP or tagged_sentence[index + 1][0] in WHO:
if tagged_sentence[index + 2][1] != "MD":
features_dict["whclause_023"] += 1
else:
pass
```
- Accuracy: F-score of
## Verbs in the infinitive: vinfinitive_024
- Definition from Biber: "to + (ADV) + VB" (1988: 232)
- Example from Reddit: oh crap, that's right, need *to update* my links.
- Our search strategy: Within the function analyze_verb we first check for items tagges as VB (Verb, base form). We exclude all items in sentence-initial position or items following a comma. All remaining items are counted. We deviate from Biber in that we are not checking for the particle "to" to occur one or two to the left, since we rely on the tagger to correctly identify infinitives.
```{python}
elif word_tuple[1] == "VB":
if tagged_sentence[index-1][1] == "X" or tagged_sentence[index-1][0] == ",":
features_dict["vimperative_205"] += 1
else:
features_dict["vinfinitive_024"] += 1
```
- Accuracy: F-score of 0.67
## Past participial clauses: vpastpart_026
- Definition from Biber: "T#/ALL-P + VBN + PREP/ADV (these forms were edited by hand)" (1988: 233)
- Example from Reddit: *none in our sample data*
- Our search strategy: Within the function analyze_verb we are first looking for items with the tag "VBN" (Verb, past participle). The word is counted towards this feature if it is sentence-initial position and the following item is tagged as ["IN", "RB", "TO"]. We are therefore implementing the same strategy as Biber.
```{python}
elif word_tuple[1] == "VBN":
if (tagged_sentence[index-1][1] == "X" or tagged_sentence[index-1][0] in ALLP):
if tagged_sentence[index+1][1] in ["IN", "RB", "TO"]:
features_dict["vpastpart_026"] += 1
```
- Accuracy: F-score of
## that-relative clauses on subject position: thatresub_029
- Definition from Biber: "N + (T#) + that + (ADV) + AUX/V (that relatives across intonation boundaries are identified by hand.)" (1988: 234)
- Example from Reddit: I’m sure you could work a persona *that* didn’t have a pretty scowl… >:-D
- Our search strategy: Within the function analyze_wh_word we first check whether the preceding item has a nominal tag (all nominal tags start with "NN"). If yes we check whether the next item is a full verb or a modal verb. If these conditions are fulfilled the structure is counted towards the feature. We are also allowing for one intervening adverb (RB).
```{python}
if tagged_sentence[index-1][1].startswith("NN"):
if tagged_sentence[index+1][1].startswith("RB"):
if (tagged_sentence[index+2][1].startswith("V") or tagged_sentence[index+2][1].startswith("MD")):
features_dict["thatresub_029"] += 1
elif tagged_sentence[index+1][1].startswith("VB") or tagged_sentence[index+1][1].startswith("MD"):
features_dict["thatresub_029"] += 1
```
- Accuracy: F-score of 0.71
## WH-relative clauses on subject position: whresub_031
- Definition from Biber: "xxx + yyy + N + WHP + (ADV) + AUX/V (where xxx is NOT any form of the verbs ASK or TELL; to exclude indirect WH questions like Tom asked the man who went to the store)" (1988: 235)
- Example from Reddit: You really want help go to an al-anon meeting, support for codependent fools *who* put up with our shit.
- Our search strategy: *Within the function analyze_wh_word we ...* We then check whether our item is one of ["who", "whom", "whose", "which"]. If yes, we first exclude all instances of sentence relatives, pied piping, and relative clauses in subject position. For all remaining cases we exclude structures that have a form of 'ask' or 'tell' as main verb and that do not have a noun preceding. We then count all structures that are followed by a verb or modal (with one potential intervening adverb) towards whresub_031.
```{python}
if tagged_sentence[index-1][1].startswith("NN"):
if tagged_sentence[index+1][1].startswith("RB"):
if (tagged_sentence[index+2][1].startswith("V") or tagged_sentence[index+2][1].startswith("MD")):
features_dict["thatresub_029"] += 1
elif tagged_sentence[index+1][1].startswith("VB") or tagged_sentence[index+1][1].startswith("MD"):
features_dict["thatresub_029"] += 1
elif tagged_sentence[index+1][1].startswith("DT") or tagged_sentence[index+1][1].startswith("JJ") or tagged_sentence[index+1][1] == "NNS" or tagged_sentence[index+1][1].startswith("NNP"):
features_dict["thatreobj_030"] += 1
elif tagged_sentence[index+1][0] == "it" or tagged_sentence[index+1][0] in subjpro or tagged_sentence[index+1][0] in posspro:
features_dict["thatreobj_030"] += 1
else:
if word_tuple[0] in WHP: # WHP = ["who", "whom", "whose", "which"]
if tagged_sentence[index-1][1] == "IN":
features_dict["whrepied_033"] += 1
if word_tuple[0] == "which":
if tagged_sentence[index-1][0] == ",":
features_dict["sentencere_034"] += 1
elif index == 3 and tagged_sentence[4][1].startswith("V"):
if not tagged_sentence[4][0] in belist:
features_dict["sentencere_034"] += 1
#31. WH relative clauses on subject position (e.g., the man who likes popcorn) xxx + yyy + N + WHP + (ADV) + AUX/V
if tagged_sentence[index-1][1].startswith("N") and tagged_sentence[index-2][0] not in ["tell", "tells", "told", "telling", "ask", "asks", "asked", "asking"]:
if tagged_sentence[index+1][1].startswith("R"):
if (tagged_sentence[index+2][1].startswith("V") or tagged_sentence[index+2][1].startswith("MD")):
features_dict["whresub_031"] += 1
elif(tagged_sentence[index+1][1].startswith("V") or tagged_sentence[index+1][1].startswith("MD")):
features_dict["whresub_031"] += 1
```
- Accuracy:
## WH-relative clauses on object position: whreobj_032
- Definition from Biber: "xxx + yyy + N + WHP + zzz (where xxx is NOT any form of the verbs ASK or TELL, to exclude indirect WH questions, and zzz is not ADV, AUX or V, to exclude relativization on subject position)" (1988: 235)
- Example from Reddit: You didn't give any evidence and then proceeded to change your argument to something *which* I actually agree with.
- Our search strategy: *Within the function analyze_wh_word we ...* We then check whether our item is one of ["who", "whom", "whose", "which"]. If yes, we first exclude all instances of sentence relatives, pied piping, and relative clauses in subject position. For all remaining cases we exclude structures that have a form of 'ask' or 'tell' as main verb. We also exclude cases that have an adverb, verb, or modal following. All remaining structures are counted towards whreobj_032.
```{python}
if tagged_sentence[index-1][1].startswith("NN"):
if tagged_sentence[index+1][1].startswith("RB"):
if (tagged_sentence[index+2][1].startswith("V") or tagged_sentence[index+2][1].startswith("MD")):
features_dict["thatresub_029"] += 1
elif tagged_sentence[index+1][1].startswith("VB") or tagged_sentence[index+1][1].startswith("MD"):
features_dict["thatresub_029"] += 1
elif tagged_sentence[index+1][1].startswith("DT") or tagged_sentence[index+1][1].startswith("JJ") or tagged_sentence[index+1][1] == "NNS" or tagged_sentence[index+1][1].startswith("NNP"):
features_dict["thatreobj_030"] += 1
elif tagged_sentence[index+1][0] == "it" or tagged_sentence[index+1][0] in subjpro or tagged_sentence[index+1][0] in posspro:
features_dict["thatreobj_030"] += 1
else:
if word_tuple[0] in WHP: # WHP = ["who", "whom", "whose", "which"]
if tagged_sentence[index-1][1] == "IN":
features_dict["whrepied_033"] += 1
if word_tuple[0] == "which":
if tagged_sentence[index-1][0] == ",":
features_dict["sentencere_034"] += 1
elif index == 3 and tagged_sentence[4][1].startswith("V"):
if not tagged_sentence[4][0] in belist:
features_dict["sentencere_034"] += 1
#31. WH relative clauses on subject position (e.g., the man who likes popcorn) xxx + yyy + N + WHP + (ADV) + AUX/V
if tagged_sentence[index-1][1].startswith("N") and tagged_sentence[index-2][0] not in ["tell", "tells", "told", "telling", "ask", "asks", "asked", "asking"]:
if tagged_sentence[index+1][1].startswith("R"):
if (tagged_sentence[index+2][1].startswith("V") or tagged_sentence[index+2][1].startswith("MD")):
features_dict["whresub_031"] += 1
elif(tagged_sentence[index+1][1].startswith("V") or tagged_sentence[index+1][1].startswith("MD")):
features_dict["whresub_031"] += 1
#32. WH relative clauses on object positions
if not tagged_sentence[index-3][0].startswith("ask") and not tagged_sentence[index-3][0].startswith("tell") and not tagged_sentence[index-3][0] == "told":
if not tagged_sentence[index+1][1].startswith("R") and not tagged_sentence[index+1][1].startswith("V") and not tagged_sentence[index+1][1].startswith("MD"):
if tagged_sentence[index-1][1].startswith("N"):
features_dict["whreobj_032"] += 1
```
- Accuracy: F-score of
## Pied-piping relative clauses: whrepied_033
- Definition from Biber: "PREP + WHP" (1988: 235)
- Example from Reddit: Example from Biber: "the manner *in which* he was told" (Biber 1988: 235)
- Our search strategy: Within the function analyze_wh_word we first exclude all structures that follow a noun. In the remaining structures we check whether the item is part of ["who", "whom", "whose", "which"], and whether the preceding item is tagged as "IN" (Preposition or subordinating conjunction). If yes then the structure is counted as pied-piping. We therefore don't deviate from Biber's strategy.
```{python}
if tagged_sentence[index-1][1].startswith("NN"):
else:
if word_tuple[0] in WHP:
if tagged_sentence[index-1][1] == "IN":
features_dict["whrepied_033"] += 1
```
- Accuracy: F-score of
## Sentence relatives: sentencere_034
- Definition from Biber: "T#/, + which (These forms are edited by hand to exclude non-restrictive relative clauses.)" (1988: 235)
- Example from Reddit: *Which* is why we will be sending our military forces their way.
- Our search strategy: Within the function analyze_wh_word we first exclude all structures that follow a noun. We then check whether the item is part of ["who", "whom", "whose", "which"]. Next we exlude all structures that follow a preposition (which are pied-piping). We then narrow it down further to only items which are "which". These are counted either if they follow a comma or if they are in sentence-initial position and the next items is a verb (except be). We are therefore adding more conditions than Biber since we cannot afford manual analysis.
```{python}
if tagged_sentence[index-1][1].startswith("NN"):
else:
if word_tuple[0] in WHP:
if tagged_sentence[index-1][1] == "IN":
features_dict["whrepied_033"] += 1
if word_tuple[0] == "which":
if tagged_sentence[index-1][0] == ",":
features_dict["sentencere_034"] += 1
elif index == 3 and tagged_sentence[4][1].startswith("V"):
if not tagged_sentence[4][0] in belist:
features_dict["sentencere_034"] += 1
```
- Accuracy: F-score of 0.71
## Causative adverbial subordinators: advsubcause_035
- Definition from Biber: not stated, presumably surface form "because" (1988: 236)
- Example from Reddit: *Because* the Canucks gave the Flames the best offer.
- Our search strategy: Within the function analyze_preposition we check whether the item is "because" (or one of its spelling variants). We count all hits except the ones that are followed by "of".
```{python}
if word_tuple[0] in ["because", "becuase", "beacuse", "cause", "'cause", "cos", "'cos", "coz", "'coz", "caus", "'caus", "cuz", "'cuz", "bcoz", "bcuz", "bcos", "bcause", "bcaus"] and tagged_sentence[index+1][0] != "of":
features_dict["advsubcause_035"] += 1
# AB: I decided against a separate feature for "because of" since it goes into "prepositions_039".
# HM: I don't understand what this means. Biber (1988: 236-237) does not list "because of" as a preposition (even though it is an obvious contender),
# and it is purposefully excluded in the list above for "prepositions_039". Right now we are not counting "because of" at all, are we?
```
- Accuracy: F-score of 0.89
## Concessive adverbial subordinators: advsubconc_036
- Definition from Biber: not stated, presumably surface forms "although" or "though" (1988: 236)
- Example from Reddit: The parka copes fine with the rain, *although* I haven't been caught in any thunderstorms yet!
- Our search strategy: Within the function analyze_preposition we count all items with the surface form "although", "though" and "tho". We therefore deviate from Biber in including 'tho' and in checking for the word class preposition first.
```{python}
elif word_tuple[0] == "although" or word_tuple[0] == "though" or word_tuple[0] == "tho":
features_dict["advsubconc_036"] += 1
```
- Accuracy: F-score of 0.80
## Conditional adverbial subordinators: advsubcond_037
- Definition from Biber: not stated, presumably surface forms "if" or "unless" (1988: 236)
- Example from Reddit: *If* Redskins get Williams...where is he playing?
- Our search strategy: Within the function analyze_sentence we are checking for "if" and "unless" either in sentence-medial or sentence-initial position.
```{python}
for advsubcond in [" if ", " unless ", " if, ", " unless, "]:
features_dict["advsubcond_037"] += sentence.count(advsubcond)
if sentence.startswith("if ") or sentence.startswith("if, ") or sentence.startswith("unless ") or sentence.startswith("unless, "):
features_dict["advsubcond_037"] += 1
```
- Accuracy: F-score of 1.00
## Other adverbial subordinators: advsubother_038
- Definition from Biber: "since, while, whilst, whereupon, whereas, whereby, such that, so that xxx, such that xxx, inasmuch as, forasmuch as, insofar as, insomuch as, as long as, as soon as (where xxx is NOT: N/ADJ)" (1988: 236)
- Example from Reddit: Just *as long as* you have a good time and enjoy your week here, you can't let anyone down!
- Our search strategy: Within the function analyze_preposition we check for all the single-word items that are part of Biber's list, they are included in the list "oteradvsublist". We also count all cases where the item itself is "that" and the preceding item is "such" or "so", to catch "such that" and "so that". All other items listed by Biber are searched via the analyze_sentence function (so using the untagged string of characters). Here we check for all surface forms. The only exceptions are "as long as" and "as soon as", which are counted only in sentence-initial position (to avoid uses in which the second item is a true adjective, e.g. "the key was as long as a pencil")
```{python}
otheradvsublist = ["since", "while", "whilst", "whereupon", "whereas", "whereby"]
## within the function analyze_preposition
elif word_tuple[0] == "that" and tagged_sentence[index-1][0] in ["such", "so"]:
features_dict["advsubother_038"] += 1
if word_tuple[0] in otheradvsublist:
features_dict["advsubother_038"] += 1
## within the function analyze_sentence
for advsub in ["inasmuch as", "forasmuch as", "insofar as", "insomuch as", " as long as ", " as soon as "]:
features_dict["advsubother_038"] += sentence.count(advsub)
if sentence.startswith("as long as ") or sentence.startswith("as soon as "):
features_dict["advsubother_038"] += 1
```
- Accuracy:
## Prepositions: prepositions_039
- Definition from Biber: "against, amid, amidst, among, amongst, at, besides, between, by, despite, during, except, for, from, in, into, minus, notwithstanding, of, off, on, onto, opposite, out, per, plus, pro, re, than, through, throughout, thru, to, toward, towards, upon, versus, via, with, within, without" (1988: 236-237)
- Example from Reddit: I clap *during* the Friends theme song.
- Our search strategy: Within the function analyze_preposition we are counting all items that are not one of ["because", "unless", "whilst", "while", "though", "tho", "although", "that", "since", "whereupon", "whereas", "whereby"] (because these are often or always conjunctins) and that are not parts of our list of adverbs of time and place. We therefore deviate significantly from Biber's procedure, as he looks for a finite list of items that he considers to be preposition. Again we rely more on our parts-of-speech tagger.
```{python}
if not word_tuple[0] in ["because", "unless", "whilst", "while", "though", "tho", "although", "that", "since", "whereupon", "whereas", "whereby"] + timepoints + timedurfreq + placelist:
features_dict["prepositions_039"] += 1
```
- Accuracy: F-score of 0.87
## Attributive adjectives: adjattr_040
- Definition from Biber: "ADJ + ADJ/N (+ any ADJ not identified as predicative - no. 41)" (1988: 238)
- Example from Reddit: All the documentaries I've seen, like FRONTLINE, paint Trump in a very *different* light.
- Our search strategy: Within the function analzye_adjective we set all adjectives to predicative as the default. We then look at the following items and only change the value to attributive if it is followed by a string of nouns or a string of adjectives + noun (which can also be separated by a come). We then count all structures that have the value attributive
We also tried this the other way around (starting with attributive as the default), but the results were less accurate.
```{python}
adj_type = "pred"
forward = 1
while tagged_sentence[index+forward][1].startswith(("N","J")) or tagged_sentence[index+forward][0] == ",":
if tagged_sentence[index+forward][1].startswith("N"):
adj_type = "attr"
forward += 1
if adj_type == "attr":
features_dict["adjattr_040b"] += 1
elif adj_type == "pred":
features_dict["adjpred_041b"] += 1
```
- Accuracy: F-score of 0.91
## Predicative adjectives: adjpred_041
- Definition from Biber:
"(a) BE + ADJ + xxx (where xxx is NOT ADJ, ADV, or N)
(b) BE + ADJ + ADV + xxx (where xxx is NOT ADJ or N)" (1988: 238)
- Example from Reddit: Updating the getmonero.org site would be *awesome*!
- Our search strategy: Within the function analzye_adjective we set all adjectives to predicative as the default. We then look at the following items and only change the value to attributive if it is followed by a string of nouns or a string of adjectives + noun (which can also be separated by a come). We then count all structures that still have the value predicative.
We also tried this the other way around (starting with attributive as the default), but the results were less accurate.
```{python}
adj_type = "pred"
forward = 1
while tagged_sentence[index+forward][1].startswith(("N","J")) or tagged_sentence[index+forward][0] == ",":
if tagged_sentence[index+forward][1].startswith("N"):
adj_type = "attr"
forward += 1
if adj_type == "attr":
features_dict["adjattr_040b"] += 1
elif adj_type == "pred":
features_dict["adjpred_041b"] += 1
```
- Accuracy: F-score of 0.75
## Adverbs: adverbs_042
- Definition from Biber: "Any adverb form occurring in the dictionary, or any form that is longer than five letters and ends in -ly. The count for total adverbs excludes those adverbs counted as instances of hedges, amplifiers, downtoners, amplifiers, place adverbials, and time adverbials." (1988: 238)
- Example from Reddit: Let it *never* be said that I am an impatient man.
- Our search strategy: Within the function analyze_adverb we count all items that are caught by this function, so all items that receive the tag "RB" (advber), "RBR" (adverb, comparative), or "RBS" (adverb, superlative). This is a deviation from Biber, since we are not excluding the words covered by other features, and we are not checking for items in a dictionary (+ items longer than five letters ending in -ly), because we trust the accuracy of our parts-of-speech tagger.
```{python}
features_dict["adverbs_042"] += 1
```
- Accuracy:
## Type-token ratio: ttratio_043
- Definition from Biber: "This feature is computed by counting the number of different lexical items that occur in the first 400 words of each text, and then dividing by four; texts shorter than 400 words are not included in the present analysis." (1988: 238-239)
- Our search strategy:
*apparently not in our script?*
```{python}
```
- Accuracy: this was not coded manually and therefore not checked for accuracy.
## Word length: wordlength_044
- Definition from Biber: "mean length of the words in a text, in orthographic letters" (1988: 239)
- Our search strategy: Within the function analyze_sentence we count the length of all words in characters and divide it by the number of words in the sentence. *We deviate from Biber in that we delete everything that is not ... beforehand.*
```{python}
words = sent.split()
sum_wordlen = 0
for word in words:
word = re.sub(r'[^\w\s]','', word)
wordlen = len(word)
sum_wordlen = sum_wordlen + wordlen
features_dict["wordlength_044"] = (sum_wordlen/len(words))
```
- Accuracy: this was not coded manually and therefore not checked for accuracy.
## Conjuncts: conjuncts_045
- Definition from Biber:
"alternatively, altogether, consequently, conversely, eg, e.g., else, furthermore, hence, however, i.e., instead, likewise, moreover, namely, nevertheless, nonetheless, notwithstanding, otherwise, rather, similarly, therefore, thus, viz.
in + comparison/contrast /particular /addition /conclusion /consequence /sum /summary/ any event/ any case/ other words
for + example /instance
by + contrast / comparison
as a + result/consequence
on the + contrary/other hand
ALL-P/T# + that is/else / altogether+ T#,
ALL-P/T# + rather + T#/,/xxx (where xxx is NOT: ADJ/ADV)" (1988: 239)
- Example from Reddit: *However*, I would be happy if the race for President was between those two.
- Our search strategy: All of the one-word items listed by Biber that do not have punctuation attached to them are searched for within the analyze_adverb function. We count all items that have a surface form which is part of the list "conjunctslist", which we defined beforehand. The items in the list are the same as listed by Biber. The two-word items and the words with punctuation are searched for within the analyze_sentence function (so using the untagged string of characters forming the sentence).
```{python}
conjunctslist = ["alternatively", "altogether", "consequently", "conversely", "eg", "e.g.", "else", "furthermore",
"hence", "however", "ie", "i.e.", "instead", "likewise", "moreover", "namely", "nevertheless",
"nonetheless", "notwithstanding", "otherwise", "rather", "similarly", "therefore", "thus", "viz"]
## within the function analyze_adverb
elif word_tuple[0] in conjunctslist:
features_dict["conjuncts_045"] += 1
## within the function analyze_sentence