{"id":246,"date":"2019-03-27T11:03:09","date_gmt":"2019-03-27T17:03:09","guid":{"rendered":"http:\/\/briancroxall.net\/w19dh\/?page_id=246"},"modified":"2019-04-04T16:30:22","modified_gmt":"2019-04-04T22:30:22","slug":"topic-modeling","status":"publish","type":"page","link":"https:\/\/briancroxall.net\/w19dh\/assignments\/topic-modeling\/","title":{"rendered":"Topic Modeling Duffy"},"content":{"rendered":"<h2>Rationale<\/h2>\n<p>We have completed our reading of Carol Ann Duffy&#8217;s first five books, and we&#8217;ve gotten a closer look at various poems as we&#8217;ve <a href=\"http:\/\/briancroxall.net\/w19dh\/assignments\/tei-markup\/\">marked them up with TEI<\/a>. I&#8217;m guessing that most of us could now begin to put together a pretty <a href=\"http:\/\/briancroxall.net\/w19dh\/assignments\/puzzling-out-duffys-poetry\/\">cogent argument<\/a> about whether or not\u00a0<em>The World&#8217;s Wife<\/em> differs from the volumes that preceded it. This argument would no doubt be based on particular poems that stuck in our memories, themes that we traced across the volumes, the sequencing of the poems, and any of the other things we discussed in our close readings. We would certainly be interested in her use of language since, after all,\u00a0that is what poetry is all about (if we are being incredibly reductive).<\/p>\n<p>But in our digital humanities class, we have more tools at our disposal for considering language, and one of them is topic modeling. From our reading, we know that the topics created from LDA are, as <a href=\"http:\/\/journalofdigitalhumanities.org\/2-1\/what-can-topic-models-of-pmla-teach-us-by-ted-underwood-and-andrew-goldstone\/\">Andrew Goldstone and Ted Underwood put it<\/a>, &#8220;neither more nor less than a pattern of co-occuring words.&#8221; And from our other reading, we know that topic models are, first, not necessarily designed for literary language, and, second, a radical simplification of poetry (which is <em>not<\/em> all about language). Nevertheless, in our quest to understand potential differences between\u00a0<em>The World&#8217;s Wife<\/em> and Duffy&#8217;s other books of poetry, topic modeling provides us with a chance to consider patterns of linguistic affinity and difference that are not especially visible to the human eye. In short, it&#8217;s worth a shot!<\/p>\n<h2>Nitty Gritty<\/h2>\n<p>For this assignment, you will produce several topic models of Duffy&#8217;s poetry and begin the process of analyzing them.\u00a0The assignment has one outcome: a blog post. The blog post is due <strong>at the end of class on Monday, 1 April<\/strong>.\u00a0<\/p>\n<h3>Step One: Get the Data<\/h3>\n<p>Download the Duffy data from our repository in the <a href=\"https:\/\/github.com\/briancroxall\/duffy2019\/tree\/master\/cleaned-data\">cleaned-data folder<\/a>. (If you sync your GitHub repo that you will have the files on your local hard drive.) I have removed the XML from our TEI editions and then combined our 60 marked-up poems with those marked-up by my 2018 class to get all 204 poems in a single data set.<\/p>\n<ul>\n<li><code>2019-cleaned-simple.zip<\/code> takes this content\u00a0and\n<ul>\n<li>lowercases the text<\/li>\n<li>fixes curly apostrophes and single-character ellipsis to be standardized as straight apostrophes and &#8216; . . . &#8216;, respectively<\/li>\n<li>tokenizes\u00a0the text (which, put <em>very<\/em> inaccurately is a fancy way of saying that it breaks the words apart from the punctuation so we don&#8217;t get grams like &#8216;cannot,&#8217;)<\/li>\n<li>strips the punctuation from the text<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Step\u00a0 Two: Model the Data<\/h3>\n<p>Using MALLET and the <a href=\"http:\/\/briancroxall.net\/w19dh\/topic-modeling-step-by-step\/\">Step-by-Step Guide to Topic Modeling<\/a>, make at least 5 different topic models of Duffy&#8217;s poetry. Experiment with some or all of the following:<\/p>\n<ul>\n<li>the number of topics<\/li>\n<li>using and\u00a0<strong><em>not <\/em><\/strong>using\u00a0stopwords; consider whether you need to supplement MALLET&#8217;s default stopword list (viewable in the MALLET directory &gt; stoplists &gt; en.txt) with an additional stopwords file.<\/li>\n<li>the number of iterations you run<\/li>\n<li>whether or not you use the <code>--optimize-interval<\/code> flag<\/li>\n<\/ul>\n<p>Make sure that you keep careful records of the different commands you use to create each of the different models.<\/p>\n<h3>Step Three: Analyze the Data<\/h3>\n<p>After making each model, look at the topic keys to see if there seem to be too few topics or too many. Too many topics tend to be easier to spot insofar as you will have two or more topics that look relatively similar to one another. For example, if you have three &#8220;body words&#8221; topics, you should probably run the model with fewer topics. Too few topics can be spotted by there not being especially clear patterns to the topic keys. (That said, since we are working with poetry rather than academic articles, the clarity of such &#8220;clear patterns&#8221; is not guaranteed.)<\/p>\n<p>When you have a model with topic keys that seems workable, open the topic composition file in Excel. Insert a row at the top of the spreadsheet and name the columns to make them easy to work with. See which documents (AKA poems) rank high for the various topics. Do the poems that are grouped together surprise you? Do you see any patterns based on volume the poems are published in? Is there one topic that seems to be high for a lot more poems than you would expect? (This often happens and represents what I sometimes call\u00a0the &#8220;English language&#8221; topic. This becomes easier to spot if you&#8217;ve used the\u00a0<code>--optimize-interval<\/code> command.)<\/p>\n<p>As always, please be especially attuned to the differences that may or may not exist between Duffy&#8217;s first four volumes and\u00a0<em>The World&#8217;s Wife<\/em>.<\/p>\n<h3>Step Four: Visualize the Data<\/h3>\n<p>Pick three favorite poems from Duffy&#8217;s work, using at least two of her books. Do one or more of the following:<\/p>\n<ul>\n<li>Make a pie chart for each of the poems, showing which topics comprise the poem using Excel and the guidelines in Miriam Posner&#8217;s &#8220;<a href=\"http:\/\/miriamposner.com\/blog\/very-basic-strategies-for-interpreting-results-from-the-topic-modeling-tool\/\">Very basic strategies for interpreting results from the Topic Modeling Tool<\/a>&#8220;<\/li>\n<li>Identify the three most prominent topics for each poem, according to your model. Using the topic keys, color-code the terms in the poem that come from the particular topic, similar to what Lisa M. Rhody does for Anne Sexton&#8217;s &#8220;The Starry Night&#8221; in &#8220;<a href=\"http:\/\/www.lisarhody.com\/some-assembly-required\/\">Some Assembly Required<\/a>.&#8221; N.B. When taking this option, make sure you remove the stop words from the poem before you color-code it so that you can post it to the blog (in Step Five) and stay on the good side of copyright law.<\/li>\n<li>Ask me to prep your data for network visualization in Gephi (or run <code><a href=\"https:\/\/github.com\/briancroxall\/duffy2019\/blob\/master\/mallet2gephi.py\">mallet2gephi.py<\/a><\/code> yourself from our repo).<\/li>\n<\/ul>\n<h3>Step Five: Blog about the Data<\/h3>\n<p>Write about your modeling and your data <a href=\"http:\/\/docs.google.com\/\">using Google Docs<\/a>. When you are done, make the Doc public and <a href=\"http:\/\/briancroxall.net\/w19dh\/wp-admin\/post-new.php\">post a link to it on our blog<\/a>. The post is due by the end of class on <strong>Monday, 1 April. <\/strong>Your write-up should contain the following information:<\/p>\n<ul>\n<li>A list (bullet points is fine) of the different models you tried. This might look something like, &#8220;20 topics, no stopwords, 1000 iterations, no optimization&#8221;<\/li>\n<li>Identify which of the abovementioned models you think is best for Duffy&#8217;s poetry and discuss why you made this decision.<\/li>\n<li>In your best model, try to identify at least two each for what Rhody, in &#8220;<a href=\"http:\/\/www.lisarhody.com\/some-assembly-required\/\">Some Assembly Required<\/a>,&#8221; calls &#8220;semantically evident topics&#8221; and &#8220;semantically opaque topics.&#8221; For each of these four topics, write out the topic keys and explain what leads you to identify them as &#8220;evident&#8221; or &#8220;opaque&#8221; topics.<\/li>\n<li>Write 2-3 paragraphs to report on what you observed in Step Three.<\/li>\n<li>Include the visualizations that you produced in Step Four.<\/li>\n<li>Write a paragraph that discusses what you learned from this approach that you didn&#8217;t learn through reading the poems or marking the poems up.<\/li>\n<\/ul>\n<h2>Grading<\/h2>\n<p>This assignment is worth 50 points. You will be graded on whether your post has all the required items; the quality of the work that you did in trying and evaluating different models; and your analysis of the models that you create.<\/p>\n<h2>Credits<\/h2>\n<p>This assignment was designed in 2018 and owes debts to Miriam Posner and Lisa Rhody for their ideas for visualizing the output of a topic model. In 2019, I simplified portions of the assignment based on what I learned the previous year.<\/p>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rationale We have completed our reading of Carol Ann Duffy&#8217;s first five books, and we&#8217;ve gotten a closer look at various poems as we&#8217;ve marked them up with TEI. I&#8217;m guessing that most of us could now begin to put together a pretty cogent argument about whether or not\u00a0The World&#8217;s Wife differs from the volumes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":77,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-246","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/PaATg6-3Y","_links":{"self":[{"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/pages\/246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":25,"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/pages\/246\/revisions"}],"predecessor-version":[{"id":585,"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/pages\/246\/revisions\/585"}],"up":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/pages\/77"}],"wp:attachment":[{"href":"https:\/\/briancroxall.net\/w19dh\/wp-json\/wp\/v2\/media?parent=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}