diff --git a/PapersCited.py b/PapersCited.py index aeebe3f..f5dcad2 100644 --- a/PapersCited.py +++ b/PapersCited.py @@ -43,6 +43,8 @@ class PhrasesToChange: "suradnicima": "sur.", "suradnici": "sur.", "suradnika": "sur.", + # Change possesive form to a proper noun + "'s" : "" } # Before adding something to excluded phrases, Google [word] surname. # If anything shows up, don't include that word. diff --git a/tests/test_detecting_authors.py b/tests/test_detecting_authors.py index c025dbc..068aa57 100644 --- a/tests/test_detecting_authors.py +++ b/tests/test_detecting_authors.py @@ -152,4 +152,23 @@ def test_new_foreign_characters(): ["Bø (1999", "Yø (2000", "Så (2001"] text_non_alphanumeric = "Bø's (1999) research cited Yø-yoma (2000)" assert PapersCited.get_matches_solo_author(text_non_alphanumeric).citations ==\ - ["Bø's (1999", "Yø-yoma (2000"] \ No newline at end of file + ["Bø's (1999", "Yø-yoma (2000"] + +def test_possesive_recognised_and_adjusted(): + possesive_text = "Listen to Cohen's (1999) talk." + matches = PapersCited.get_matches_solo_author(possesive_text) + matches.cleanup() + assert matches.citations == ["Cohen 1999"] + # When both possesive and regular form are cited, this should result in a single, + # proper form citation. + possesive_and_regular = "Listen to Cohen's (1999) talk. Or read Cohen (1999)" + matches = PapersCited.get_matches_solo_author(possesive_and_regular) + matches.cleanup() + assert matches.citations == ["Cohen 1999"] + +def test_surnames_apostrophe_s_recognised(): + text = "O'Sullivan (2000) wrote a paper. Compare it to O'Samuel's (1999) work." + matches = PapersCited.get_matches_solo_author(text) + matches.cleanup() + assert matches.citations == ["O'Samuel 1999", "O'Sullivan 2000"] + \ No newline at end of file