<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Alexander Weld - clr2</title>
      <link>https://weldale.xyz</link>
      <description>Alexander Weld&#39;s Homepage</description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://weldale.xyz/tags/clr2/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Fri, 02 Oct 2026 00:00:00 +0000</lastBuildDate>
      <item>
          <title>ChatLogReader 2 - Part 1</title>
          <pubDate>Fri, 02 Oct 2026 00:00:00 +0000</pubDate>
          <author>aweld</author>
          <link>https://weldale.xyz/blog/clr2-01/</link>
          <guid>https://weldale.xyz/blog/clr2-01/</guid>
          <description xml:base="https://weldale.xyz/blog/clr2-01/">&lt;h1 id=&quot;chatlogreader-2-part-1-from-chatlogs-to-tokens&quot;&gt;ChatLogReader 2&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; - Part 1 - From Chatlogs to Tokens&lt;/h1&gt;
&lt;p&gt;I have been working on a tool for managing various chatlogs that I collected over the last 20 years.
This provided some interesting challenges mostly due to the fact that the chatlogs are stored in around 10 different formats.
All of the formats have different quirks and present their information in different ways.&lt;/p&gt;
&lt;p&gt;The goal was to combine them into a common format and store them in a sqlite database, so I can search through them and immerse myself in nostalgia (and potentially cringe).&lt;/p&gt;
&lt;p&gt;This will be a multi part blog article discussing the interesting parts of the project.
This part discusses the general design and one step in the processing.&lt;/p&gt;
&lt;p&gt;In case you&#39;re already interested, the complete project can be found on gitlab: &lt;a rel=&quot;external&quot; href=&quot;https://gitlab.com/xicalango/clr2&quot;&gt;gitlab.com/xicalango/clr2&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id=&quot;chatlog-formats&quot;&gt;Chatlog formats&lt;/h1&gt;
&lt;p&gt;Just to give you an example of what the different exports look like, here is a list of some of the different formats in my collection, with a short description of what is found in the file.&lt;/p&gt;
&lt;h2 id=&quot;kopete-xml-format&quot;&gt;Kopete XML format&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt;&lt;span&gt; Kopete-History&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;kopete-history&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; version&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;0.9&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; month&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; year&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;2007&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;contact&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; contactId&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;987654321&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;myself&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;contact&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; contactId&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;123456789&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; nick&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;User2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; in&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; from&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;123456789&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;14 21:53:14&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt;hi&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; nick&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;User2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; in&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; from&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;123456789&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;14 21:53:25&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt;sagen&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; nick&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;User1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; in&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; from&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;987654321&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;14 21:53:32&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt;weiß&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; nick&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;User1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; in&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; from&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;987654321&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;14 21:54:4&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt;und&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;kopete-history&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Format: &lt;code&gt;XML&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header contains start month and year: &lt;code&gt;&amp;lt;date month=&quot;3&quot; year=&quot;2007&quot; /&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Subsequent messages only show day and time: &lt;code&gt;time=&quot;14 21:53:14&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header shows ICQ numbers of participants and tags which one is the &quot;receiver&quot;: &lt;code&gt;contactId=&quot;987654321&quot; type=&quot;myself&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;List of messages shows full information: Username, ICQ number, whether the message was received or not: &lt;code&gt;nick=&quot;User1&quot; in=&quot;0&quot; from=&quot;987654321&quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;plaintext-log&quot;&gt;Plaintext log&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Session Start (987654321:User2): Thu Dec 21 13:41:52 2006&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[13:41] User2: hey^^&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[13:42] User1: hay ;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[14:17] *** Thu Dec 21 14:17:39 2006 - User2 ist nun Offline.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[18:00] *** Sie wurden getrennt. Thu Dec 21 18:00:54 2006.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[18:37] *** Sie wurden getrennt. Thu Dec 21 18:37:08 2006.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[21:37] *** Sie wurden getrennt. Thu Dec 21 21:37:46 2006.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Session Close (User2): Thu Dec 21 22:09:57 2006&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Session Start (987654321:User2): Thu Dec 28 18:56:30 2006&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[18:56] User2: hey^^&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[18:56] User2: wie gehts?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[18:56] User1: hay&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[18:56] User1: passd scho&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[21:41] *** Sie wurden getrennt. Thu Dec 28 21:41:32 2006.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[21:41] *** Thu Dec 28 21:41:39 2006 - User2 ist nun Online.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[22:07] *** Thu Dec 28 22:07:56 2006 - User2 ist nun Offline.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Session Close (User2): Fri Dec 29 00:05:26 2006&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Format: &lt;code&gt;plaintext&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header contains start timestamp: &lt;code&gt;Thu Dec 21 13:41:52 2006&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Messages only have time: &lt;code&gt;13:41&lt;/code&gt; (accurate to the minute only)&lt;/li&gt;
&lt;li&gt;Header contains only ICQ number and username of messaging partner: &lt;code&gt;987654321:User2&lt;/code&gt;, but not of the receiver&lt;/li&gt;
&lt;li&gt;Chatlogs automatically separated by &quot;sessions&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;second-plaintext-log&quot;&gt;Second Plaintext log&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;User1 messages history&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date : 08.08.2005    Time : 14:52&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;To : User1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;lustig&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date : 08.08.2005    Time : 14:51&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;From : User2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Und wie wars?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date : 08.08.2005    Time : 14:51&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;To : User1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;hi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date : 08.08.2005    Time : 14:50&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;From : User2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Moin moin&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Format: &lt;code&gt;plaintext&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header does not contain useful information&lt;/li&gt;
&lt;li&gt;Each message has a minute-accurate timestamp: &lt;code&gt;Date : 08.08.2005    Time : 14:52&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Each message has the user information stored, and whether the message was sent or received: &lt;code&gt;To : User1&lt;/code&gt;/&lt;code&gt;From : User2&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Note: the messages are stored in reverse order: The oldest messages is at the bottom&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;html-format&quot;&gt;HTML format&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; http-equiv&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;content-type&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;text/html; charset=UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Conversation with 123456789 at Mo 04 Jan 2010 15:20:15 CET on 987654321 (icq)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;h3&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Conversation with 137749571 at Mo 04 Jan 2010 15:20:15 CET on 987654321 (icq)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;h3&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;#A82F2F&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; size&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;(15:20:15)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;User2:&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; hey ho&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;#16569E&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; size&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;(15:20:26)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;User1:&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; hoi&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Format: &lt;code&gt;HTML&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header has start timestamp: &lt;code&gt;Mo 04 Jan 2010 15:20:15 CET&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Messages only have a time: &lt;code&gt;(15:20:15)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header shows protocol: &lt;code&gt;(icq)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Header shows ICQ numbers: &lt;code&gt;123456789&lt;/code&gt;/&lt;code&gt;987654321&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Messages only show usernames: &lt;code&gt;User2&lt;/code&gt;/&lt;code&gt;User1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Messages may have different colors depending on sender/receiver: &lt;code&gt;#A82F2F&lt;/code&gt;/&lt;code&gt;#16569E&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Separation of chatlogs by date&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;facebook-format&quot;&gt;facebook format&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;participants&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;: [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;User2&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;User1&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    ],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;messages&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;: [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;sender_name&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;User1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;timestamp_ms&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt; 1340201234567&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;hm&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;sender_name&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;User2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;timestamp_ms&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt; 1340201235678&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;            &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;erkl&lt;/span&gt;&lt;span style=&quot;color: #F5C2E7;&quot;&gt;\u00c3\u00a4&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;rb&lt;/span&gt;&lt;span style=&quot;color: #F5C2E7;&quot;&gt;\u00c3\u00a4&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;r&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    ],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;Test Conversation&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;thread_path&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;quot;:&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;inbox/12345678912345678&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Format: &lt;code&gt;JSON&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Timestamp associated with each message&lt;/li&gt;
&lt;li&gt;No separation by &quot;conversation&quot; or &quot;session&quot;&lt;/li&gt;
&lt;li&gt;Header contains list of participants&lt;/li&gt;
&lt;li&gt;Each message also contains the name of the participant&lt;/li&gt;
&lt;li&gt;Conversations are not separated&lt;/li&gt;
&lt;li&gt;Note the encoding of special characters: &lt;code&gt;erkl\u00c3\u00a4rb\u00c3\u00a4r&lt;/code&gt;. We will touch on this later&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;Find more example input formats here: &lt;a rel=&quot;external&quot; href=&quot;https://gitlab.com/xicalango/clr2/-/tree/main/clr-ingest/res&quot;&gt;https://gitlab.com/xicalango/clr2/-/tree/main/clr-ingest/res&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;format-differences&quot;&gt;Format differences&lt;/h2&gt;
&lt;p&gt;From the chatlogs above we can already see a bunch of differences in how the information is presented:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Different formats: xml, html, plain text, json&lt;/li&gt;
&lt;li&gt;Different ways on how the timestamp is stored:
&lt;ul&gt;
&lt;li&gt;Some chatlogs have a full timestamp associated with each message&lt;/li&gt;
&lt;li&gt;Some chatlogs have a start timestamp in the header, and each message only has a fraction of the remaining information&lt;/li&gt;
&lt;li&gt;Also the accuracy of the timestamp varies a lot&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Different ways on how user information is stored:
&lt;ul&gt;
&lt;li&gt;Some show user information with username and user id&lt;/li&gt;
&lt;li&gt;Some have no clear connection between username and user id&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Separation of chatlogs
&lt;ul&gt;
&lt;li&gt;Some chatlogs are one huge file with all messages&lt;/li&gt;
&lt;li&gt;Some chatlogs are separated by date&lt;/li&gt;
&lt;li&gt;Some chatlogs have a concept of &lt;code&gt;session&lt;/code&gt; and separate the messages by that&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&quot;design&quot;&gt;Design&lt;/h1&gt;
&lt;p&gt;To work with this heterogeneous set of chatlogs where the information is stored so differently my plan was to separate the &quot;information extraction&quot; from the &quot;chatlog assembly&quot;.&lt;/p&gt;
&lt;p&gt;That is, one part of the program is just concerned to extract the information as found in the chatlog and convert them into a well known set of &quot;information bits&quot; (which i called &quot;tokens&quot;).
The tokens are designed to carry a single bit of information, closely mirroring how they appear in the input source, but well-defined and unified in their format.&lt;/p&gt;
&lt;p&gt;For example tokens could be time related: &lt;code&gt;TimeInfo(DateTime(&quot;2010-01-04&quot;, &quot;14:20:15&quot;, &quot;CET&quot;))&lt;/code&gt;, user related: &lt;code&gt;UserInfo{ id = &quot;123456789&quot;, name = &quot;User2&quot; }&lt;/code&gt;, message related: &lt;code&gt;MessageContent(&quot;hallo&quot;)&lt;/code&gt;, or just contain meta information, either for structure: &lt;code&gt;MetaStart&lt;/code&gt;/&lt;code&gt;MetaEnd&lt;/code&gt;, &lt;code&gt;MessageStart&lt;/code&gt;/&lt;code&gt;MessageEnd&lt;/code&gt;, or for metadata: &lt;code&gt;Platform(&quot;icq&quot;)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Depending on the context, tokens could mean different things as well, e.g. a &lt;code&gt;TimeInfo&lt;/code&gt; token found between &lt;code&gt;MetaStart&lt;/code&gt;/&lt;code&gt;MetaEnd&lt;/code&gt; tokens gives time information about the whole conversation, while it being found between &lt;code&gt;MessageStart&lt;/code&gt;/&lt;code&gt;MessageEnd&lt;/code&gt; will relate the time information to a specific message.&lt;/p&gt;
&lt;p&gt;Those tokens would be passed on to a different component which would take the tokens in arbitrary order and assmeble the chatlogs into a common format.&lt;/p&gt;
&lt;p&gt;That way I just need to implement a &quot;tokenizer&quot; per chatlog format that generates a &quot;stream of tokens&quot; which then gets passed into a generic &quot;Chatlog assembler&quot; which then creates the final chatlog from the stream of tokens.&lt;/p&gt;
&lt;p&gt;In a diagram the pipeline looks like this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;***************           +++++++++++++++++++++++++++&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* XML chatlog * --------&amp;gt; + XML chatlog &amp;quot;tokenizer&amp;quot; + --------+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;***************           +++++++++++++++++++++++++++         |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                                                              |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*********************     +++++++++++++++++++++++++++++++++   |    ********************     +++++++++++++++++++++     ************ &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* Plaintext chatlog * --&amp;gt; + Plaintext chatlog &amp;quot;tokenizer&amp;quot; + --+--&amp;gt; * Stream of tokens * --&amp;gt; + Chatlog assembler + --&amp;gt; * Chatlogs * *&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*********************     +++++++++++++++++++++++++++++++++   |    ********************     +++++++++++++++++++++     ************ *&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                                                              |                                                        *************&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;****************          ++++++++++++++++++++++++++++        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* JSON chatlog * -------&amp;gt; + JSON chatlog &amp;quot;tokenizer&amp;quot; + -------+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;****************          ++++++++++++++++++++++++++++&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For each input format there exists a specific tokenizer, but the tokens are sent to a singular &quot;Chatlog assembler&quot;.&lt;/p&gt;
&lt;h2 id=&quot;token-example&quot;&gt;Token example&lt;/h2&gt;
&lt;p&gt;To illustrate the &quot;tokenization&quot; with an example:&lt;/p&gt;
&lt;p&gt;Taking an XML export:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt;&lt;span&gt; Kopete-History&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;kopete-history&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; version&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;0.9&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; month&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; year&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;2007&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;contact&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; contactId&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;987654321&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;myself&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;contact&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; contactId&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;123456789&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; nick&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;User2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; in&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; from&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;123456789&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;14 21:53:14&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt;hi&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; nick&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;User1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; in&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; from&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;987654321&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;14 21:54:4&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt;hallo&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;msg&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;kopete-history&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This could be transformed into the following sequence of tokens:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ConversationStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MetaStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Month(3))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Year(2007))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ id = &amp;quot;987654321&amp;quot;, tag = Receiver }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ id = &amp;quot;123456789&amp;quot;, tag = Sender }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MetaEnd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ id = &amp;quot;123456789&amp;quot;, name = &amp;quot;User2&amp;quot; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageTag(Received)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Day(14))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Time(&amp;quot;21:53:14&amp;quot;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageContent(&amp;quot;hi&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageEnd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ id = &amp;quot;987654321&amp;quot;, name = &amp;quot;User1&amp;quot; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageTag(Sent)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Day(14))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Time(&amp;quot;21:54:04&amp;quot;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageContent(&amp;quot;hallo&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageEnd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ConversationEnd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;While scanning through the XML file we convert the various information bits into a stream of tokens.
For example once we read the &lt;code&gt;&amp;lt;date month=&quot;3&quot; year=&quot;2007&quot; /&amp;gt;&lt;/code&gt; part in the XML source, we can emit the tokens &lt;code&gt;TimeInfo(Month(3))&lt;/code&gt; and &lt;code&gt;TimeInfo(Year(2007))&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;To give another example here&#39;s how the HTML format could be translated:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; http-equiv&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;content-type&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;text/html; charset=UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Conversation with 123456789 at Mo 04 Jan 2010 15:20:15 CET on 987654321 (icq)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;h3&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Conversation with 137749571 at Mo 04 Jan 2010 15:20:15 CET on 987654321 (icq)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;h3&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;#A82F2F&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; size&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;(15:20:15)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;User2:&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; hey ho&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;#16569E&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;&quot;&gt; size&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;(15:20:26)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;User1:&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; hoi&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This could be tokenized as:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ConversationStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MetaStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ id = &amp;quot;123456789&amp;quot;, tag = Sender }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ id = &amp;quot;987654321&amp;quot;, tag = Receiver }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(DateTime(&amp;quot;2010-01-04&amp;quot;, &amp;quot;14:20:15&amp;quot;, &amp;quot;CET&amp;quot;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Platform(&amp;quot;icq&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MetaEnd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ name = &amp;quot;User2&amp;quot; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageTag(Received)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Time(&amp;quot;15:20:15&amp;quot;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageContent(&amp;quot;hey ho&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageEnd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageStart&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UserInfo{ name = &amp;quot;User1&amp;quot; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageTag(Sent)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TimeInfo(Time(&amp;quot;15:20:26&amp;quot;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageContent(&amp;quot;hoi&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MessageEnd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ConversationEnd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even though the input formats are vastly different we can reduce them to the same set of tokens.&lt;/p&gt;
&lt;h2 id=&quot;implementing-tokenizers&quot;&gt;Implementing tokenizers&lt;/h2&gt;
&lt;p&gt;Implementing a tokenizer for a given format is usually a straightforward proces. If the input format is a structured format (like XML or JSON) one can employ an existing parser for those formats (e.g. rust packages &lt;code&gt;serde_json&lt;/code&gt; or &lt;code&gt;xml&lt;/code&gt;) and use them to construct the tokens.&lt;/p&gt;
&lt;p&gt;XML based parsers emit events&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, e.g. one event could be &lt;code&gt;StartElement(&quot;head&quot;)&lt;/code&gt;. This can be transformed into a token &lt;code&gt;MetaStart&lt;/code&gt;. Or an event &lt;code&gt;StartElement(&quot;date&quot;)&lt;/code&gt; can be transformed into a &lt;code&gt;TimeInfo&lt;/code&gt; token, while extracting the &lt;code&gt;month&lt;/code&gt; and &lt;code&gt;year&lt;/code&gt; attributes.&lt;/p&gt;
&lt;p&gt;For other formats a combination of regex and line-based processing usually works good enough as well. Especially the HTML format is well-structured, so it can be parsed using regex.&lt;/p&gt;
&lt;p&gt;Find the implementation of different tokenizers here: &lt;a rel=&quot;external&quot; href=&quot;https://gitlab.com/xicalango/clr2/-/tree/main/clr-ingest/src/parser/tokenizer&quot;&gt;https://gitlab.com/xicalango/clr2/-/tree/main/clr-ingest/src/parser/tokenizer&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&quot;tokens-to-chatlog&quot;&gt;Tokens to chatlog&lt;/h1&gt;
&lt;p&gt;Now we have a stream of tokens, how do we assemble this into a unified chatlog?
Given that this is its own challenge this will be discussed in part 2. Stay tuned!&lt;/p&gt;
&lt;hr /&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;1&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;/sup&gt;
&lt;p&gt;In case you&#39;re wondering where the &quot;2&quot; is coming from: This is my third attempt at implementing this.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;2&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;/sup&gt;
&lt;p&gt;In retrospective maybe &quot;event&quot; would have been a better name than &quot;token&quot; in my implementation as well...&lt;/p&gt;
&lt;/div&gt;
</description>
      </item>
    </channel>
</rss>
