<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Richard Ashworth on Medium]]></title>
        <description><![CDATA[Stories by Richard Ashworth on Medium]]></description>
        <link>https://medium.com/@richard.ashworth?source=rss-d02cd6d6572------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0D2q58CIR1CK4D4rCdOEgA.jpeg</url>
            <title>Stories by Richard Ashworth on Medium</title>
            <link>https://medium.com/@richard.ashworth?source=rss-d02cd6d6572------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:00:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@richard.ashworth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Analysing Subtitles with Natural Language Processing]]></title>
            <link>https://medium.com/itv-technology/analysing-subtitles-with-natural-language-processing-4969071b9839?source=rss-d02cd6d6572------2</link>
            <guid isPermaLink="false">https://medium.com/p/4969071b9839</guid>
            <category><![CDATA[climate-change]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[television]]></category>
            <dc:creator><![CDATA[Richard Ashworth]]></dc:creator>
            <pubDate>Thu, 16 Sep 2021 09:36:50 GMT</pubDate>
            <atom:updated>2021-09-16T09:36:50.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Scrabble letters arranged to form the phrase “climate change”" src="https://cdn-images-1.medium.com/max/1024/1*g0kHrmp40D4pVYpPaJyLug.jpeg" /></figure><h4>What does our content say about climate change?</h4><p><a href="https://wearealbert.org/">Albert</a>, a sustainability project adopted by BAFTA, helps the UK’s major broadcasters answer this question through their <a href="https://wearealbert.org/editorial/subtitles-to-save-the-world-2/">Subtitles to Save the World</a> initiative. In this post, we’ll look at how data at ITV is used to support this, and how we can expand on the analysis using Natural Language Processing (NLP).</p><p>Elasticsearch and Kibana enable different users to search for particular words or phrases within our subtitled content. For example, a clip sales agent might want to find programmes that reference a particular location, or we might be interested to see how frequently people talk about climate change on screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tNZ1sb-bWS1OxUGGfggRvw.png" /><figcaption>Searching subtitle data for mentions of a phrase using Kibana</figcaption></figure><p>Subtitle data is also available as a BigQuery dataset, which enables further analysis by combining it with other data sources. For example, we can use catalogue data to determine which genres contain the most mentions of climate change:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*xyf31E5KngSJtl7nXr3eDA.png" /><figcaption>Mentions of climate change by Ofcom genre (taken from a sample dataset)</figcaption></figure><p>Similarly, we can use this data to identify trends in our content, comparing the frequency of ‘Covid’ and ‘climate change’ in programmes broadcast during 2020:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*s434KV1HCxN_tTl2GYszkw.png" /><figcaption>Frequency of different words in our content over time (taken from a sample dataset)</figcaption></figure><h4>Limitations and the need for NLP</h4><p>When we know what we’re looking for, Kibana and SQL queries work well. When we don’t know what to expect in our results, things get more difficult: for example, we might want to identify which people are mentioned most frequently in the context of climate change.</p><p>This is where Natural Language Processing comes in. In the following examples, we’ll show how the open-source <a href="https://spacy.io/">spaCy</a> and <a href="https://textblob.readthedocs.io/en/dev/">TextBlob</a> libraries can be used to perform this analysis.</p><h4>Installing spaCy and loading models</h4><p>After installing spaCy as a python package, we’ll need to provide it with some trained data, known as a model. This is used to identify and categorise entities in our input text, and although it’s possible to customise this, the general-purpose en_core_web_trf model is sufficiently accurate for our needs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ee8f2c83e3237d9589994678173056e/href">https://medium.com/media/4ee8f2c83e3237d9589994678173056e/href</a></iframe><h4>Named Entity Recognition</h4><p>With spaCy now set up and the model loaded, we can use the library to tag different entities that appear in our subtitle text. For example, using the following sentence:</p><blockquote>&quot;We can speak to the UK’s own Greta Thunberg, because Amy Bray is a climate change activist from Cumbria, who is getting great acclaim for saying young people should be very worried about their future.”</blockquote><p>we can invoke spaCy’s ents method to extract the named entities and render them using the built-in displacy visualiser:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d78a5a5efd6f671b602803dee1148e3/href">https://medium.com/media/0d78a5a5efd6f671b602803dee1148e3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsAdlr-m8oLrUonXTj3CmQ.png" /></figure><p>As well as identifying people and places, spaCy supports a host of other entities, including products, organisations and even works of art! See <a href="https://spacy.io/models/en#en_core_web_trf-labels">here</a> for a complete list.</p><h4>Tokenisation</h4><p>Given the fragmented nature of subtitle segments, it can be difficult to infer the surrounding context from an individual segment. Treating the subtitles for a particular programme as a single document and then splitting (tokenising) this into sentences makes analysis far easier. This can be done using spaCy’s sents method. For example, given a set of subtitle segments from an episode of Jonathan Ross:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*6_QRHF_XYjoeRCVf9eDUwA.png" /></figure><p>we can run the following code to convert this into sentences:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/581fadf34aff1e6ab7bd78e680aa24fe/href">https://medium.com/media/581fadf34aff1e6ab7bd78e680aa24fe/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQ13dVFiXF16PZW7rmYbWw.png" /></figure><h4>Lemmatisation</h4><p>Converting words into their canonical form (lemmatisation) is also useful when searching subtitles for a particular phrase. For example, we may be interested in segments containing any of “climate change”, “ climate changes”, “climate-changing”, etc. To avoid having to include all the inflected forms of a word in our search query, we can generate the lemmas for each excerpt in our subtitles and pattern match these with our search terms instead:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/255145fadfa9c4d6375232d465017bd4/href">https://medium.com/media/255145fadfa9c4d6375232d465017bd4/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*TcyUxnEnMgBvf2ktzKcwKA.png" /></figure><p>Spelling correction is also something we could use here to further improve search results.</p><h4>Analysing Sentiment</h4><p>An interesting area of NLP is sentiment analysis, widely used to track customer reviews and comments on social media. We can use <a href="https://textblob.readthedocs.io/en/dev">TextBlob</a> to derive a score between -1 and 1 to reflect the sentiment in a piece of text. This helps us measure the tone of our content, as well as analyse the language being used to describe different entities. For example, in the following sentence:</p><blockquote>“It’s great that people are talking about climate change”</blockquote><p>we can assess the sentiment using the code below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdcda44d7482358f4bbff424746e2519/href">https://medium.com/media/bdcda44d7482358f4bbff424746e2519/href</a></iframe><pre>Sentiment(polarity=0.8, subjectivity=0.75, assessments=[([‘great’], 0.8, 0.75, None)])</pre><p>These assessments provide a crude measure of our tone of voice, but care is needed when drawing inferences. In the above example, the adjective ‘great’ yields a positive score, yet it is not being used to describe our search term, “climate change”. A deeper analysis of the text is needed to extract the language used to express sentiment about a specific word or phrase.</p><h4>Using Parts-Of-Speech and Dependency Tags</h4><p>To perform such a task, we need to examine the grammar of the sentences containing our search terms. We can do this with spaCy using parts-of-speech (POS) and dependency tags:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/219a590f6733791154c201dfa21b9992/href">https://medium.com/media/219a590f6733791154c201dfa21b9992/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKAsMf3uiNMNsg3jKvIq-w.png" /></figure><p>We can now use the POS tags to extract adjectives from our sentence, and determine which nouns they describe using the dependency tags:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5edd995f3cbae0822de8940ea6869f30/href">https://medium.com/media/5edd995f3cbae0822de8940ea6869f30/href</a></iframe><p>Applying this function to our example sentences enables us to differentiate the use of ‘great’ in the first sentence (which is not being used to describe climate change) from the “rapid” and “bad” in the second. A ‘relevant sentiment’ score can then be calculated using only those assessments that are connected directly to “climate change” in the dependency graph:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f149d9d4170b33c235cbf5fd2c12c273/href">https://medium.com/media/f149d9d4170b33c235cbf5fd2c12c273/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQyuf9Q-LPA-hj4fSTeKkQ.png" /></figure><h4>Bringing it all together</h4><p>Since named-entity recognition, tokenisation and dependency tagging are not performed in the context of a particular search term, it is more efficient to do this ahead of time and persist the results. We’re using <a href="https://cloud.google.com/dataflow">Google Dataflow</a> (a runner for <a href="https://beam.apache.org/">Apache Beam</a> pipelines) to apply some of the functions described above to our subtitle data.</p><p>With the results of this analysis at our disposal, we can harness the techniques described above to answer a broader set of questions about our content. Some examples:</p><p><em>Which people do we mention most frequently in the context of climate change?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*FkH7RgDTr2UpHFcH8wh_sA.png" /><figcaption>Results from a sample dataset</figcaption></figure><p><em>Which places do we mention most frequently when we talk about climate change?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V8JHTKq08oL6sQGpNpGr6A.png" /><figcaption>Results from a sample dataset</figcaption></figure><p><em>What language do we use when discussing climate change on screen?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cchX5jTMBwZGuEAT6c8qXg.png" /><figcaption>Results from a sample dataset</figcaption></figure><h4>Summary</h4><p>Although analysing natural language is a difficult problem, NLP libraries like spaCy and TextBlob provide us with powerful tools. As we have shown in the examples, these tools can be leveraged to glean deeper insights from our content through entity extraction, dependency tagging and sentiment analysis.</p><p>As well as investigating how different topics are represented on-screen, applying NLP to subtitle data could also be useful in other applications: a compliance team may want to check which entities appear in our scheduled content following a particular news story, for example.</p><p>In this post, we have only scratched the surface of what can be achieved with sPacy and TextBlob. Both libraries come with excellent documentation, and for more advanced examples and tutorials, I would thoroughly recommend the following resources:</p><ul><li><a href="https://spacy.io/usage/spacy-101">spaCy 101: Everything you need to know · spaCy Usage Documentation</a></li><li><a href="https://textblob.readthedocs.io/en/dev/quickstart.html">Tutorial: Quickstart - TextBlob 0.18.0.post0 documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4969071b9839" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itv-technology/analysing-subtitles-with-natural-language-processing-4969071b9839">Analysing Subtitles with Natural Language Processing</a> was originally published in <a href="https://medium.com/itv-technology">ITV Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Smarter Content Workflows With Event-Driven Architecture]]></title>
            <link>https://medium.com/itv-technology/building-smarter-content-workflows-with-event-driven-architecture-38aeab236ea?source=rss-d02cd6d6572------2</link>
            <guid isPermaLink="false">https://medium.com/p/38aeab236ea</guid>
            <category><![CDATA[event-driven-systems]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[domain-events]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Richard Ashworth]]></dc:creator>
            <pubDate>Thu, 30 Jul 2020 10:28:12 GMT</pubDate>
            <atom:updated>2020-08-12T14:43:45.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRw-HvcLzCN2OhaSpSvUxw.jpeg" /></figure><h3>The Content Supply Chain: A Logistics Business</h3><p>At its core, the supply and distribution of content at ITV is a logistics business. Bringing together a number of systems, teams and workflows, the Content Supply Chain is responsible for bringing up to five terabytes’ worth of content every day into ITV and distributing it to consumers. As with any logistics business, technology plays a key role: automation helps us to receive, process and deliver content efficiently, while data and analytics present opportunities to optimise workflows and extract more value from the supply chain itself.</p><p>Small, composable components are well-suited to this domain, and insights can be derived by taking an event-driven approach to their interaction. For example, by comparing the timestamps of different events in a particular workflow, we can measure its performance and identify any bottlenecks that it might contain. Similarly, if an expected event does not arrive, alerts can be raised so that the underlying issues get resolved before causing problems.</p><h3>Adopting Event-Driven Architecture</h3><p>An example workflow from the content supply chain is presented in figure 1, annotated with some of the events that occur as it executes. These follow naturally from the steps in the workflow: there is a single event to indicate that a step has begun, and separate events for the possible outcomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MDFFVV0KIgdunpny" /><figcaption>Figure 1. An Example Content Workflow</figcaption></figure><p>Using events from the business domain to influence a system’s architecture yields a number of benefits. By delimiting the actions of different components, events can help enforce the <a href="https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html">Single Responsibility Principle</a> and ensure that domain boundaries are reflected appropriately within the system.</p><p>Reusability, too, is an important property of supply chain software: workflows can be modelled as different wirings of components and being able to share steps between them is useful. Decoupling the steps in a workflow helps achieve this; in architectural terms, we design components that react to events rather than exchange commands or rely on a central brain to orchestrate control flow.</p><p>In refactoring parts of our system to this style, we’ve found that the risk of breaking existing functionality can be offset by first extending components’ behaviour to include just the publishing of events, introducing consumers to replace their interactions later. This approach also makes data for reporting and analytics available sooner.</p><h3>Identifying and Modelling Events</h3><p>Identifying domain events may seem like a trivial exercise from the previous example, but given their key role, it is a process worth paying attention to. We’ve recently begun using <a href="https://openpracticelibrary.com/practice/event-storming">Event Storming</a> workshops to identify important events across our workflows. Getting input from <a href="https://en.wikipedia.org/wiki/Subject-matter_expert#Domain_expert_(software)">Domain Experts</a> is essential here and helps establish a common language between product teams and their stakeholders. Since so much waste in Software Engineering arises from ambiguity in some form or another, the value in designing systems from a verified understanding cannot be overstated.</p><p>Two further principles for modelling events are worth mentioning at this point:</p><h4>1) Name Events Carefully</h4><p>Events in software reflect something that has <em>happened</em>, so they should always be named in the past tense. This may sound pernickety, but consider these possible event names:</p><ul><li>DATA VERIFIED</li><li>DATA VERIFICATION</li></ul><p>From the first name, we can tell that the verification step has completed, and could use the timestamp of this event to infer how long that step took. With the second, it is not clear what state the verification is in, and the system becomes more difficult to reason about as a result. It is also worth considering how consumers will decide what to do when they receive a particular event. Descriptive names can save consumers having to pull extra information out of a message payload or make API calls to determine what has happened.</p><h4>2) Simplify Event Consumers With Generic Metadata</h4><p>In an event-driven system, the publisher of an event shouldn’t need to be aware of the components reacting to it. If events are sent via messaging, the structure of those messages should be predictable so that components can handle new events as they are introduced. This also makes it easier to query the events from a data store, using them to build up a picture of the system’s behaviour. Of course, some details may be specific to particular event types, but using generic fields (event name, timestamp, etc.) consistently can help here. Depending on the underlying technology, encoding this information in message headers might help reduce the impact on existing consumers.</p><h3>An Event Collector Service</h3><p>The diagram in figure 2 shows how our system’s architecture has been extended to support event-based analytics using <a href="https://www.splunk.com/">Splunk</a> and <a href="https://cloud.google.com/bigquery">BigQuery</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DCvZQxq9lESUHAd7" /><figcaption>Figure 2. Event-Driven Architecture with Messaging</figcaption></figure><p>In this example,<em> Service B</em> reacts to events published by <em>Service A</em>. Routing logic in the message broker ensures that these events are forwarded to the<em> Event Collector</em> service. Using a common format for event metadata means that the Event Collector can serialize these messages and upload them to different data stores for further analysis.</p><p>As well as supporting AMQP (via RabbitMQ), the Event Collector also has an HTTPS endpoint so that third-party systems can publish events via a webhook. Likewise, a lambda function forwards events from an SQS queue, providing an interface for serverless workflows.</p><h3>Supporting A Smarter Business</h3><p>The log of events generated every time a workflow executes provides users with a single source of truth for the supply chain’s behaviour. We’ve found transforming this data using SQL Views in BigQuery an effective way to expose this data to different stakeholders. The ability to join this data to other sources is a useful feature of this approach. For example, metrics from the event log can be enriched with catalogue data to provide insight into how long content for a particular production takes to process.</p><p>Adopting an event-based approach for our content ingest workflows proved its worth recently during a critical project to bring a number of processing steps in-house. Splunk dashboards were used to rapidly prototype a user interface for tracking content coming into ITV. These enabled our operations teams to diagnose issues with missing content quickly and make better predictions about when content would be available.</p><p>Product Owners have also found this data valuable. Measuring the impact of new features and prioritising future work both become easier when the relevant metrics are readily available.</p><p>Perhaps the greatest value in having collected this data, however, is that it is now accessible and intelligible to other parts of the business. Breaking down silos of knowledge is a challenge for any organisation, and if taking an event-driven approach can help achieve this, then it’s surely worth considering.</p><h3>What Next?</h3><p>Dashboards and alerts are useful tools, but the goal is to improve the supply and distribution of our content. While equipping people with metrics has proved valuable, they are not the only consumers that can benefit from this information.</p><p>Feeding analysis back into the system itself presents an opportunity for components to adapt automatically to changes across the supply chain: heuristic algorithms might infer whether a piece of content is likely to arrive on time, and different parts of the system could be configured to scale up in response to this information. The work described in this post only <em>facilitates</em> a more scientific approach to the business domain; connecting the insights, taking informed action and then iterating on this is where the value really emerges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38aeab236ea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itv-technology/building-smarter-content-workflows-with-event-driven-architecture-38aeab236ea">Building Smarter Content Workflows With Event-Driven Architecture</a> was originally published in <a href="https://medium.com/itv-technology">ITV Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>