Culture Eats AI Strategy for Breakfast: Cheat Codes for Technology Leaders Driving AI Transformation

Peter Drucker famously warned that “Culture eats strategy for breakfast.” Today, as organizations race toward AI-driven futures, his wisdom has never been more relevant. Boards ask for AI roadmaps, pilot programs, and productivity breakthroughs, but experienced technology leaders recognize one crucial truth: Your culture, not your technology, determines your AI success.

You can invest significantly in top-tier AI talent, sophisticated models, and robust infrastructure. Yet if your organizational culture resists innovation and experimentation, even the most ambitious AI strategies will stall.

The Cultural Disconnect Is Real and Expensive

Consider these recent findings:

  • According to BCG, 70% of digital transformations fail, and more than 50% of these failures are directly linked to cultural resistance.
  • Gartner highlights that just 19% of organizations move successfully from AI experimentation to broad adoption.

In other words, the biggest obstacle isn’t technology, it’s your people.

Why Culture is Your Real AI Enabler

AI reshapes how teams operate, make decisions, and deliver value. Organizations thriving in an AI-powered environment typically share these cultural traits:

  • Open to experimentation (instead of focusing solely on perfection)
  • Driven by outcomes (rather than task completion)
  • Decentralized and agile (rather than rigidly hierarchical)

Without embracing these cultural shifts, your AI initiatives risk becoming ineffective investments.

Critical Questions for Technology Leaders

Before diving into AI projects, pause to reflect on these questions about your organizational culture:

  • Do employees see AI as a threat or as a helpful partner?
  • Are leaders genuinely comfortable learning from failures, or is perfection still expected?
  • Do innovation activities translate into meaningful business outcomes, or are they primarily for show?
  • Is your decision-making process agile enough to support rapid AI experimentation and implementation?

Your responses will help identify the key cultural barriers and opportunities you need to address.

Success Stories: Companies Mastering Culture-First AI

Here are organizations that successfully navigated cultural challenges to harness the power of AI:

  • Microsoft: CEO Satya Nadella introduced a growth mindset, fostering experimentation and cross-team collaboration. This culture paved the way for successful AI products such as Copilot and Azure OpenAI.
  • DBS Bank: DBS embedded a “data-first” culture through widespread employee AI education. This investment led to rapid AI adoption, significantly improving customer service and reducing response times by up to 80%.
  • USAA: USAA positioned AI clearly as an augmentation tool rather than a replacement. This approach fostered employee trust and improved both customer satisfaction and internal productivity.

Cheat Codes for Technology Leaders: How to Accelerate Cultural Readiness for AI

Instead of complicated frameworks, here are three practical cheat codes to drive rapid cultural change:

1. Shift the AI Narrative from Threat to Opportunity

  • Clearly position AI as an ally, not an adversary.
  • Share success stories highlighting how AI reduces repetitive tasks, increases creativity, and boosts employee satisfaction.

2. Democratize AI Knowledge Quickly

  • Rapidly roll out AI training across your entire organization, not just among tech teams.
  • Use accessible formats like quick-start guides, lunch-and-learns, and internal podcasts. Quickly increasing organizational AI fluency helps accelerate cultural change.

3. Celebrate Rapid, Open Experimentation

  • Foster a culture that openly celebrates experimentation and accepts failures as valuable learning opportunities.
  • Publicly reward teams for trying innovative ideas, clearly communicating that experimentation is encouraged and safe within defined boundaries.

Final Thought: AI Transformation is Fundamentally Cultural

Technology opens the door, but your culture determines whether your organization steps through. AI transformation requires more than strategy and investment in tools. It requires intentional cultural shifts influencing how your teams operate daily.

As Peter Drucker emphasized decades ago, culture can derail even the most ambitious strategy. However, technology leaders who master the cultural aspects of AI transformation will create an enduring competitive advantage.

#DigitalTransformation #AI #CTO #CIO #ProductStrategy #Culture #EngineeringLeadership #FutureOfWork #PeterDrucker

AI Agents: Expanding or Contracting TAM?

Artificial Intelligence (AI) agents, are transforming industries and reshaping market dynamics. When evaluating AI’s strategic implications, understanding whether these agents expand or contract your Total Addressable Market (TAM) is crucial.

AI Agents: Catalysts of Market Expansion

AI agents are notably expanding markets by enabling businesses to reach previously underserved customer segments or create entirely new use cases. Consider Shopify’s “Sidekick,” an AI assistant empowering small businesses to launch sophisticated e-commerce stores with minimal expertise. Similarly, GitHub Copilot drastically enhances developer productivity and even empowers non-developers to participate in software creation. Klarna’s AI-driven customer support bot performs the work equivalent to hundreds of support staff, allowing even smaller enterprises to offer around-the-clock customer service.

These examples underline a significant trend: AI agents democratize advanced capabilities, significantly broadening markets by making sophisticated solutions accessible to broader audiences.

Where AI Agents Contract TAM

However, the integration of AI agents also means contraction in specific traditional markets, primarily those heavily reliant on human labor. TurboTax’s AI tools are reducing the need for professional tax preparation services, while Microsoft’s Copilot for Excel threatens niche data analytics tools by embedding powerful AI directly into mainstream products. Likewise, legal firms face revenue contraction from AI-driven contract reviews and document analysis tools automating what previously required extensive manual labor.

Thus, markets reliant on routine human-intensive services face significant disruption and potential TAM contraction unless they strategically adapt.

Products vs. Services: Divergent Impact

AI’s impact diverges between products and services:

  • Products: Enhanced by AI integrations, digital products like Microsoft’s Office suite become vastly more appealing and broadly applicable, increasing their market reach. However, niche or standalone products risk commoditization and obsolescence if they don’t integrate competitive AI capabilities.
  • Services: AI automation opens scalable delivery opportunities, expanding service reach. Financial advisory bots or healthcare symptom-checkers exemplify how traditionally premium services now scale affordably. Yet, human-intensive services without AI augmentation may find themselves losing customers who switch to lower-cost, AI-driven alternatives.

Industry-Level Implications

Industries experiencing significant TAM expansion include:

  • Education: AI tutors (e.g., Khan Academy’s Khanmigo) democratizing personalized learning globally.
  • Healthcare: AI symptom-checkers (Babylon Health) extending care access to remote populations.
  • Retail & E-Commerce: AI-powered shopping assistants and merchant tools driving customer engagement and business growth.
  • Software & Technology: AI expanding software capabilities into roles previously requiring human labor, drastically enlarging software’s market.

Conversely, industries facing contraction pressures include:

  • Legal Services: Automation of routine legal work reducing traditional billable services.
  • Customer Support BPOs: AI-driven support bots displacing entry-level customer support roles.
  • Basic Financial Advisory: Robo-advisors capturing lower-tier investment advisory markets previously served by human advisors.

Overall Industry Outlook: Industries centered on information, analysis, and routine communication are seeing parts of their TAM shrink for traditional players but expand for tech-enabled ones. Meanwhile, industries that can harness AI to reach underserved populations or create new offerings see TAM expansion. Importantly, the total economic opportunity doesn’t vanish – it shifts. As one venture study put it, AI agents let software and automated services compete for a “10-20x larger opportunity” by doing work that used to be outside software’s scope lsvp.com. Companies need to recognize whether AI agents enlarge their particular market or threaten it, and adapt accordingly.

Recommendations

If you are aiming to harness AI agents for market expansion you should:

  1. Embed AI in Products to Access New Users: Companies should integrate AI agents or assistants directly into their products to enhance functionality and usability. By offering AI-driven features (such as natural language queries, smart recommendations, or autonomous task completion), products become accessible to a wider audience. This can unlock new user segments who lack expertise or resources – for example, a software platform with an AI helper can attract non-specialist users and expand the product’s TAM. Strategic tip: Identify core user pain points and implement an AI agent to solve them (e.g. an AI design assistant in a web builder). This not only differentiates the product but also positions the company to capture customers who were previously underserved. Successful cases like Adobe adding AI generative tools into its suite or CRM systems adding AI sales assistants show that built-in AI features drive adoption and usage lsvp.com.
  2. Reframe Service Offerings as “Agent-Augmented”: Service organizations (consultancies, agencies, support providers, etc.) should redesign their offerings around AI + human collaboration. Instead of viewing AI as a pure substitute, present it as a value-add that makes services faster, more affordable, and scalable. For instance, a marketing agency might offer an “AI-augmented content creation” service where AI drafts content and humans refine strategy – delivering faster turnaround at lower cost. This reframing helps retain clients who might otherwise try a DIY AI tool, by giving them the best of both worlds. It also attracts new clients who were priced out of the fully human service. The key is to train staff to work alongside AI agents and emphasize the enhanced outcomes (better insights, quicker service) in marketing the service. Organizations that position themselves as AI-empowered advisors or providers can expand their TAM by capturing clients who demand efficiency and still value human judgment.
  3. Use Tiered Models to Avoid Cannibalization: When introducing AI agents that could undercut your existing offerings, use tiered product/service models to segment the market. Offer a basic, AI-driven tier targeting cost-sensitive or new customers, and a premium tier that includes high-touch human expertise. This prevents the AI solution from simply cannibalizing your top-end revenue – instead, it lets you capture a new low-end market while preserving an upscale segment for those willing to pay more. For example, a software company might offer a free or low-cost AI tool to appeal to a broad audience (expanding TAM), while reserving advanced features and support for a paid enterprise version. In services, a law firm could provide an AI-powered contract review service for simple cases (low fee, high volume) and a specialized attorney review for complex cases (high fee). By tiering, organizations can widen their market reach with AI without eroding the value of premium offerings. Over time, some customers may even upgrade as their needs grow. The goal is a balanced portfolio where the AI-based tier brings in new business and the premium tier continues to generate high-margin revenue – together growing the total addressable market served by the firm.

In conclusion, the mandate is clear, embrace AI agents proactively to drive growth, but do so strategically. AI agents are reshaping markets: expanding them in aggregate, but shifting where value flows. Organizations that thoughtfully integrate AI into their products and services, adjust their business models, and target emerging opportunities can ride this wave to capture a larger TAM. Those that resist or neglect the trend risk seeing their addressable market captured by more agile, AI-powered competitors. In summary, AI agents should be viewed as a catalyst for expansion, and with prudent strategy, businesses can ensure that they are on the expanding side of the TAM equation rather than the contracting side, leveraging AI to unlock new horizons of growth.

The Core vs. Context Trap: How Product Teams and Business Leaders Can Stay Focused

One of the most frequent yet overlooked mistakes in product management and business strategy is failing to clearly distinguish between “core” and “context.” This is not merely a theoretical issue but a fundamental cause of diluted focus, inefficient resource allocation, and weakened competitive positioning.

Defining Core vs. Context

Let’s start by clearly defining these terms:

  • Core refers to the elements of your products, services, or operations that directly differentiate your company in the marketplace. These are areas where you have, or can build, unique expertise that competitors find difficult to replicate. Essentially, core is the heartbeat of your competitive advantage.
  • Context, by contrast, comprises the necessary but non-differentiating activities and technologies that support your business. These activities are essential to operate but offer little strategic advantage because competitors can easily replicate or purchase these capabilities from the open market.

The Risks of Confusing Context for Core

A common pitfall is treating context activities as core activities. Misallocating resources and attention to context often leads to diluted strategic focus, inefficient spending, and reduced capacity for innovation in genuinely differentiating areas. Over time, this misalignment erodes competitive positioning, leading to stagnation or even decline.

Consider a hypothetical example: Company A, a promising SaaS startup, decides to build and maintain its own internal customer support tooling because it perceives support as crucial to user experience. While customer support is undoubtedly important, proprietary tooling does not differentiate Company A from competitors. Instead, the heavy investment into maintaining these internal tools diverts resources away from product innovation, inadvertently giving an edge to competitors focused correctly on their core.

Real-world examples underscore this risk clearly. Netflix recognized early that its “core” was content personalization and delivery technology, not owning servers or data centers, and thus smartly leveraged cloud providers like AWS for infrastructure, a classic “context” component. Conversely, traditional retailers who treated IT infrastructure as core and heavily invested in data centers found themselves struggling against competitors who correctly leveraged cloud platforms.

Actionable Guidelines for Identifying Your Core

Here are practical steps for identifying your organization’s core:

  1. Strategic Differentiation Test: Regularly ask, “Does this directly differentiate us from competitors in ways customers value and competitors struggle to replicate?”
  2. Market Impact Analysis: Evaluate if an activity or product capability strongly influences purchasing decisions or brand perception.
  3. Scalability and Sustainability Check: Determine whether investments in an area sustainably scale your competitive advantage over time.
  4. Regular Portfolio Reviews: Conduct periodic audits of your product and operational investments to realign resources toward core activities and streamline context ones via partnerships or third-party solutions.

Role of the Business Leaders

Business leaders play a crucial role in clearly defining and consistently communicating strategic priorities. They are responsible for establishing the vision and direction that distinguishes core activities from context. Effective leaders maintain a disciplined approach to resource allocation, focusing resources primarily on strategic differentiators and ensuring context elements are efficiently managed or outsourced.

Role of the Product Team

The Product team, including the Chief Product Officer (CPO), Chief Technology Officer (CTO), and product leaders, operationalize the distinction between core and context. They execute the business vision through technical decisions, product roadmaps, and feature prioritization. The product team ensures day-to-day actions remain aligned with strategic goals, avoiding the temptation to invest disproportionately in non-differentiating context areas.

Contrasting Roles: Business vs. Product Team

While business leaders set the strategic boundaries and priorities, the product team focuses on execution within these boundaries. Business leaders must consistently reinforce the importance of core differentiation at the strategic level, while product teams translate this strategic clarity into practical, focused, and efficient product development efforts.

A Three-Step Framework to Avoid the Core vs. Context Problem

To maintain strategic clarity and competitive advantage, organizations should consistently apply the following three-step framework:

  1. Identify: Clearly define and communicate what constitutes core and context within your organization.
  2. Align: Ensure alignment of resources, processes, and investments around core activities, with disciplined outsourcing or efficient management of context activities.
  3. Review: Regularly revisit and reassess your definitions and strategic alignment to adapt to market changes and maintain competitive advantage.

Ultimately, mastering the core versus context distinction is an ongoing strategic discipline. Organizations that embed this clarity deeply into their culture and decision-making processes will not only enhance their agility and responsiveness but also sustain long-term competitive differentiation. Embracing this framework can empower your teams, clarify strategic direction, and ensure that your organization’s most critical resources, such as time, talent, and capital, are consistently invested where they deliver the greatest impact.

The Role of JS in the Agent Ecosystem

“Any application that can be written in JavaScript, will eventually be written in JavaScript.” – Jeff Atwood

This insight from Jeff Atwood has never felt truer, especially as we witness TypeScript and JavaScript rapidly emerging as leading languages in AI agent development—an area traditionally dominated by Python.

The recent “Tiny Agents” article from Hugging Face, alongside innovations like Vercel AI SDK (1m+ weekly downloads), raises an important question: As someone that spends more time with JavasScript (preferably TypeScript) than I should it raises the question, are we seeing the rise of a new generation of developers looking to bring AI into their applications, or is this the beginning of a broader shift within AI itself?

With fewer than 50 lines of TypeScript code, developers can now create AI agents that manage workflows, access tools, and orchestrate tasks—all while integrating smoothly with APIs. Frameworks like LangGraphJS (1.3k GitHub Stars), Mastra (12.7k GitHub Stars), LlamaIndex.TS (2.6k GitHub Stars), and tools from the Vercel ecosystem highlight how accessible and developer-friendly this space has become.

Why are Agents and TypeScript a good match?

  • Static Typing: Ensures code reliability, reduces runtime errors, and enhances maintainability.
  • Superior JSON handling: Optimizes integration with APIs, crucial for agent interactions.
  • Robust Async/Await Support: Ideal for handling asynchronous operations, central to AI workflows.
  • Unified Frontend & Backend Development: Allows developers to use one language across their entire application stack.

Examples like KaibanJS (1.1k GitHub Stars) and StageHand (11.6k GitHub Stars) further demonstrate TypeScript’s growing ecosystem for AI agents, underscoring its ability to facilitate scalable, secure, and maintainable applications.

This evolution prompts a deeper reflection: Is AI agent development becoming a core part of full-stack engineering? As tooling and frameworks continue to improve, the lines between app developer and AI developer may continue to blur.

Balancing Vision and Execution in a Ship-It Culture

Who owns the Product Vision in your organization, and how clearly is it defined? How does your team align on strategy, and is execution a challenge? Perhaps you’ve solved for all these elements, or maybe the relentless pace of shipping leaves little room for reflection.

In a culture dominated by the relentless mantra of “Ship-It,” there is a seductive appeal in equating velocity with progress. Speed to market can become an obsession, driven by agile rituals and iterative dogma, often causing strategy, and more crucially Vision, to be sidelined. This phenomenon isn’t merely problematic; it’s existential. Without Vision anchoring execution, organizations risk accelerating down paths that lead nowhere meaningful, sacrificing long-term competitive advantage for the transient comfort of motion.

Strategy, far from being the bureaucratic nuisance it is often painted as, serves as the essential bridge between Vision and execution. It acts as the scaffolding that ensures each incremental effort compounds into sustainable differentiation rather than dissipating into disconnected efforts. Yet in the rush to deliver, strategy frequently becomes an inconvenient step, a luxury dismissed by leaders who prioritize pace over purpose. The true role of strategy is not to slow down innovation but to amplify impact by aligning each shipment with the organization’s broader goals.

Vision suffers the greatest neglect in this culture of immediacy. True Vision provides not only a north star but also an enduring framework for strategic coherence. When Vision is overlooked or undervalued, companies inevitably fragment into tactical chaos, mistaking activity for achievement. The paradox is clear: the very speed sought by a “Ship-It” culture is best achieved by clarifying Vision first, strategically aligning efforts second, and then relentlessly shipping toward meaningful outcomes.

No matter where your organization finds itself on the strategy journey, maintaining a balance between thoughtful planning and decisive action is critical. The most successful teams aren’t those who avoid missteps entirely but those who remain committed to progress, excited by the opportunity to continuously learn and refine their approach along the way.

Fixing the HP Z Book Function Keys

The HP Z Book is a great development laptop for anyone that needs to build using the Windows stack. There is one minor annoyance, by default the function keys are not mapped to your standard F1 through F12.

To fix this, press fn+ctrl+shift. The standard function key behavior will then be active.

MailKit Converting a InternetAddressList to a MailAddressCollection

If you need to work with email in a .NET environment I highly recommend checking out MailKit by Jeffrey Stedfast. MailKit provides a higher level abstraction working across the different email protocols, which is a massive time saver.

MailKit has its own classes for handling Email Addresses. Most notability the MailboxAddress and InternetAddressList classes are returned when parsing a message envelope.

foreach (var summary in inbox.Fetch(0, -1, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure))
{
var tos = summary.Envelope.To;
var replyToList = summary.Envelope.ReplyTo;
}

As powerful as the MailKit constructs are, I typically like to convert any 3rd party types into their .NET framework equivalents.  The below extension method adds a ToMailAddressCollection method to MailKit’s InternetAddressList class.

public static class MailKitExts
{
public static MailAddressCollection ToMailAddressCollection(this InternetAddressList addressList)
{
if(addressList == null)
{
return new MailAddressCollection();
}
return addressList.Mailboxes.Aggregate(new MailAddressCollection(), (c, r) => { c.Add(new MailAddress(r.Address, r.Name)); return c; });
}
}
view raw MailKitExts.cs hosted with ❤ by GitHub

Swift Trimming Trailing Punctuation

Lately, I’ve been working on a project that requires some basic MLP text processing to be performed on device.  A component of our text processing involved removing any trailing punctuation, no matter the language.

I’ve found the below String Extension is a good balance between effectiveness, performance, and readability.  Especially if you are collecting input from users prone to excessive punctuation.

extension String {
func trimTrailingPunctuation() -> String {
return self.trimmingCharacters(in: .whitespacesAndNewlines)
.trimmingCharacters(in: .punctuationCharacters)
.trimmingCharacters(in: .whitespacesAndNewlines)
}
}
let example1 = "How are you???".trimTrailingPunctuation()
>>> How are you
let example2 = "Hi!!!!".trimTrailingPunctuation()
>>> Hi
let example3 = "Act limited time offer now!".trimTrailingPunctuation()
>>> Act limited time offer now

 

Freeing the space used by Xcode with XcodeCleaner

With every release of Xcode it seems to eat more and more space. I was thrilled to find the XcodeCleaner project from Baye on Github.  This is a great project that allows you to tailor the space Xcode uses.  I’ve been able to free up an easy 12GB without any issues.

I highly recommend checking out the project on GitHub at XcodeCleaner. You can build the project from source or download from the macOS App Store for $0.99.
68747470733a2f2f7777772e6170706c652e636f6d2f6974756e65732f6c696e6b2f696d616765732f6c696e6b2d62616467652d61707073746f72652e706e67

screenshot

Sentiment Analysis using Swift

Lately I’ve been working on several projects using conversational UI or “Bot” interactions.  A key interaction pattern when designing “Bots” you must listen to both the intent and sentiment of the text the user is providing.  Through the use of sentiment analysis you can help determine the mood of the user. This can be an important tool in determining when to offer help or involve a human.  You might think of this as the “help representative” moment we are all familiar with.  Using sentiment analysis you can try to offer help before that moment occurs.

There are several great sentiment analysis node.js packages but nothing I could find to run offline in Swift. A majority of the node.js projects seem to be a forks of the Sentiment package. The Sentiment-v2 package worked best for many of my cases and became my starting point.

A majority of the sentiment analysis  packages available through NPM use the same scoring approach. First they parse a provided phrase into individual words. For example “Cats are amazing” would be turned into an array of words, ie [“cats”, “are”,”amazing”].

Next a dictionary of keywords and associated weights are created. These scoring dictionary is created using the AFINN wordlist and Emoji Sentiment Ranking. In a nutshell, words like “amazing” would have a positive weight whereas words like “bad” would have a negative weight. The weight of each word in the provided phrase is added together to get the total weight of the phrase. If the phrase has a negative weight, chances are your user is starting to get frustrated or at least talking about a negative subject.

Using this approach I created the SentimentlySwift playground to demonstrate how this can be done on device using Swift.  This playground uses the same FINN wordlist and Emoji Sentiment Ranking weights to determine a sentiment analysis score without the network dependency.   To make comparisons easier, I tried to mirror the Sentiment package API as must as possible.  The below demonstrates the output for a few of the test phrases included with Sentiment.

let sentiment = Sentimently()
print(sentiment.score("Cats are stupid."))
analysisResult(score: -2, comparative: -0.66666666666666663, positive: [], negative: ["stupid"], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "stupid", wordStem: Optional("stupid"))])
print(sentiment.score("Cats are very stupid."))
analysisResult(score: -3, comparative: -0.75, positive: [], negative: ["stupid"], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "very", wordStem: Optional("very")), wordToken(word: "stupid", wordStem: Optional("stupid"))])
print(sentiment.score("Cats are totally amazing!"))
analysisResult(score: 4, comparative: 1.0, positive: ["amazing"], negative: [], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "totally", wordStem: Optional("totally")), wordToken(word: "amazing", wordStem: Optional("amaze"))])
var testInject = [sentimentWeightValue]()
testInject.append(sentimentWeightValue(word: "cats", score: 5))
testInject.append(sentimentWeightValue(word: "amazing", score: 2))
print(sentiment.score("Cats are totally amazing!", addWeights: testInject))
analysisResult(score: 7, comparative: 1.75, positive: ["cats", "amazing"], negative: [], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "totally", wordStem: Optional("totally")), wordToken(word: "amazing", wordStem: Optional("amaze"))])

Although the APIs are similar there is one important difference between the two approaches. The SentimentlySwift playground uses NSLinguisticTagger to tokenize the provided phrase. Using NSLinguisticTagger, SentimentlySwift first parsers each word into a series of word slices. Each slice is a word tokenized using the options provided to the NSLinguisticTagger. Next the slides are enumerated and an optional “tag” or word stem is calculated. For example, in the phrase “cats are amazing”, the “amazing” word generates a word stem of “amaze”. A better example would be the word “hiking” produces the word stem of “hike”.

The following snippet shows an example on how this can be implemented.

public struct wordToken {
let word: String
let wordStem: String?
init(word: String, wordStem: String?) {
self.word = word
self.wordStem = wordStem
}
}
func lemmatize(_ text: String) -> [wordToken] {
let text = text.lowercased()
let options: NSLinguisticTagger.Options = [.omitWhitespace, .omitPunctuation, .omitOther]
let tagger = NSLinguisticTagger(tagSchemes: NSLinguisticTagger.availableTagSchemes(forLanguage: "en"),
options: Int(options.rawValue))
tagger.string = text
var tokens: [wordToken] = []
tagger.enumerateTags(in: NSMakeRange(0, text.characters.count), scheme: NSLinguisticTagSchemeLemma, options: options) { tag, tokenRange, _, _ in
let word = (text as NSString).substring(with: tokenRange)
tokens.append(wordToken(word: word, wordStem: tag))
}
return tokens
}
view raw lemmatize.swift hosted with ❤ by GitHub

You might be asking why this is important? By implementing Lemmatisation you increase your AFINN hit rate and improve your overall analysis scoring.

This is one trick I’ve found for improving or at least monitoring your conversational UI or “Bot” interactions.