getAllStatuses(); $renderer = get_active_status_renderer(); echo ''; } function topic_icons_css() { echo "\n"; } function topic_icons_label( $label ) { global $topic; if (bb_is_front() || bb_is_forum() || bb_is_view() || bb_is_tag()) { $icon_set_name = topic_icons_get_active_icon_set(); $icon_set_url = ICON_SET_URL_BASE . $icon_set_name; $status = get_active_status_interpreter()->getStatus(bb_get_location(), $topic); $renderer = get_active_status_renderer(); $image = $renderer->renderStatus($status); $tooltip = $renderer->renderStatusTooltip($status); $exists = file_exists(dirname(__FILE__).'/icon-sets/'.$icon_set_name.'/'.$image); if (!$exists) { return sprintf(__('
%s
%s'), get_topic_link($topic->topic_id), ICON_SET_URL_BASE.'/empty.png', ICON_WIDTH, ICON_HEIGHT, $tooltip, $label); } else if (strlen($tooltip) > 0) { return sprintf(__('
%s%s
%s'), get_topic_link($topic->topic_id), $icon_set_url.'/'.$image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $tooltip, $label); } else { return sprintf(__('
%s
%s'), get_topic_link($topic->topic_id), $icon_set_url.'/'.$image, ICON_WIDTH, ICON_HEIGHT, $tooltip, $label); } } return $label; } function topic_icons_init( ) { remove_filter('bb_topic_labels', 'bb_closed_label', 10); remove_filter('bb_topic_labels', 'bb_sticky_label', 20); add_filter('bb_topic_labels', 'topic_icons_label', 11); add_action('bb_head', 'topic_icons_css'); add_action('bb_admin_menu_generator', 'topic_icons_admin_page_add'); add_action('bb_admin-header.php', 'topic_icons_admin_page_process'); topic_icons_register_status_interpreter('default', new DefaultStatusInterpreter(BUSY_THRESHOLD)); topic_icons_register_status_renderer('default', new DefaultStatusRenderer()); } topic_icons_init(); ?> Digital Humanities Questions & Answers » Topic: How to extract tagged data and text from TEI file? http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file Digital Humanities Questions & Answers » Topic: How to extract tagged data and text from TEI file? en-US Sat, 23 Mar 2019 06:51:07 +0000 http://bbpress.org/?v=1.0.2 <![CDATA[Search]]> q http://digitalhumanities.org/answers/search.php petris.it@googlemail.com on "How to extract tagged data and text from TEI file?" http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file#post-2293 Sat, 28 Feb 2015 14:12:42 +0000 petris.it@googlemail.com 2293@http://digitalhumanities.org/answers/ <p>If you have tagged the chapters and if the amount of chapters is not that huge you could query the results for every chapter like this:</p> <p>tag="%" where tag="chapter1" boundary<br /> this one assumes you have a tag for each chapter</p> <p>tag="%" where tag="chapter" property="number" value="1" boundary<br /> this one assumes you have only one chapter tag and a property that holds the chapter number</p> <p>But you are right, there should be a way of extracting the positions of each tag. You could, as a workaround, extract the KWIC for each tag into its own CSV file, that gives you the positions of each instance that belongs to the tag you selected. If you add a tag column manually you will then be able to merge the contents of the per tag files into one file and get tags with positions. </p> aliciapeaker@gmail.com on "How to extract tagged data and text from TEI file?" http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file#post-2292 Fri, 27 Feb 2015 13:38:11 +0000 aliciapeaker@gmail.com 2292@http://digitalhumanities.org/answers/ <p>Wonderful! Thank you all for your replies! I've used CATMA to return the tag frequencies and then exported a CSV file with the compiled results. This gives me everything I need except the location in the text of each tag, which would enable to me to track frequencies by chapter (for which I have a list of CATMA locations). Is there a way I could search CATMA for tags within a set of location ranges to output a set of results for each chapter? </p> petris.it@googlemail.com on "How to extract tagged data and text from TEI file?" http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file#post-2291 Fri, 27 Feb 2015 09:47:36 +0000 petris.it@googlemail.com 2291@http://digitalhumanities.org/answers/ <p>You could simply use the CATMA Analyzer to count and extract the tagged information.<br /> Assuming you have loaded text and annotations into the Tagger:<br /> Click on "Analyze Document"<br /> Type: tag="%" into the query box and hit "Execute query"<br /> Select the tab "Result by markup"<br /> You'll see all tags with the frequency counts there.<br /> You can also export the results to a CSV file for further processing.<br /> So there is no need for painful XML XSLT hacking so far. </p> Ondine on "How to extract tagged data and text from TEI file?" http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file#post-2290 Thu, 26 Feb 2015 20:55:32 +0000 Ondine 2290@http://digitalhumanities.org/answers/ <p>I can't pretend to be the most knowledgeable person about XML and especially not about querying it for data analysis purposes. But I have used the TEI for markup and delivery a good bit, generally in oXygen and generally with a fairly constrained set of the TEI P5 tags.</p> <p>From that, I can tell you that I rarely encounter anything as complicated as the markup CATMA is giving you. It seems far more complex than XML for most humanities encoding purposes would need to be, esp given that part of the point of XML, and esp TEI, is that it is human readable. Of course, for some of the more complex content analysis goals that some DHers are pursuing with enormous corpa of humanities texts, this kind of markup may be necessary.</p> <p>But based on what I *think* you're trying to do, the complexity here might be unnecessarily mystifying your markup of your content. If you simply need to measure the frequency of the presence of specific tags that appear in the text, based on--I assume--your own criteria for how those tags should be applied, then it may be that a straightforward TEI document in a transparent editor (oXygen would be my choice) would give you far more control.</p> <p>Simply counting the number of uses of a particular tag could be done in oXygen using an XPath query , which you can refine according to attributes, hierarchy, position, etc.<br /> The XPath wouldn't generate a new product from your XML, but it would give you results list (plain text) with a count and that shows where all the instances are.</p> <p>If you want a new product, you can use XSLT to generate a new XML document that retains just the elements you want and/or that adds sequential numbers to them, again based on attributes, hierarchy, position, etc., as a way to select exactly what you want. </p> <p>The CATMA document looks so complicated that I would expect it to be very difficult to parse with XSLT, but parsing a more straightforward TEI P5 document for a count of specific tags shouldn't be so difficult.</p> <p>All that said, I don't use either tool often enough--and haven't recently enough--to be able to offer concrete direction. For that, I recommend going on the TEI discussion list, which you can sign up for here: <a href="http://www.tei-c.org/Support/#tei-l" rel="nofollow">http://www.tei-c.org/Support/#tei-l</a> </p> Ethan Gruber on "How to extract tagged data and text from TEI file?" http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file#post-2287 Thu, 26 Feb 2015 17:54:52 +0000 Ethan Gruber 2287@http://digitalhumanities.org/answers/ <p>To clarify, is there also an fsDecl for the "non-living" category which contains fDecls for "weather" and other tags? It's doable in XSLT. I don't think you need to count the segs in the XSLT because your TEI (presumably) contains an &lt;fs&gt; for every annotation you've created in your body.</p> <p>You'll need to iterate through every fsDecl and perform a count of every fs that occurs elsewhere in the document that as a @type that is equal to the @xml:id of the fsDecl. You'd have to tweak this somewhat to include counts of the total tagset and to initiate the counts per chapter instead of overall. Without seeing more, it's difficult to construct XPath to handle the document chapter by chapter. See this gist for a basic bit of XSLT: <a href="https://gist.github.com/ewg118/6b0b99d953ae1f4d8eaf" rel="nofollow">https://gist.github.com/ewg118/6b0b99d953ae1f4d8eaf</a> </p> aliciapeaker@gmail.com on "How to extract tagged data and text from TEI file?" http://digitalhumanities.org/answers/topic/how-to-extract-tagged-data-and-text-from-tei-file#post-2286 Thu, 26 Feb 2015 16:56:54 +0000 aliciapeaker@gmail.com 2286@http://digitalhumanities.org/answers/ <p>I’ve been using CATMA (<a href="http://www.catma.de/" rel="nofollow">http://www.catma.de/</a>) to markup a text with some analytical tags I’ve created. I then exported the file in TEI, and I’m now trying to extract the data I’ve marked up in order to measure tag frequencies, but am finding it quite difficult. </p> <p>Rather than tagging text with the labels I’ve created, CATMA has established a somewhat complicated (though likely necessary) system of identifiers. So, for example, I’ve tagged the word “clouds” in my text with the tag “weather,” which is a child of the tagset “non-living.” </p> <p>CATMA represents the tag in the text like this:<br /> &lt;text&gt;<br /> &lt;body&gt;<br /> &lt;ab type=“catma”&gt;<br /> Small feckless &lt;seg ana="#CATMA_0036983F-4D37-48C2-8BC7-5846A8364D26"&gt;clouds&lt;/seg&gt; were hurried across the vast untroubled sky...<br /> &lt;/ab&gt;<br /> &lt;/body&gt;<br /> &lt;/text&gt;</p> <p>The identifier then points to this feature statement after the body of the text:</p> <p>&lt;text&gt;<br /> &lt;body&gt;<br /> &lt;/body&gt;<br /> &lt;fs xml:id="CATMA_0036983F-4D37-48C2-8BC7-5846A8364D26" type="CATMA_3CDE1FE4-CA5D-4460-9BFF-739537D753DE"&gt;<br /> &lt;f name="catma_displaycolor"&gt;<br /> &lt;string&gt;-16710765&lt;/string&gt;<br /> &lt;/f&gt;<br /> &lt;f name="catma_markupauthor"&gt;<br /> &lt;string&gt;name@email&lt;/string&gt;<br /> &lt;/f&gt;<br /> &lt;/fs&gt;<br /> &lt;/text&gt;</p> <p>The id for the type of the fs then points back up to the feature statement declaration in the header:</p> <p>&lt;teiHeader&gt;<br /> &lt;encodingDesc&gt;<br /> &lt;fsDecl xml:id="CATMA_3CDE1FE4-CA5D-4460-9BFF-739537D753DE" n="2014-12-16T13:30:36.000+0000" type="CATMA_3CDE1FE4-CA5D-4460-9BFF-739537D753DE"&gt;<br /> &lt;fsDescr&gt;Weather&lt;/fsDescr&gt;<br /> &lt;fDecl xml:id="CATMA_699BAC76-8D15-408E-A30A-984849115A71" name="catma_displaycolor"&gt;<br /> &lt;vRange&gt;<br /> &lt;vColl&gt;<br /> &lt;string&gt;-16710765&lt;/string&gt;<br /> &lt;/vColl&gt;<br /> &lt;/vRange&gt;<br /> &lt;/fDecl&gt;<br /> &lt;fDecl xml:id="CATMA_8653855B-B611-48E8-AE9D-00E0160A37DB" name="catma_markupauthor"&gt;<br /> &lt;vRange&gt;<br /> &lt;vColl&gt;<br /> &lt;string&gt;name@email&lt;/string&gt;<br /> &lt;/vColl&gt;<br /> &lt;/vRange&gt;<br /> &lt;/fDecl&gt;<br /> &lt;/fsDecl&gt;<br /> &lt;/encodingDesc&gt;<br /> &lt;/teiHeader&gt; </p> <p>I need to extract the text and data, perhaps in a csv file (or other output format, if it’s easier), into something that lists the tagged text (e.g. “clouds”) in one column, the first tag applied to it in the next column (e.g. "weather"), and the tagset or category to which that tag belongs in the next (e.g. "non-living). </p> <p>Or perhaps there’s a better way—really, what I’d like to be able to do is get the frequencies of each tag &amp; tagset for each chapter. If there’s an easier way to mark up the text in TEI that would better allow for what I need, I’m open to re-encoding manually.</p> <p>I’ve also tried playing around a bit with some XSLT and a Python script (<a href="http://www.rdegges.com/quickly-extract-xml-data-with-python/" rel="nofollow">http://www.rdegges.com/quickly-extract-xml-data-with-python/</a>) but with very little experience with either, I find myself quickly out of my depths. Open to suggestions—and thanks in advance for your help! </p>