<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Marco Steinke</title>
    <description>The latest articles on DEV Community by Marco Steinke (@marcosteinke).</description>
    <link>https://dev.to/marcosteinke</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F593386%2F8f419870-0313-4549-b60c-7549e983c078.jpeg</url>
      <title>DEV Community: Marco Steinke</title>
      <link>https://dev.to/marcosteinke</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marcosteinke"/>
    <language>en</language>
    <item>
      <title>Brief summary of ChatGPT</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Tue, 20 Dec 2022 15:04:33 +0000</pubDate>
      <link>https://dev.to/marcosteinke/brief-summary-of-chatgpt-3gej</link>
      <guid>https://dev.to/marcosteinke/brief-summary-of-chatgpt-3gej</guid>
      <description>&lt;p&gt;This content is part of my collection of Machine Learning resources. Check out my repository &lt;a href="https://www.github.com/MarcoSteinke/Machine-Learning-Resources"&gt;https://www.github.com/MarcoSteinke/Machine-Learning-Resources&lt;/a&gt; and leave a star, if you like my collection of resources on Machine Learning and Artificial Intelligence&lt;/p&gt;

&lt;h2&gt;
  
  
  ChatGPT:
&lt;/h2&gt;

&lt;p&gt;ChatGPT is a ChatBot which is powered by artificial&lt;br&gt;
intelligence and was created by OpenAI.&lt;br&gt;
It is still considered as a prototype and was released in the november of 2022.&lt;/p&gt;

&lt;h2&gt;
  
  
  Training Methods:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RLHF (Reinforcement Learning from Human Feedback&lt;/li&gt;
&lt;li&gt;Proximal Policy Optimization (also reinforcement learning)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  I/O:
&lt;/h2&gt;

&lt;p&gt;For the input and output ChatGPT uses GPT 3.5 which is another AI model. GPT is short for &lt;br&gt;
Generative Pre-Trained-Transformer and GPT is an improved version of OpenAI's GPT-3.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protection against wrong and adversial answers
&lt;/h2&gt;

&lt;p&gt;Before ChatGPT was developed, OpenAI learned a lot from their research on GPT and Codex, another model of OpenAI.&lt;br&gt;
Thus, ChatGPT includes various mechanism which try to protect ChatGPT against wrong and adversial answers.&lt;br&gt;
Since this is a really hard job, ChatGPT already does a good job on this, but still has to get a lot of improvements.&lt;/p&gt;

&lt;p&gt;ChatGPT will continuously be improved by human input and feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Training Data:
&lt;/h2&gt;

&lt;p&gt;The training data of ChatGPT consists of texts which were created by humans. This has the purpose of training ChatGPT to &lt;br&gt;
communicate with its users in a natural way. Thus, it uses texts from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;forums&lt;/li&gt;
&lt;li&gt;social Media&lt;/li&gt;
&lt;li&gt;blogs&lt;/li&gt;
&lt;li&gt;books&lt;/li&gt;
&lt;li&gt;spoken language&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Problems with human input:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In the early stages of the training users did prefer long answers, which resulted in CHATGPT answering with longer texts.&lt;/li&gt;
&lt;li&gt;Algorithmic bias: The training data can cause the model to give biased answers, for example it can interpret the word "CEO" as a succesful white male person&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Applications:
&lt;/h2&gt;

&lt;p&gt;The model has the purpose of serving a tool for natural conversation with an AI to inform the human about expressions, definitions, concepts of various areas of the human life.&lt;br&gt;
For example ChatGPT understands all common human languages and can translate between them.&lt;br&gt;
It can also be used to generate text templates, which can then be improved by the human.&lt;br&gt;
ChatGPT is also able to explain complex contexts in simple language and can present a brief overview of certain topics.&lt;br&gt;
If you ask ChatGPT about "Scaling of Software" it will define what Scaling is and will also name different methods of scaling. The users can then answer and pick one of the named methods to step one step deeper into this topic and receive an overview of this certain subtopic.&lt;br&gt;
Thus, complex information could get available for a broader audience by using ChatGPT's simpler explanations.&lt;/p&gt;

&lt;p&gt;Another powerful ability of ChatGPT is the generation and explanation of sourcecode and configurations. Using ChatGPT developers are able to generate code for all common programming languages. This does even work for frameworks like Unity or ThreeJS. ChatGPT also explains every piece of code and provides information about the performance of the generated code and how it can bei improved. &lt;/p&gt;

&lt;h2&gt;
  
  
  Critique:
&lt;/h2&gt;

&lt;p&gt;ChatGPT can in one answer provide a correct and high quality formulation and in the next answer it could provide something completely stupid or wrong, as described by AI expert Gary Marcus. Thus, users always have to remind that the answers of ChatGPT always require verifications, before using them in a serious situation.&lt;br&gt;
Another problem has to do with scientific or very complex backgrounds. In these ChatGPT offers well-written and long answers, which are actually completely wrong in some contexts. This was tested by the physicist Teresa Kubacka by asking ChatGPT about her doctoral thesis in physics.&lt;br&gt;
The german blog author Sascha Lobo is fascinated by ChatGPT, but also fears a huge wave of spam on the internet, which was generated by ChatGPT. This problem forced Reddit to ban content which was generated using ChatGPT.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Learning from Human Preferences. OpenAI, 13. Juni 2017, abgerufen am 11. Dezember 2022 (englisch).&lt;/li&gt;
&lt;li&gt;Paul Christiano, Jan Leike, Tom B. Brown, Miljan Martic, Shane Legg, Dario Amodei: Deep reinforcement learning from human preferences. 13. Juli 2017, doi:10.48550/arxiv.1706.03741.&lt;/li&gt;
&lt;li&gt;Proximal Policy Optimization. OpenAI, 20. Juli 2017, abgerufen am 9. Dezember 2022 (englisch).&lt;/li&gt;
&lt;li&gt;John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, Oleg Klimov: Proximal Policy Optimization Algorithms. 28. August 2017, doi:10.48550/arxiv.1707.06347.&lt;/li&gt;
&lt;li&gt;ChatGPT: The Ultimate Tool for Natural Language Processing and Text Generation. Abgerufen am 16. Dezember 2022 (englisch).&lt;/li&gt;
&lt;li&gt;OpenAI: ChatGPT: Optimizing Language Models for Dialogue (englisch) 30. November 2022. Abgerufen am 5. Dezember 2022.&lt;/li&gt;
&lt;li&gt;Murphy Kelly: This AI chatbot is dominating social media with its frighteningly good essays (englisch) In: CNN. 5. Dezember 2022. Abgerufen am 5. Dezember 2022.&lt;/li&gt;
&lt;li&gt;Eike Kühl: ChatGPT: Gut erfunden ist halb geglaubt. In: zeit.de. 6. Dezember 2022, abgerufen am 10. Dezember 2022.&lt;/li&gt;
&lt;li&gt;ChatGPT is a new AI chatbot that can find mistakes in your code or write a story for you. In: Business Insider. Abgerufen am 9. Dezember 2022.&lt;/li&gt;
&lt;li&gt;Sophia Schmid: ChatGPT - Überblick zum neuen Tool von OpenAI. In: neuroflash. 5. Dezember 2022, abgerufen am 17. Dezember 2022 (deutsch).&lt;/li&gt;
&lt;li&gt;Sophia Schmid: Wo kommt ChatGPT am besten zur Anwendung? In: neuroflash. 12. Dezember 2022, abgerufen am 17. Dezember 2022 (deutsch).&lt;/li&gt;
&lt;li&gt;ChatGPT. In: OpenAI. OpenAI, 30. November 2022, abgerufen am 9. Dezember 2022 (englisch).&lt;/li&gt;
&lt;li&gt;Michael Moorstedt: Künstliche Intelligenz Chat GPT beantwortet Fragen verblüffend klug. In: sueddeutsche.de. 4. Dezember 2022, abgerufen am 10. Dezember 2022.&lt;/li&gt;
&lt;li&gt;Jakob Jung: Stack Overflow verbannt OpenAI ChatGPT. In: ZDnet.de. 7. Dezember 2022, abgerufen am 10. Dezember 2022.&lt;/li&gt;
&lt;li&gt;Sascha Lobo: Das Ende der irrelevanten künstlichen Intelligenz. In: Der Spiegel (online). 7. Dezember 2022, abgerufen am 10. Dezember 2022.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/paniterka_ch/status/1599893718214901760"&gt;https://twitter.com/paniterka_ch/status/1599893718214901760&lt;/a&gt;. Abgerufen am 17. Dezember 2022.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/paniterka_ch/status/1599893839367483392"&gt;https://twitter.com/paniterka_ch/status/1599893839367483392&lt;/a&gt;. Abgerufen am 17. Dezember 2022.&lt;/li&gt;
&lt;li&gt;Datenwissenschaftlerin aus Zürich warnt vor ChatGPT und den bösen Folgen. Abgerufen am 17. Dezember 2022 (Schweizer Hochdeutsch).&lt;/li&gt;
&lt;li&gt;ChatGPT — Release Notes. 15. Dezember 2022, abgerufen am 18. Dezember 2022 (englisch).&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>chatgpt</category>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Text Prediction using Bigrams and Markov Models</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Fri, 26 Nov 2021 12:36:16 +0000</pubDate>
      <link>https://dev.to/marcosteinke/text-prediction-using-bigrams-and-markov-models-229k</link>
      <guid>https://dev.to/marcosteinke/text-prediction-using-bigrams-and-markov-models-229k</guid>
      <description>&lt;h1&gt;
  
  
  1. Introduction:
&lt;/h1&gt;

&lt;p&gt;For the implementation of text prediction I am using the concept of Markov Models, which allows me to calculate the probabilities of consecutively events. I will first explain what a Markov Model is.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Hidden Markov Model:
&lt;/h1&gt;

&lt;p&gt;To explain a Markov Model it is important to start by understanding what a Markov Chain is.&lt;/p&gt;

&lt;h2&gt;
  
  
  2.1 Markov-Chain
&lt;/h2&gt;

&lt;p&gt;A Markov Chain is a stochastic model, which models a sequence of random variables. It is assumed that states in the future only depend on a limited amount of previous states (Markov Adoption)&lt;/p&gt;

&lt;p&gt;Let q1, q2, …​, qn be a series of states. With the Markov Adoption you can assume:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jp3cRQH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/Machine-Learning-Concepts/blob/main/blog/text-prediction/markovchain.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jp3cRQH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/Machine-Learning-Concepts/blob/main/blog/text-prediction/markovchain.PNG%3Fraw%3Dtrue" alt="" width="333" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  markovchain
&lt;/h3&gt;

&lt;p&gt;So instead of spectating the probabilities of all previous states of the series, you may only spectate the previous state and end up with the same result.&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Text prediction:
&lt;/h1&gt;

&lt;p&gt;After introducing the idea of hidden Markov models and Markov chains I can now proceed and presentate the appliance of this concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.1 N-grams:
&lt;/h2&gt;

&lt;p&gt;Let the next sentence be the ongoing example for this section.&lt;/p&gt;

&lt;p&gt;"On a rainy day please carry an umbrella."&lt;/p&gt;

&lt;p&gt;Following the idea of Markov chains, you are interested in the following probabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;P( a | On )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P( rainy | a )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P( day | rainy )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P( please | day )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P( carry | please )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P( an | carry )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P( umbrella | an )&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore you will have to understand the structure of each probability:&lt;/p&gt;

&lt;p&gt;P(day, rainy) defines the probability of the word "day" following the word "rainy" in a given input. You can use the following synonyms:&lt;/p&gt;

&lt;p&gt;P(day,rainy) → next = day, previous = rainy.&lt;/p&gt;

&lt;p&gt;To get this probability, you will have to count the amount of the value of previous in the given input and then count how often the value of next is following the value of previous in the given input.&lt;/p&gt;

&lt;p&gt;The quotient of them gives you the probability as follows:&lt;/p&gt;

&lt;p&gt;P(next, previous = (|next| / |previous|).&lt;/p&gt;

&lt;p&gt;This will get clear using the following quote:&lt;/p&gt;

&lt;p&gt;"To be or not to be"&lt;/p&gt;

&lt;p&gt;What is the probability P(be, to) ?&lt;/p&gt;

&lt;p&gt;Ignoring the casing of the words (you could format all words to lowercase beforehand) you will find "to" being 2 times in the given input and "be" being following "to" 2 times, so you get the probability P(be, to) = 2/2 = 1.&lt;/p&gt;

&lt;p&gt;Following this scheme you can now calculate the probabilites for all pairs of words.&lt;/p&gt;

&lt;p&gt;If you use this type of probabilities where exactly two words are required to calculate a probability, then you are using Bigrams or 2-grams.&lt;/p&gt;

&lt;p&gt;You can generalize this idea by defining N-grams, where a N-gram is the probability which you can again find in the Markov chain:&lt;/p&gt;

&lt;p&gt;markovchain&lt;br&gt;
In the text example, you would find a probability such as:&lt;/p&gt;

&lt;p&gt;P(be, To be or not to) = 1&lt;/p&gt;

&lt;p&gt;where your next-value is a single word and the previous-value is a sequence of words with the length n-1.&lt;/p&gt;
&lt;h2&gt;
  
  
  3.2 Application of N-grams to text prediction:
&lt;/h2&gt;

&lt;p&gt;Now to predict text you will need the following components:&lt;/p&gt;
&lt;h3&gt;
  
  
  3.2.1 Input:
&lt;/h3&gt;

&lt;p&gt;You will need any sort of textarea or predefined string (for texts it may be a multiline string or a list). This input has to be processed and stored, such that any algorithm can iterate through the result and built bigrams or N-grams from it.&lt;/p&gt;

&lt;p&gt;In this implementation I read the input from a textarea and defined an array of separators.&lt;/p&gt;

&lt;p&gt;static SEPARATORS = ['.', ',', '!', '?', '', "\n"];&lt;br&gt;
Those separators will be used to determine when a sentence or paragraph is ending and there shall not be instantiated a bigram from the input at the given location.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
"One apple please. I also want a bag."&lt;/p&gt;

&lt;p&gt;This would lead to the construction of the bigram (I, please) with P(I | please), which is not really included in the given input.&lt;/p&gt;

&lt;p&gt;To avoid such wrong bigrams I am checking each word for not being a separator.&lt;/p&gt;

&lt;p&gt;After checking for separators you can iterate through the text and process the input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;formatInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// (1)&lt;/span&gt;
        &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

        &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;! &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;? &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^,^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^.^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^!^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^?^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replaceAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// (2)&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isSeparator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first part of the method (1) I am replacing all separators with spaces around them with the exact same separator, but without spaces. Then I replace the separator with "^^" around it, so I can later split the input and remain the separators in my processed data.&lt;/p&gt;

&lt;p&gt;Afterwards I am checking the end of the data for a separator (2), because I do not want to have any unexpected behaviour of my algorithm when coming to the end, where a separator is the last piece of input and no other word is following it.&lt;/p&gt;

&lt;p&gt;This would result in the following:&lt;/p&gt;

&lt;p&gt;Input: "To be, or not to be."&lt;/p&gt;

&lt;p&gt;Output (1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;be&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;or&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;not&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;be&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And after (2) has finished, it would return:&lt;/p&gt;

&lt;p&gt;Output (2):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;be&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;or&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;not&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;be&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now I received the input as list with the remaining separators inside of the text, but not the unnecessary separator at the end of the input.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2.2 Successors and the input:
&lt;/h3&gt;

&lt;p&gt;To construct bigrams from the input, I first wanted to count each word and store the amount in a map. The map would have looked like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;wordCountMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;One&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would map each word to its amount.&lt;/p&gt;

&lt;p&gt;But with this concept I looked into the future of the implementation and realized I throw away a very important information when only storing the amount of each word.&lt;/p&gt;

&lt;p&gt;BECAUSE: I would still have to iterate through the processed input over and over again to check each word for its successor.&lt;br&gt;
This led me to the idea of replacing my original problem by a equivalent algorithmic problem, which only requires numbers and no information about the words.&lt;/p&gt;

&lt;p&gt;Problem of successing indices:&lt;br&gt;
Given two sets of integers, find the amount of integers from the first set which are numerically successors of any integers from the second set.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example: Given A = {4, 11, 19, 27} and B = {5, 20}
&lt;/h4&gt;

&lt;p&gt;You would iterate through A and for each integer from A, you would look if there is any integer in B which is an successor of the current integer from A. If yes, increment a counter and continue with the next integer from A, if no, directly continue with the next integer from A.&lt;/p&gt;

&lt;p&gt;In this case it would lead to a counter of 2, because B[0] = 5 = 4 + 1 = A[0] + 1 and B[1] = 20 = 19 + 1 = A[2] + 1.&lt;/p&gt;

&lt;p&gt;If you now divide this counter by the size (cardinality) of A, you now would get the probability of B including a successor of an integer from A.&lt;/p&gt;

&lt;p&gt;This numerical problem can now be represented by using the location (index) of words in a text (list).&lt;/p&gt;
&lt;h3&gt;
  
  
  3.2.3 Constructing Bigrams:
&lt;/h3&gt;

&lt;p&gt;To construct bigrams you would have iterate through the list and in each iteration step look at the current value of the iterator and its successor, or to talk in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;generateBigrams&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;existingBigramHashes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bigrams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasWordsCounted&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SEPARATORS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SEPARATORS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;existingBigramHashes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bigrams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]));&lt;/span&gt;
                &lt;span class="nx"&gt;existingBigramHashes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This piece of code basically looks at Bigram.input[i] and Bigram.input[i+1] and constructs a bigram from it, using the following constructor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Will be explained later !&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findProbability&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also checks for duplicate bigrams by comparing the current input[i] and input[i+1] to the ones from all previously constructed bigrams. Lastly it checks for bigrams to not include any of the separators.&lt;/p&gt;

&lt;p&gt;Now after bigrams are constructed, there will only be the task of computing the probabilities for all bigrams.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2.4 Computing the probabilities (or solving the index successor problem):
&lt;/h3&gt;

&lt;p&gt;At this point you already know instead of counting the amount of the previous word of a bigram and then iterate through the text and count how often the next word of a bigram is following the previous one, you can also solve the already defined index successor problem.&lt;/p&gt;

&lt;p&gt;Now instead of counting the words I want to map each word to the indices at which the word occurs in the input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;countWords&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasInput&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isFormatted&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tmpArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="nx"&gt;tmpArr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tmpArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In general, this method iterates through the processed input and checks if a certain word is already stored in the map and then follows two different cases:&lt;/p&gt;

&lt;p&gt;if the word is not in the map yet, put it in the map and store a list with the current position in the text as value.&lt;/p&gt;

&lt;p&gt;if the word already is in the map, load the list from the map and add the current position to it.&lt;/p&gt;

&lt;p&gt;Let the following be the input:&lt;/p&gt;

&lt;p&gt;"One Ring to rule them all, One Ring to find them, One Ring to bring them all, and in the darkness bind them"&lt;/p&gt;

&lt;p&gt;For the given input you would then receive the following map:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;One&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ring&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rule&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;them&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="nx"&gt;Entries&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;One&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;One&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;them&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;them&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;find&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;find&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bring&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;and&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;and&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;in&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;in&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;the&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;the&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;darkness&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;darkness&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bind&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bind&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And as you can see there is an array including the positions (indices) for each word of the input.&lt;/p&gt;

&lt;p&gt;To calculate the probabilites for all bigrams, we now have to iterate through the list of all bigrams which were already constructed and run the algorithm which I have explained before on each bigram.&lt;/p&gt;

&lt;p&gt;So for each bigram run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;findProbability&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;probability&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;Bigram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wordCountMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will, as already explained before, take the array of indices from the previous-value and then count in how many of the cases there is an successor in the indices array from the next-value for the current integer from the previous-value array.&lt;/p&gt;

&lt;p&gt;The final result can be seen in the following probabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;P(Ring | One) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(to | Ring) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(rule | to) = 0.3333333333333333&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(them | rule) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(all | them) = 0.5&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(find | to) = 0.3333333333333333&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(them | find) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(bring | to) = 0.3333333333333333&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(them | bring) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(in | and) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(the | in) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(darkness | the) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(bind | darkness) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;P(them | bind) = 1'&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You have now learned how to predict the probability of a word following another word by a given input.&lt;br&gt;
In the next part you will see how all of this can be used to generate text by using those probabilities!&lt;/p&gt;

&lt;p&gt;If you want to have a look at the actual implementation, feel free to look at the files included in this directory or to visit:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bestofcode.net/Applications/text-prediction"&gt;https://bestofcode.net/Applications/text-prediction&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;Source-code can be found here: &lt;a href="https://github.com/MarcoSteinke/Machine-Learning-Concepts/tree/main/implementation/1.%20text-prediction"&gt;https://github.com/MarcoSteinke/Machine-Learning-Concepts/tree/main/implementation/1.%20text-prediction&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>You are wasting resources by using classical surveillance</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Wed, 24 Nov 2021 12:33:59 +0000</pubDate>
      <link>https://dev.to/marcosteinke/you-are-wasting-resources-by-installing-surveillance-2nfh</link>
      <guid>https://dev.to/marcosteinke/you-are-wasting-resources-by-installing-surveillance-2nfh</guid>
      <description>&lt;p&gt;Greetings fellow developers on dev.to&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;Today I am mentioning a topic why is neccessary when owning your own small business, or protecting your by using installing surveillance cameras. &lt;/p&gt;

&lt;p&gt;The cameras which you install to protect your possession do mostly offer no more than a video source, which is persisted on any type of hard drive (in marketing they would say "secure data server") inside of your shop or home and will only be inspected if something happened. &lt;/p&gt;

&lt;p&gt;Some more modern surveillance technologies do also offer &lt;code&gt;motion detection&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Thus the motion detection may somehow be used to update the cameras orientation, as often seen in Action Movies. The camera may follow the motion by a certain degree thus the original field of view is still in sight but the motion can be captured too.&lt;/p&gt;

&lt;p&gt;But don't you think the motion detection could be used better?&lt;/p&gt;

&lt;p&gt;This and more will be the topic of this post and also of this series, which I create to also promote the GitHub project &lt;a href="https://github.com/SurvAPI/survAPI-Surveillance-Camera-Analysis"&gt;survAPI&lt;/a&gt;, which is under development to offer some more functionality to your existing surveillance and also give the ability of motion detection and a lot more to cheaper cameras, so you can configure which features your camera will be using.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Network cameras
&lt;/h2&gt;

&lt;p&gt;There are a lot of different types of cameras.&lt;/p&gt;

&lt;p&gt;Some examples are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IP Security Camera&lt;/li&gt;
&lt;li&gt;Analog MPX Security Camera&lt;/li&gt;
&lt;li&gt;Analog MPX Wireless Security Camera&lt;/li&gt;
&lt;li&gt;Wire-Free Security Camera Wiring&lt;/li&gt;
&lt;li&gt;Wi-Fi Security Camera Wiring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of them do have different architectures in capturing and persisting video material and &lt;a href="https://github.com/SurvAPI/survAPI-Surveillance-Camera-Analysis"&gt;survAPI&lt;/a&gt; tries to find a generalized interface to work with any type of camera as a middle-ware.&lt;/p&gt;

&lt;h3&gt;
  
  
  Problem:
&lt;/h3&gt;

&lt;p&gt;This security software has to become a module in security networks which is located between the actual video input device and the DVR if the video input device is not wireless or NVR if the video input device is wireless.&lt;/p&gt;

&lt;p&gt;An example would be the classical IP Security Camera:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://camo.githubusercontent.com/0822de14a1f75496c9573e3a6e68e8c1897bd83fd2466cb8d3aed4223a958cb5/68747470733a2f2f7777772e6c6f726578746563686e6f6c6f67792e636f6d2f696d616765732f61727469636c65732f636f6e74656e742f486f77546f496e7374616c6c2f76322f696d616765732f496e7374616c6c6174696f6e2d6469616772616d735f49502d472e706e67" class="article-body-image-wrapper"&gt;&lt;img src="https://camo.githubusercontent.com/0822de14a1f75496c9573e3a6e68e8c1897bd83fd2466cb8d3aed4223a958cb5/68747470733a2f2f7777772e6c6f726578746563686e6f6c6f67792e636f6d2f696d616765732f61727469636c65732f636f6e74656e742f486f77546f496e7374616c6c2f76322f696d616765732f496e7374616c6c6174696f6e2d6469616772616d735f49502d472e706e67" alt="IP Security Camera architecture" width="2084" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this system of an IP Security Camera you will find a cable which connects the NVR and the video input device by using power-over-ethernet (POE) technology to &lt;a href="https://www.lorex.com/pages/how-to-install-security-cameras"&gt;"provide both power and video transmission"&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This setup leaves no space for an external software which directly controls the video input stream. This problem is architectural and has to be solved by this software to achieve the highest possible compatibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Backwards Integration:
&lt;/h4&gt;

&lt;p&gt;When using the Backwards Integration, the software should be run on a server which is directly connected to the DVR/NVR and will rewatch the video material recorded, filter unimportant video information and redirect it either to the DVR/NVR or to the server to reduce the amount of data saved.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Automated Video Analysis:
&lt;/h4&gt;

&lt;p&gt;Using this method, the software is run on a server just as in the previous example. The software will then rewatch the video information received from the DVR/NVR and collect timestamps which flag video intervals in which target objects could be detected. You can then either keep your videos as they are or use the time stamps to remove unimportant sequences.&lt;/p&gt;

&lt;p&gt;More solutions have to come, but at the moment there is no idea to manipulate the video input stream between the video input device and the DVR/NVR, which would be the ultimate use-case for this software, since video fragments in which nothing happened (no motion detected, also no objects) would not be persisted and the amount of produced video material would be much smaller than on usual surveillance systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Goal
&lt;/h2&gt;

&lt;p&gt;And this is exactly what SurvAPI tries to achieve: Become a middle-ware which is able to directly read the input stream from a surveillance camera and only send them to the DVR/NVR if something "relevant" happens.&lt;/p&gt;

&lt;p&gt;But what does "relevant" mean? Well, this is your decision. SurvAPI uses &lt;code&gt;CocoSSD&lt;/code&gt; which is a Computer Vision Neural Network and trained to detection a list of different objects. SurvAPI will only step in if any of the personally chosen-objects (if configured) are detected in a certain surveillance camera. Otherwise no data will be persisted or if you still want to persist everything no timestamps will be saved to the database.&lt;/p&gt;

&lt;p&gt;Thus you will receive a lot of control over how your surveillance does work and also a toolkit which enables to filter a lot of unneccessary data produced by the camera before or after persistence.&lt;/p&gt;

&lt;p&gt;This will definitely reduce the cost of hard-drives since the server does persist less amount of data than on a regular setup.&lt;/p&gt;

&lt;p&gt;SurvAPI will also enable you to use cheaper (regular) cameras, install them and since it attaches to the camera the AI tools offered by SurvAPI will then analyze the videos and you do not need to buy very expensive cameras to have those tools.&lt;/p&gt;

&lt;p&gt;SurvAPI is also able to use the detected time stamps and video fragments for Data Analysis.&lt;/p&gt;

&lt;p&gt;Why don't you use your surveillance to notify if a customer leaves of enters your store?&lt;/p&gt;

&lt;p&gt;Why don't you use your surveillance to measure the distribution of customers visiting your store?&lt;/p&gt;

&lt;p&gt;You could also use the surveillance to do long-term statistics and find out how the amount of customers develops or a long period.&lt;/p&gt;

&lt;p&gt;Measure the effect of certain events and use the produced data for more reasons,&lt;/p&gt;

&lt;h4&gt;
  
  
  BUT DON'T WASTE SURVEILLANCE ONLY AS A RESOURCE OF SECURITY
&lt;/h4&gt;

&lt;h4&gt;
  
  
  ATTACH A MIDDLE-WARE AND MAKE MORE USE OF YOUR CAMERAS
&lt;/h4&gt;

&lt;h2&gt;
  
  
  4. Still work in progres
&lt;/h2&gt;

&lt;p&gt;SurvAPI is still work in progress. &lt;/p&gt;

&lt;p&gt;This post was only the first part of a longer series which will explain the development of SurvAPI step by step.&lt;/p&gt;

&lt;p&gt;In the next part I will show the architecture and the UI of the current version of SurvAPI&lt;/p&gt;

&lt;p&gt;There was a longer break on the project but the work will now be continued and you are free to check out the project using the following URL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/SurvAPI/survAPI-Surveillance-Camera-Analysis"&gt;SurvAPI on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I would love to get ⭐️ on the project if you like the idea and if you are also interested in the future of this project.&lt;/p&gt;

&lt;p&gt;I would also appreciate follows on my GitHub account &lt;a href="https://github.com/MarcoSteinke"&gt;MarcoSteinke on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>javascript</category>
      <category>datascience</category>
      <category>security</category>
    </item>
    <item>
      <title>Quick tool to check Covid-19 incidencies for German districts</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Tue, 26 Oct 2021 09:45:34 +0000</pubDate>
      <link>https://dev.to/marcosteinke/quick-tool-to-check-covid-19-incidencies-for-german-districts-1i25</link>
      <guid>https://dev.to/marcosteinke/quick-tool-to-check-covid-19-incidencies-for-german-districts-1i25</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;A very simple fetcher for COVID19 statistics offered by the Robert-Koch-Institut (RKI) in Germany. This tool was created, because in Germany you will have different restrictions in order to the current incidency of your district, since Germany released the "Coronanotstandverordnung", which allowed each individual state to release regional restrictions based on the local incidencies of the certain regions.&lt;/p&gt;

&lt;p&gt;In the future the tool will be advanced by displaying the current restrictions and also proven facts and science results and also information about Covid-19 and the restrictions.&lt;/p&gt;

&lt;p&gt;The page will also give information on why vaccination is important not only to yourself, but also to the society and also scientific information about the non-existence of long-term-consequences.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage:
&lt;/h2&gt;

&lt;p&gt;To use this tool, you will only have to follow 2 (or if you want to share 3) steps and profit:&lt;/p&gt;

&lt;p&gt;1️⃣ SELECT your district&lt;/p&gt;

&lt;p&gt;2️⃣ CHECK the latest information about your surrounding&lt;/p&gt;

&lt;p&gt;3️⃣ SHARE the information with your friends, family or coworkers&lt;/p&gt;

&lt;p&gt;You will start at the landing page of the qovis tool. You can either choose your district or look at the Covid-19 statistics in Germany.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kuJ2nIwC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/main.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kuJ2nIwC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/main.PNG%3Fraw%3Dtrue" alt="landing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Germany Statistics:
&lt;/h2&gt;

&lt;p&gt;In the Germany statistics you will find the current hotspots and safest districts in Germany. You will also find this information on every search page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_owgrR9e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/statis.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_owgrR9e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/statis.PNG%3Fraw%3Dtrue" alt="germany statistics"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Autocomplete:
&lt;/h2&gt;

&lt;p&gt;If you want to start searching for a district, qovis will support you with autocomplete in the search bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--liNeiEOG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/autocomplete.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--liNeiEOG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/autocomplete.PNG%3Fraw%3Dtrue" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  District Statistics:
&lt;/h2&gt;

&lt;p&gt;After choosing your district, you will be redirected to a page where you can see a photo taken in the district you were looking for and you will also find the current incidency and amount of cases and also different statistics which are useful to find out the development of the numbers you were seeing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PJsCQumo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/town.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PJsCQumo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/town.PNG%3Fraw%3Dtrue" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Neighbouring districts:
&lt;/h2&gt;

&lt;p&gt;After a district was selected you can directly go to the neighbouring districts by clicking them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WRczxRWl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/neighbours.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WRczxRWl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/neighbours.PNG%3Fraw%3Dtrue" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sharing:
&lt;/h2&gt;

&lt;p&gt;You can also share the current statistics page with your friends, family or coworkers by using the "Teilen" button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GWfrUQDU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/share.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GWfrUQDU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/share.PNG%3Fraw%3Dtrue" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fully mobile responsive:
&lt;/h2&gt;

&lt;p&gt;The website is also fully mobile responsive, so you can check current incidencies from everywhere. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fkCXrgXK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/mobile.PNG%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fkCXrgXK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/MarcoSteinke/qovis-RKI-statistics/raw/main/screenshots/mobile.PNG%3Fraw%3Dtrue" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you read until this point, you are free to check out the tool. you can access it at &lt;a href="https://qovis.steinke-it.com"&gt;https://qovis.steinke-it.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I would really enjoy getting a ⭐️ on the tool's github repo if you enjoy this. You can find the repo here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/MarcoSteinke/qovis-RKI-statistics"&gt;https://github.com/MarcoSteinke/qovis-RKI-statistics&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to know some background or technical details, feel free to comment on this post.&lt;/p&gt;

&lt;p&gt;If you want a blog post on how I implemented this tool, please also tell me! I would love to write a post on how this tool was implemented.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>covid</category>
      <category>api</category>
    </item>
    <item>
      <title>MovingPoint-Lightweight-Java-2D-Game-Engine</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Tue, 11 May 2021 14:02:39 +0000</pubDate>
      <link>https://dev.to/marcosteinke/movingpoint-lightweight-java-2d-game-engine-2m7l</link>
      <guid>https://dev.to/marcosteinke/movingpoint-lightweight-java-2d-game-engine-2m7l</guid>
      <description>&lt;p&gt;Find repo here: &lt;a href="https://github.com/MarcoSteinke/MovingPoint-Lightweight-Java-2D-Game-Engine"&gt;https://github.com/MarcoSteinke/MovingPoint-Lightweight-Java-2D-Game-Engine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1 Beginner Friendly / Educational&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I love programming and I also love teaching it to other persons, so the main goal of MovingPoint is to bring new motivated talents into programming. + A lot of people dream of creating their own games, MovingPoint gives them a first impression of Game Design + Even childs with basic Java skills could use this to create simple games like TicTacToe or Snake!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 Operating System Independence&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;since MovingPoint is written in pure Java, you can run it on any Operating System&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3 Hardware Independence&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MovingPoint is lightweight, you do not need the latest hardware to build your games. + You also do not need to import all modules, only use the code which you need to build your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4 Use all Java libraries!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes it is true. You can run any libraries and connect them to MovingPoint + You are able to create Browsergames by running a Java Webapplication and importing MovingPoint. + Also usable to create Android Apps by using Android Studio!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5 Open source&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Since I am coding for around 5 years and I tried out many different things, this is my first try on writing a Game Engine, so I want everybody to help me with the development. + You are able to use the Engine as you want to. Modify it, give me tips and together we can create a new experience of Game Design.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>📷 survAPI Surveillance Camera Analysis</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Tue, 11 May 2021 14:01:29 +0000</pubDate>
      <link>https://dev.to/marcosteinke/survapi-surveillance-camera-analysis-3ago</link>
      <guid>https://dev.to/marcosteinke/survapi-surveillance-camera-analysis-3ago</guid>
      <description>&lt;p&gt;❓ Need surveillance, but low on server capacity?&lt;br&gt;
💡 Train the camera to know when to record.&lt;/p&gt;

&lt;p&gt;find my Repository here: &lt;a href="https://github.com/MarcoSteinke/survAPI-Surveillance-Camera-Analysis"&gt;https://github.com/MarcoSteinke/survAPI-Surveillance-Camera-Analysis&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡ Introduction:
&lt;/h2&gt;

&lt;p&gt;This implementation demonstrates a Security-Camera Software which was written in javascript and uses cocossd offered by ml5 to detect objects.&lt;/p&gt;

&lt;p&gt;The application is secured using express-session and bcrypt. This way only authenticated users can access your surveillance and you are able to allow registrations and create new roles to control this system.&lt;/p&gt;

&lt;h3&gt;
  
  
  ❓ Problem:
&lt;/h3&gt;

&lt;p&gt;A business needs a security camera, but is low on server capacity. Thatswhy the business can not store videos 24/7.&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 Solution:
&lt;/h3&gt;

&lt;p&gt;Using Machine Learning, we can tell the camera when it has objects in view and use a lightweight backend to store the timestamps and also the type of objects which where detected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Classification:
&lt;/h3&gt;

&lt;p&gt;After detection, the software later classifies them as certain targets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Persistence
&lt;/h3&gt;

&lt;p&gt;If the classified object is one of the targets, it will be persisted in the database by giving information on its type and also adding a timestamp and date. Now we know when to start recording and stop after a predefined amount of time passed.&lt;/p&gt;

&lt;h2&gt;
  
  
  💪 Improvements over conventional Security Cameras:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;installation is very easy and very customizable due to Open Source Technology&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;a clean webinterface makes your cameras accessible and configurable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;detection of persons is a standard problem of Machine Learning and already has a very high precision&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;destroy video material in which nothing happens, you will only store critical/important moments&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⭐ advance your security by getting additional information from your camera.&lt;/p&gt;

&lt;p&gt;⭐ super simple setup.&lt;/p&gt;

&lt;p&gt;⭐ modern dashboard and webpages to access the cameras.&lt;/p&gt;

&lt;p&gt;⭐ combine any hardware with this software.&lt;/p&gt;

&lt;p&gt;⭐ SurvAPI: The included surveillance API also offers all of the analysis tool to be called from other frameworks.&lt;/p&gt;

&lt;p&gt;⭐ lightweight and fast.&lt;/p&gt;

&lt;p&gt;⭐ optimized amount of video data.&lt;/p&gt;

&lt;p&gt;⭐ Machine Learning used to detect certain targets.&lt;/p&gt;

&lt;p&gt;⭐ predefine intervals to control data produced by the camera.&lt;/p&gt;

&lt;p&gt;⭐ very simple database structure&lt;/p&gt;

&lt;p&gt;⭐high security level by using bcrypt&lt;/p&gt;

&lt;p&gt;🏛️ Architecture:&lt;br&gt;
The project will be separated into the subsystems Camera, Surveillance, Database, Webviews where each subsystem exactly solves one of the given business problems.&lt;/p&gt;

&lt;p&gt;To guarantee clean code, this project will profit from Domain Driven Design and from Self Contained System’s.&lt;/p&gt;

&lt;p&gt;Camera:&lt;br&gt;
The subsystem will fulfill the HARDWARE-part in this project. All types of cameras (which you find right below under Compatibility) will be connected via this subsystem. It defines a domain model which projects the real world properties of cameras into code and offers its configured cameras to all of the other subsystems. All of the input will run through this subsystem.&lt;/p&gt;

&lt;p&gt;Surveillance:&lt;br&gt;
The surveillance will process video material received from any video source, configured in the Camera subsystem. It makes use of ML5 and analyses the material based on the admins preferences. The analysis results will be persisted in the Database subsystem. It usually is not a separate subsystem, but for this project it will do best if the database can completely be substituted behind an interface which connects the Webviews and the Surveillance to it.&lt;/p&gt;

&lt;p&gt;Database:&lt;br&gt;
Use any type of database you want and store all of the analysis results. You can access the persisted data by using the Webviews or build your own UI to access it.&lt;/p&gt;

&lt;p&gt;Webviews:&lt;br&gt;
Basically a frontend which can be accessed from any webbrowser. You can configure the cameras, inspect detections in a nice way and get watch live material from your surveillance cameras.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>AI powered surveillance</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Fri, 26 Mar 2021 19:50:31 +0000</pubDate>
      <link>https://dev.to/marcosteinke/ai-powered-surveillance-3pan</link>
      <guid>https://dev.to/marcosteinke/ai-powered-surveillance-3pan</guid>
      <description>&lt;p&gt;❓ Problem:&lt;br&gt;
A business needs a security camera, but is low on server capacity. Thatswhy the business can not store videos 24/7.&lt;/p&gt;

&lt;p&gt;💡 Solution:&lt;br&gt;
Using Machine Learning, we can tell the camera when it has objects in view and use a lightweight backend to store the timestamps and also the type of objects which where detected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/MarcoSteinke/survAPI-Surveillance-Camera-Analysis"&gt;https://github.com/MarcoSteinke/survAPI-Surveillance-Camera-Analysis&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AI powered surveillance for businesses</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Sun, 14 Mar 2021 16:23:14 +0000</pubDate>
      <link>https://dev.to/marcosteinke/ai-powered-surveillance-for-businesses-2i1g</link>
      <guid>https://dev.to/marcosteinke/ai-powered-surveillance-for-businesses-2i1g</guid>
      <description>&lt;p&gt;❓ Problem:&lt;br&gt;
A business needs a security camera, but is low on server capacity. Thatswhy the business can not store videos 24/7.&lt;/p&gt;

&lt;p&gt;💡 Solution:&lt;br&gt;
Using Machine Learning, we can tell the camera when it has objects in view and use a lightweight backend to store the timestamps and also the type of objects which where detected.&lt;/p&gt;

&lt;p&gt;Find out more here: &lt;a href="https://github.com/MarcoSteinke/survAPI-Surveillance-Camera-Analysis"&gt;https://github.com/MarcoSteinke/survAPI-Surveillance-Camera-Analysis&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AI-powered surveillance for businesses.</title>
      <dc:creator>Marco Steinke</dc:creator>
      <pubDate>Tue, 09 Mar 2021 21:44:28 +0000</pubDate>
      <link>https://dev.to/marcosteinke/ai-powered-surveillance-for-businesses-1gj3</link>
      <guid>https://dev.to/marcosteinke/ai-powered-surveillance-for-businesses-1gj3</guid>
      <description>&lt;p&gt;A business needs a security camera, but is low on server capacity. Thatswhy the business can not store videos 24/7.&lt;/p&gt;

&lt;p&gt;💡 Solution:&lt;br&gt;
Using Machine Learning, we can tell the camera when it has objects in view and use a lightweight backend to store the timestamps and also the type of objects which where detected.&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="https://www.github.com/MarcoSteinke/Security-Cam"&gt;https://www.github.com/MarcoSteinke/Security-Cam&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
