Changes between Initial Version and Version 1 of en/AdvancedNlpCourse2015/Stylometry

Sep 11, 2017, 4:34:19 PM (4 years ago)
Ales Horak

copied from private/AdvancedNlpCourse/Stylometry


  • en/AdvancedNlpCourse2015/Stylometry

    v1 v1  
     1= Stylometry =
     3[[|IA161]] [[en/AdvancedNlpCourse|Advanced NLP Course]], Course Guarantee: Aleš Horák
     5Prepared by: Honza Rygl
     7== State of the Art ==
     9The analysis of author's characteristic
     10writing style and vocabulary has been used to uncover author's traits such as authorship, age, or gender
     11documents by both manual linguistic approaches and automatic algorithmic methods.
     13The most common approach to stylometry problems
     14is to combine stylistic analysis with machine learning techniques:
     15 1. specific style markers are extracted,
     16 2. a classification procedure is applied to extracted markers
     19=== References ===
     21 1. Stamatatos, E. (2009), A Survey of Modern Authorship Attribution Methods (2009), Journal of the American Society for Information Science and Technology, 60(3), 538-556. [[ | pdf]]
     22 2. Kestemont, M. (2014), Function Words in Authorship Attribution From Black Magic to Theory? Proceedings of the 3rd Workshop on Computational Linguistics for Literature, EACL 2014, 59–66 [[ | pdf]]
     23 1. Walter, D.  Explanation in Computational Stylometry
     25== Practical Session ==
     27Student will get to know a *Style & Identity Recognition* tool. They will test this tool on prepared data.
     28Their goal will be to implement a small function to extract style markers from a text.
     301. go to `` server:
     342. Download a  [[htdocs:bigdata/|python package with the assignment]]
     353. Unzip the downloaded file
     394. Go to the unziped folder
     41cd sir-assignment
     435. Test the prepared program that analyses data from on-line dating services to distinguish gender (masculine/feminine) by text style features
     48`` can have two optional parameters:
     50./  [number_of_testing_cycles]  [show_first_N_erroneously_predicted_documents]
     52The default values, i.e. running `./` without parameters, are `100` cycles and `no documents` (`./ 100 0`). For faster feature testing even `./ 10` should be sufficient.
     54Example with document output:
     56[xrygl@asteria04:~/temp/sir-assignment]$ ./ 10 1
     57author: on
     58text: Ahoj, (nejen) pro výlety do víru podivnězimního velkoměsta, či divočiny
     59venkova, hledá se partnerka přiměřených rozměrů, tvarů a úrovně. Slečny veselé
     60povahy preferovány; ona je to nejspíš nutnost :-)
     61morphology: ((u'<s>', u'<s>'), (u'Ahoj', u'N.N.I.S.1.-.-.-.-.-.A.-.-.-.-'),
     62(u',', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'), (u'(',
     63u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'), (u'nejen', u'T.T.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     64(u')', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'), (u'pro',
     65u'R.R.-.-.4.-.-.-.-.-.-.-.-.-.-'), (u'v\xfdlety',
     66u'N.N.I.P.4.-.-.-.-.-.A.-.-.-.-'), (u'do', u'R.R.-.-.2.-.-.-.-.-.-.-.-.-.-'),
     67(u'v\xedru', u'N.N.I.S.2.-.-.-.-.-.A.-.-.-.-'), (u'podivn\u011bzimn\xedho',
     68u'A.A.N.S.2.-.-.-.-.1.A.-.-.-.-'), (u'velkom\u011bsta',
     69u'N.N.N.S.2.-.-.-.-.-.A.-.-.-.-'), (u',', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     70(u'\u010di', u'J.^.-.-.-.-.-.-.-.-.-.-.-.-.-'), (u'divo\u010diny',
     71u'N.N.F.S.2.-.-.-.-.-.A.-.-.-.-'), (u'venkova',
     72u'N.N.I.S.2.-.-.-.-.-.A.-.-.-.-'), (u',', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     73(u'hled\xe1', u'V.B.-.S.-.-.-.3.P.-.A.A.-.-.-'), (u'se',
     74u'P.7.-.X.4.-.-.-.-.-.-.-.-.-.-'), (u'partnerka',
     75u'N.N.F.S.1.-.-.-.-.-.A.-.-.-.-'), (u'p\u0159im\u011b\u0159en\xfdch',
     76u'A.A.I.P.2.-.-.-.-.1.A.-.-.-.-'), (u'rozm\u011br\u016f',
     77u'N.N.I.P.2.-.-.-.-.-.A.-.-.-.-'), (u',', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     78(u'tvar\u016f', u'N.N.I.P.2.-.-.-.-.-.A.-.-.-.-'), (u'a',
     79u'J.^.-.-.-.-.-.-.-.-.-.-.-.-.-'), (u'\xfarovn\u011b',
     80u'N.N.F.S.2.-.-.-.-.-.A.-.-.-.-'), (u'.', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     81(u'<s>', u'<s>'), (u'Sle\u010dny', u'N.N.F.P.1.-.-.-.-.-.A.-.-.-.-'),
     82(u'vesel\xe9', u'A.A.N.S.1.-.-.-.-.1.A.-.-.-.-'), (u'povahy',
     83u'N.N.F.S.2.-.-.-.-.-.A.-.-.-.-'), (u'preferov\xe1ny',
     84u'V.s.T.P.-.-.-.X.X.-.A.P.-.-.-'), (u';', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     85(u'ona', u'P.P.F.S.1.-.-.3.-.-.-.-.-.-.-'), (u'je',
     86u'V.B.-.S.-.-.-.3.P.-.A.A.-.-.-'), (u'to', u'P.D.N.S.1.-.-.-.-.-.-.-.-.-.-'),
     87(u'nejsp\xed\u0161', u'D.g.-.-.-.-.-.-.-.3.A.-.-.-.-'), (u'nutnost',
     88u'N.N.F.S.1.-.-.-.-.-.A.-.-.-.-'), (u':', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'),
     89(u'-', u'Z.:.-.-.-.-.-.-.-.-.-.-.-.-.-'), (u')',
     91Acc: 73.7 +- 2.2% (baseline 50.0%, 10 iterations)
     94=== Task ===
     95Examine files in  `stylometry_features` folder.
     96Modify the `` file to increase the accuracy of methods.
     97You can create another classes inside, change their names and class names to improve the accuracy score. Don't forget to add new classes into the `assignments` list in this file.
     99Suggestions for your inspiration include:
     100 * diacritics usage (yes/no), a regular expression will be needed
     101 * sentence endings (number of sentences, or typical endings)
     102 * repetitions of words in sentences/in the text
     103 * usage of uppercase letters
     104 * length of sentences/text
     105 * POS tags (n-grams)
     106 * word n-grams
     107 * character n-grams
     109Each modification can be tested by running `./` again.
     110The first call of `` can be slower, because documents are morphologically analysed during the first run.
     112Submit your assignment file. Write nice Python code and don't forget about PEP8 (