<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Dimitris Dimitriadis</title>
	<atom:link href="https://dndimitri.eu/feed/" rel="self" type="application/rss+xml" />
	<link>https://dndimitri.eu/</link>
	<description>Researcher &#38; Developer</description>
	<lastBuildDate>Tue, 03 Oct 2023 18:43:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.2</generator>

<image>
	<url>https://i0.wp.com/dndimitri.eu/wp-content/uploads/2023/10/cropped-1696348391588_2-scaled-1.jpg?fit=32%2C32&#038;ssl=1</url>
	<title>Dimitris Dimitriadis</title>
	<link>https://dndimitri.eu/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">224285271</site>	<item>
		<title>Estimating Running Time of an Algorithm using Simple Rules.</title>
		<link>https://dndimitri.eu/2020/08/23/estimating-running-time-of-an-algorithm-using-simple-rules/</link>
					<comments>https://dndimitri.eu/2020/08/23/estimating-running-time-of-an-algorithm-using-simple-rules/#respond</comments>
		
		<dc:creator><![CDATA[Dimitris Dimitriadis]]></dc:creator>
		<pubDate>Sun, 23 Aug 2020 17:43:02 +0000</pubDate>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[analysis of algorithms]]></category>
		<guid isPermaLink="false">https://dndimitri.eu/?p=586</guid>

					<description><![CDATA[<p>To estimate the running time of an algorithm and the difference of the algorithm against others, we make a strong...</p>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2020/08/23/estimating-running-time-of-an-algorithm-using-simple-rules/">Estimating Running Time of an Algorithm using Simple Rules.</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>To estimate the running time of an algorithm and the difference of the algorithm against others, we make a strong assumption where the running time of an algorithm is independent of specific hardware. Using this assumption, we can study the efficiency of the algorithms and compare the algorithms to each other, deciding which one is better and finding an optimal solution to a problem.</p>



<p>Following the assumption of hardware independence, the analysis of the running time of an algorithm depends only on the statements defined in the algorithm (i.e., the steps that the algorithms need to follow for solving a specific problem). Since the execution time of the algorithms&#8217; statements is not the same for all of them (i.e., some steps need more time to be executed than others), it is necessary to be defined a set of rules. </p>



<h3 class="wp-block-heading">Rule 1: </h3>


<p>The time required to fetch an integer from memory is defined as <strong>t<sub>fetch</sub></strong>. The time needed to store an integer to the memory is defined as <strong>t<sub>store</sub></strong>.&nbsp;</p>
<p>For example, the running time of the statement “x = 1” is t<sub>fetch</sub>&nbsp;+ t<sub>store</sub>, because the integer is in the memory (typically any constant is stored in memory) and have to be fetched and also this integer has to be stored to the variable “x” which is in memory. The same running time has the statement “x = y” because we want to get the value of the variable “y” which is stored in memory. &nbsp;&nbsp;</p>


<h3 class="wp-block-heading">Rule 2:</h3>



<p>The time needed for each basic operation to be executed is defined as <strong>t<sub>+</sub>, t<sub>&#8211;</sub>, t<sub>x</sub>, t<sub>&lt;</sub>, t<sub>/</sub>.</strong> So, the running time of the statement “y = x + 1” is 2t<sub>fetch</sub>&nbsp;+ t<sub>+</sub>&nbsp;+ t<sub>store</sub>. The 2 fetches are for “x” and “1”. The result is stored in variable “y” (t<sub>store</sub>). The addition operation time is t<sub>+</sub>.&nbsp;&nbsp;</p>



<h3 class="wp-block-heading">Rule 3:</h3>



<p>The time needed&nbsp;to&nbsp;a function to be called is defined as&nbsp;<strong>t<sub>call</sub>&nbsp;</strong>while the time required to a function to return a value is defined as <strong>t<sub>return</sub></strong><sub>.</sub></p>



<h3 class="wp-block-heading">Rule 4:</h3>



<p>The time needed to pass a value as parameter to a function is the same as the time needed to store a value in memory. For example, the running time of “y = f(x)” is 2t<sub>store</sub>&nbsp;+ t<sub>fetch</sub>&nbsp;+ t<sub>call</sub>&nbsp;+ T<sub>f(x)</sub>. Note here that the t<sub>return</sub>&nbsp;is part of the function and not of the above statement. Furthermore, the T<sub>f(x)</sub>&nbsp;is the total running time of the function “f”.&nbsp;&nbsp;&nbsp;</p>



<h3 class="wp-block-heading">Rule 5: </h3>



<p>The time required for the address calculation implied by an array subscripting operation is defined as <strong>t<sub>[]&nbsp;</sub></strong>. For example, the running time of the statement “y = a[i]” is 3t<sub>fetch&nbsp;</sub>+ t<sub>store&nbsp;</sub>+t<sub>[]</sub>. The fetches are (1) the value of i, (2) the value of a and (3) the value of a[i].&nbsp;&nbsp;</p>



<p>Using these rules, we can easily estimate the running time of the algorithms. </p>



<h2 class="wp-block-heading">Examples</h2>



<p>Here, we present some programs in C++ and we estimate their running time. </p>




<div class="codecolorer-container cpp dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #0000dd;">1</span><span style="color: #008080;">:</span> <span style="color: #0000ff;">int</span> max<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> a, <span style="color: #0000ff;">int</span> b<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
<span style="color: #0000dd;">2</span><span style="color: #008080;">:</span> &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> a <span style="color: #000080;">&gt;</span> b <span style="color: #008000;">&#41;</span> <br />
<span style="color: #0000dd;">3</span><span style="color: #008080;">:</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">return</span> a<span style="color: #008080;">;</span><br />
<span style="color: #0000dd;">4</span><span style="color: #008080;">:</span> &nbsp; &nbsp; <span style="color: #0000ff;">return</span> b<span style="color: #008080;">;</span> <br />
<span style="color: #0000dd;">5</span><span style="color: #008080;">:</span> <span style="color: #008000;">&#125;</span></div></div>




<p>The running time of the function &#8220;max&#8221; depends on the lines 2,3 and 4. So, we have to estimate for each line (or step) the corresponding time and then to calculate the total time of the function.</p>



<figure class="wp-block-table"><table class="has-white-color has-black-background-color has-text-color has-background"><tbody><tr><td><strong>Lines</strong></td><td><strong>a &gt; b</strong></td><td><strong>a &lt;= b</strong></td><td><strong>Code</strong></td></tr><tr><td><strong>3</strong></td><td>2t<sub>fetch&nbsp;</sub>+ t<sub>&lt;</sub></td><td>2t<sub>fetch&nbsp;</sub>+ t<sub>&lt;</sub></td><td>If (a &gt; b)</td></tr><tr><td><strong>4</strong></td><td>t<sub>return</sub>&nbsp;+ t<sub>fetch</sub></td><td>&#8211;</td><td>return a;</td></tr><tr><td><strong>5</strong></td><td>&#8211;</td><td>t<sub>return</sub>&nbsp;+ t<sub>fetch</sub></td><td>return b;</td></tr><tr><td><strong>Total Running Time</strong></td><td>3t<sub>fetch</sub>&nbsp;+ t<sub>&lt;</sub>&nbsp;+ t<sub>return</sub></td><td>3t<sub>fetch</sub>&nbsp;+ t<sub>&lt;</sub>&nbsp;+ t<sub>return</sub></td><td>&nbsp;</td></tr></tbody></table></figure>



<p>Making our life better, we define the total time of max function when &#8220;a &gt; b&#8221; as t<sub>1</sub> and the total time of max function when &#8220;a &lt;= b&#8221; as t<sub>2</sub>. We can say that T<sub>max(a,b)</sub>&nbsp;= t<sub>1&nbsp;</sub>&nbsp;ή&nbsp;T<sub>max(a,b)</sub>&nbsp;= t<sub>2</sub>. However, as we can see &nbsp;t<sub>1</sub> = t<sub>2</sub>, so the T<sub>max(a,b)</sub> = 3t<sub>fetch</sub>&nbsp;+ t<sub>&lt;</sub>&nbsp;+ t<sub>return</sub>. if  t<sub>1</sub> &lt;&gt;  t<sub>2</sub>, then the total worst running time of the function would be that t with the worst time.   </p>




<div class="codecolorer-container cpp dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #0000dd;">1</span><span style="color: #008080;">:</span> <span style="color: #0000ff;">int</span> findMaxNumber<span style="color: #008000;">&#40;</span>A<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<span style="color: #0000dd;">2</span><span style="color: #008080;">:</span> &nbsp; &nbsp;<span style="color: #0000ff;">int</span> maxNumber <span style="color: #000080;">=</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
<span style="color: #0000dd;">3</span><span style="color: #008080;">:</span> &nbsp; &nbsp;<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
<span style="color: #0000dd;">4</span><span style="color: #008080;">:</span> &nbsp; &nbsp; &nbsp; maxNumber <span style="color: #000080;">=</span> max<span style="color: #008000;">&#40;</span>maxNumber,A<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000dd;">5</span><span style="color: #008080;">:</span> &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #0000dd;">6</span><span style="color: #008080;">:</span> &nbsp; &nbsp;<span style="color: #0000ff;">return</span> maxNumber<span style="color: #008080;">;</span><br />
<span style="color: #0000dd;">7</span><span style="color: #008080;">:</span> <span style="color: #008000;">&#125;</span></div></div>




<p>The function &#8220;findMaxNumber&#8221; gets as input an array A with n values and returns the maximum number of the array. We also use the previous function &#8220;max&#8221; to find the maximum number of two variables.  The running time of the function depends on the lines 2 to 6. <br></p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Lines</strong></td><td><strong>Running Time</strong></td><td><strong>Code</strong></td></tr><tr><td><strong>2</strong></td><td>t<sub>fetch&nbsp;</sub>+ t<sub>store</sub></td><td>int maxNumber = -1;</td></tr><tr><td><strong>3a</strong></td><td>t<sub>fetch&nbsp;</sub>+ t<sub>store</sub></td><td>int i =0;</td></tr><tr><td><strong>3b</strong></td><td>(2t<sub>fetch</sub>&nbsp;+ t<sub>&lt;</sub>)*(n+1)</td><td>i &lt; n;</td></tr><tr><td><strong>3c</strong></td><td>(2t<sub>fetch&nbsp;</sub>+ t<sub>store</sub>&nbsp;+ t<sub>+</sub>)*n</td><td>i++;</td></tr><tr><td><strong>4</strong></td><td>(3t<sub>store</sub>&nbsp;+ t<sub>call</sub>&nbsp;+ T<sub>max(a,b)</sub>&nbsp;+ 4t<sub>fetch</sub> + t<sub>[]</sub>)*n<sub>&nbsp;&nbsp;&nbsp;</sub></td><td>maxNumber = max(maxNumber,A[i]);</td></tr><tr><td><strong>6</strong></td><td>t<sub>return</sub>&nbsp;+ t<sub>fetch</sub></td><td>return maxNumber;</td></tr></tbody></table></figure>



<p>As we can see in the table, we used the 5 rules defined above to find the running time of the algorithm (<strong>Exercise: </strong>Find the total running time of the algorithm using also the running time of the function &#8220;max&#8221;). There are some interesting parts in this source code: </p>



<ul>
<li>The line 3 is split into three parts. The initialization of the i variable is executed only one time while the statements 3b and 3c are executed at least n times. The 3b statement is executed n + 1 times because we also  take into account when the condition is getting false for the first time.</li>



<li>To find the running time of the 4th statement we needed all 5 rules. Firstly, we have to fetch the A[i] (as we explained above) and the maxNumber. These two parameters need 2t<sub>store</sub> when they are passed to the function. The return value of the function is stored in the maxNumber so we need also a t<sub>store</sub>.   </li>
</ul>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2020/08/23/estimating-running-time-of-an-algorithm-using-simple-rules/">Estimating Running Time of an Algorithm using Simple Rules.</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://dndimitri.eu/2020/08/23/estimating-running-time-of-an-algorithm-using-simple-rules/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">586</post-id>	</item>
		<item>
		<title>Deterministic Finite State Automota for Regular Expressions</title>
		<link>https://dndimitri.eu/2020/02/09/deterministic-finite-state-automota-for-regular-expressions/</link>
					<comments>https://dndimitri.eu/2020/02/09/deterministic-finite-state-automota-for-regular-expressions/#respond</comments>
		
		<dc:creator><![CDATA[Dimitris Dimitriadis]]></dc:creator>
		<pubDate>Sat, 08 Feb 2020 23:06:04 +0000</pubDate>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Language Processing]]></category>
		<guid isPermaLink="false">https://dndimitri.eu/?p=511</guid>

					<description><![CDATA[<p>A finite state automaton (FSA) is a computational model and is defined by the following 5 parameters: Q: a finite...</p>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2020/02/09/deterministic-finite-state-automota-for-regular-expressions/">Deterministic Finite State Automota for Regular Expressions</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A finite state automaton (FSA) is a computational model and is defined by the following 5 parameters:</p>



<ul><li>Q: a finite set of N states \(q_0, q_1,&#8230;,q_N\)</li><li>Σ: a finite input alphabet of symbols </li><li>\(q_0\): the start state </li><li>F: the set of final states, \( F  \subseteq  Q \)</li><li>δ(q,i): the transition function or transition matrix between states. Given \(q \in Q\) and an input symbol \( i \in Σ \), δ(q,i) returns a new state \(q&#8217; \in Q\). δ is thus a relation from \( Q \times Σ \to Q \);</li></ul>



<p>Using this machine, one can recognize a formal language. So, if we define a formal language with a regular expression, an automaton will be in a position to recognize it.</p>



<p> In this post, we will work with two formal languages to show the algorithms that can be used for recognizing the languages by finite state automaton. We will implement the algorithms in python. You can find more information about the use of deterministic finite state automata <a href="https://en.wikipedia.org/wiki/Deterministic_finite_automaton">here</a>. Furthermore, in this post one has to know what we mean &#8220;tape&#8221; and &#8220;transition matrix/table&#8221;.  For regular expressions, please visit <a href="https://en.wikipedia.org/wiki/Regular_expression">here</a>. </p>



<h3 class="wp-block-heading">The Sheep Talks (character-level tapes)</h3>



<p>Our first example is a simple formal language for the sheep language. The sheep language is any string of the form: </p>



<ul><li>baa!</li><li>baaa!</li><li>baaaa!</li><li>&#8230;.</li></ul>



<p>The corresponding regular expression is ^baa+!$. So, we want a finite state automaton to recognize this regular expression.</p>



<p>So, following the parameters defined above,  \(Σ = \lbrace a,b,! \rbrace \) while for the states and transitions we will use a transition matrix. We define these elements in python </p>



<p>

<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #808080; font-style: italic;"># sheep language </span><br />
transition_matrix <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># b, &nbsp; a, &nbsp; ! </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">None</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> &nbsp; <span style="color: #808080; font-style: italic;">#q0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">2</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">None</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> &nbsp; <span style="color: #808080; font-style: italic;">#q1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">None</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> &nbsp; <span style="color: #808080; font-style: italic;">#q2 </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">#q3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#91;</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">None</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;">#q4 &nbsp; &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#93;</span><br />
symbols <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">'b'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'a'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'!'</span><span style="color: black;">&#93;</span></div></div>

</p>



<p>The transition matrix contains the transition between two states given a letter. For example, given the letter &#8216;b&#8217; in the  \(q_0\)  state, we can pass to the state  \(q_1\). In the  \(q_1\) the FSA accepts the letter &#8216;a&#8217; and goes to the state  \(q_2\) and so on. The None values representes the invalid characters for a given state. So, if in state  \(q_0\)  the letter &#8216;a&#8217; will be given, then the given string (or tape) is invalid.   Next we define a function that will be necessary later: </p>



<p>

<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #ff7700;font-weight:bold;">def</span> convert_char_to_collumn<span style="color: black;">&#40;</span><span style="color: #dc143c;">symbol</span><span style="color: #66cc66;">,</span>symbols<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>symbols<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">symbol</span> <span style="color: #66cc66;">==</span> symbols<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> i</div></div>

</p>



<p>This function get as input the current symbol of a string (or tape) and the list of all available symbols. The aim of the function is to convert the letters to numeric values that corresponds to the collumns of the transition matrix. For example, if the given string is &#8220;baba!&#8221; the corresponding output will be &#8220;01012&#8221;. Next we define the algorithm that recognizes a given tape. </p>



<p>

<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #ff7700;font-weight:bold;">def</span> d_recognize<span style="color: black;">&#40;</span>tape<span style="color: #66cc66;">,</span>transition_matrix<span style="color: #66cc66;">,</span>symbols<span style="color: #66cc66;">,</span>accepted_states<span style="color: black;">&#41;</span>:<br />
&nbsp; index <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span> <br />
&nbsp; current_state <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> index <span style="color: #66cc66;">&gt;=</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>tape<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> current_state <span style="color: #ff7700;font-weight:bold;">in</span> accepted_states:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'accepted'</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'rejected'</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #ff7700;font-weight:bold;">not</span> transition_matrix<span style="color: black;">&#91;</span>current_state<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>convert_char_to_collumn<span style="color: black;">&#40;</span>tape<span style="color: black;">&#91;</span>index<span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>symbols<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'rejected'</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: <br />
&nbsp; &nbsp; &nbsp; current_state <span style="color: #66cc66;">=</span> transition_matrix<span style="color: black;">&#91;</span>current_state<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>convert_char_to_collumn<span style="color: black;">&#40;</span>tape<span style="color: black;">&#91;</span>index<span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>symbols<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; index +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span></div></div>

</p>



<p>This function get as input the tape, the transition matrix the symbols and the accepted states (F set as defined above). The aim of the function is to pass through all letters and to decide if the given tape is valid. Particulalry, it uses the below conditions:</p>



<ul><li>if we are at the end of the tape, then if the state is final, then the given tape is accepted, otherwise is not. </li><li>if we are not at the end of the tape, we check if the current letter in the current state can be considered as valid (i.e. not None). If the letter is not valid then the tape is rejected. Otherwise, we go to the next state based on the transition matrix and we update the index that points to the next letter in the tape.</li></ul>



<p>To test our algorithm, we define some tapes and we call the above function</p>



<p>

<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">tapes <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">'baaa!'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'baba'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'baaa'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'baaaaaaa!'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'ba!'</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> tape <span style="color: #ff7700;font-weight:bold;">in</span> tapes:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span>tape +<span style="color: #483d8b;">':<span style="color: #000099; font-weight: bold;">\t</span>'</span> + d_recognize<span style="color: black;">&#40;</span>tape<span style="color: #66cc66;">,</span>transition_matrix<span style="color: #66cc66;">,</span>symbols<span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></div>

</p>



<h3 class="wp-block-heading">A more complex example &#8211; dollars and cents (word-level tapes)</h3>



<p>Now, suppose that we want to recognize money with our FSA. For example</p>



<ul><li>twenty five dollars</li><li>five dollars thirty cents</li><li>five cents</li><li>&#8230;&#8230;</li></ul>



<p>We will work as previously but here the transition matrix is bigger due to the set of symbols. </p>



<p>

<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">symbols <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">'twenty'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'thirty'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'forty'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'fifty'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'sixty'</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'seventy'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'eigthy'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'ninety'</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'one'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'two'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'three'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'four'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'five'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'six'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'seven'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'eight'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'nine'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'ten'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'eleven'</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'twelve'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'thirteen'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'fourteen'</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'fifteen'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'sixteen'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'seventeen'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'eighteen'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'ninenteen'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'cents'</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'dollars'</span><span style="color: black;">&#93;</span><br />
<br />
transition_matrix <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
length <span style="color: #66cc66;">=</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>symbols<span style="color: black;">&#41;</span><br />
q0 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span> <br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">8</span>:<br />
&nbsp; &nbsp; q0.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">&gt;=</span> <span style="color: #ff4500;">8</span> <span style="color: #ff7700;font-weight:bold;">and</span> i <span style="color: #66cc66;">&lt;</span> length - <span style="color: #ff4500;">2</span>:<br />
&nbsp; &nbsp; q0.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; q0.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q0<span style="color: black;">&#41;</span><br />
q1 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">8</span>:<br />
&nbsp; &nbsp; q1.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">&gt;=</span> <span style="color: #ff4500;">8</span> <span style="color: #ff7700;font-weight:bold;">and</span> i <span style="color: #66cc66;">&lt;</span>length - <span style="color: #ff4500;">2</span>: <br />
&nbsp; &nbsp; q1.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">==</span> length-<span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; q1.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; q1.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span><br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q1<span style="color: black;">&#41;</span><br />
q2 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> length - <span style="color: #ff4500;">2</span>:<br />
&nbsp; &nbsp; q2.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">==</span> length - <span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; q2.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; q2.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span><br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q2<span style="color: black;">&#41;</span><br />
q3 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #008000;">None</span><span style="color: black;">&#93;</span> * length &nbsp;<br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q3<span style="color: black;">&#41;</span><br />
q4 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> length -<span style="color: #ff4500;">2</span>:<br />
&nbsp; &nbsp; q4.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; q4.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q4<span style="color: black;">&#41;</span><br />
q5 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">8</span>:<br />
&nbsp; &nbsp; q5.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">&gt;=</span> <span style="color: #ff4500;">8</span> <span style="color: #ff7700;font-weight:bold;">and</span> i <span style="color: #66cc66;">&lt;</span>length - <span style="color: #ff4500;">2</span>: <br />
&nbsp; &nbsp; q5.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">==</span> length-<span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; q5.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; q5.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span><br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q5<span style="color: black;">&#41;</span><br />
q6 <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> length - <span style="color: #ff4500;">2</span>:<br />
&nbsp; &nbsp; q6.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> i <span style="color: #66cc66;">==</span> length - <span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; q6.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; q6.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span><br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q6<span style="color: black;">&#41;</span><br />
q7 <span style="color: #66cc66;">=</span><span style="color: black;">&#91;</span><span style="color: #008000;">None</span><span style="color: black;">&#93;</span> * length <br />
transition_matrix.<span style="color: black;">append</span><span style="color: black;">&#40;</span>q7<span style="color: black;">&#41;</span></div></div>

</p>



<p>Here the symbols are all the words that corresponds to the numeric values (we ignore cases with hundreads and thousands for simplicity). The transition matrix consists of 7 states, while the states that are full of Nones mean that they are final states. </p>



<p>Defining the bellow strings, we will see the expected results</p>



<p>

<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">string_1 <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;five dollars cents&quot;</span><br />
string_2 <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;twenty two cents&quot;</span><br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span>d_recognize<span style="color: black;">&#40;</span>string_1.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>transition_matrix<span style="color: #66cc66;">,</span>symbols<span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">4</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span>d_recognize<span style="color: black;">&#40;</span>string_2.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>transition_matrix<span style="color: #66cc66;">,</span>symbols<span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">4</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></div>

</p>



<h3 class="wp-block-heading">Bibliography</h3>



<ul><li> Jurafsky, D. (2000). <em>Speech &amp; language processing</em>. Pearson Education India. </li></ul>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2020/02/09/deterministic-finite-state-automota-for-regular-expressions/">Deterministic Finite State Automota for Regular Expressions</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://dndimitri.eu/2020/02/09/deterministic-finite-state-automota-for-regular-expressions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">511</post-id>	</item>
		<item>
		<title>Google Apps for Education (Aristotle University of Thessaloniki)</title>
		<link>https://dndimitri.eu/2020/01/28/google-apps-for-education-aristotle-university-of-thessaloniki/</link>
					<comments>https://dndimitri.eu/2020/01/28/google-apps-for-education-aristotle-university-of-thessaloniki/#respond</comments>
		
		<dc:creator><![CDATA[Dimitris Dimitriadis]]></dc:creator>
		<pubDate>Tue, 28 Jan 2020 09:31:26 +0000</pubDate>
				<category><![CDATA[Education]]></category>
		<guid isPermaLink="false">https://dndimitri.eu/?p=506</guid>

					<description><![CDATA[<p>Google supports students and researchers (academic staff, in general) offering some of their services for free. In Aristotle University of...</p>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2020/01/28/google-apps-for-education-aristotle-university-of-thessaloniki/">Google Apps for Education (Aristotle University of Thessaloniki)</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Google supports students and researchers (academic staff, in general) offering some of their services for free. In Aristotle University of Thessaloniki, the services are summarized below:</p>



<ol><li>Gmail: The email of the university members have the prefix &#8220;auth.gr&#8221; </li><li>Google Drive: Unlimited free space </li><li>Google Calendar </li><li>Google Docs, Sheets, Slides and Forms </li><li>Google Classroom </li><li>Google Sites </li><li>Google Hangouts</li><li>Blogger, Google Groups and Google+ </li></ol>



<p>To learn more about the services, visit the <a rel="noreferrer noopener" target="_blank" href="https://it.auth.gr/el/cloudServices/gapps">https://it.auth.gr/el/cloudServices/gapps</a>.  To enable the service, visit <a rel="noreferrer noopener" target="_blank" href="https://accounts.auth.gr/misc/googleApps.php">https://accounts.auth.gr/misc/googleApps.php</a>. <br><br>To use the service, one has to wait 8 hours for the activation. Later, he has to be signed in to google services using the email username@gapps.auth.gr</p>



<p>For any questions, feel free to contact with me.  </p>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2020/01/28/google-apps-for-education-aristotle-university-of-thessaloniki/">Google Apps for Education (Aristotle University of Thessaloniki)</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://dndimitri.eu/2020/01/28/google-apps-for-education-aristotle-university-of-thessaloniki/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">506</post-id>	</item>
		<item>
		<title>Datasets In Question Answering</title>
		<link>https://dndimitri.eu/2019/11/02/datasets-in-question-answering/</link>
					<comments>https://dndimitri.eu/2019/11/02/datasets-in-question-answering/#respond</comments>
		
		<dc:creator><![CDATA[Dimitris Dimitriadis]]></dc:creator>
		<pubDate>Sat, 02 Nov 2019 10:44:46 +0000</pubDate>
				<category><![CDATA[Question Answering]]></category>
		<category><![CDATA[Research]]></category>
		<guid isPermaLink="false">https://dndimitri.eu/?p=473</guid>

					<description><![CDATA[<p>Question Answering (QA) is an AI-complete problem meaning that the current state-of-the-art approaches can not solve it. One of the...</p>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2019/11/02/datasets-in-question-answering/">Datasets In Question Answering</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Question Answering (QA) is an AI-complete problem meaning that the current state-of-the-art approaches can not solve it. One of the main problems of the domain some years before was the lack of a huge dataset. Although other Natural Language Processing tasks (e.g., named-entity recognition, language modeling) have plenty of resources, QA only recently has an appropriate amount of instances. Furthermore, due to the difficulty of the domain, researchers direct the research towards specific cases in QA. For example, the current big datasets, which are publicly available, are related to the extractive QA, a specific problem where the assumption is that the answer to a question is part of a passage related to the question. The models aim to predict the span text in the passage text that answers the question. Other datasets contain triples of questions, passages, and answers where the answers have been generated considering the passages texts and the world knowledge. This is a natural language generation problem. The models aim to produce an answer text for a question that is approximately close to the gold answer.</p>



<p>As we can see, there are plenty of special cases in QA, thus, it would be beneficial to find the datasets that can help us to train efficient models on a particular QA task. </p>



<p><strong>The aim of this article is to present these datasets giving a description for each of them and also links to download them and experimented with them. </strong> </p>



<h3 class="wp-block-heading">Natural Questions</h3>



<p>This dataset has been constructed in 2019 by the Google Research team for extractive QA. The dataset contains thousands of queries that have been made by users in the Google search engine. Particularly, the dataset is split into the train, dev, and test set, with approximately 310,000, 8000, and 8000 instances accordingly. An instance is a question (user query), a Wikipedia page from the top 5 search results, a long answer which has the length of a paragraph, and a short answer which is one or more entities or yes/no [1]. The Wikipedia page is in the HTML format while the dataset is in the JSON Lines text format. (In Python, one can use the <a target="_blank" href="https://jsonlines.readthedocs.io/en/latest/" rel="noreferrer noopener">jsonlines</a> library to process the dataset). The dataset is available <a target="_blank" href="https://ai.google.com/research/NaturalQuestions" rel="noreferrer noopener">here</a>.</p>



<h3 class="wp-block-heading">Squad V1.0</h3>



<p>This is another dataset for extractive QA constructed by Stanford Research Team. Crowdworkers posed questions on a set of Wikipedia articles, while the answer to the questions is a span of text included in a passage contained in the Wikipedia articles. The number of questions is 100k approximately [2]. The human performance on the dataset is 86.8%. The dataset is available <a target="_blank" href="https://rajpurkar.github.io/SQuAD-explorer/" rel="noreferrer noopener">here</a>.</p>



<h3 class="wp-block-heading">Squad V2.0</h3>



<p>The previous version of the dataset contained easy questions. Thus the state-of-the-art models achieved better results even from humans. In detail, the main issue of the past state-of-the-art models was that they tried to guess the answer in the context of a passage, while the answer was not stated in this context. Stanford observed that and introduced the second version of the dataset [3]. The dataset contains the questions from version 1 plus the 50k unanswerable questions. Now, the models must answer the questions only if it is possible. Based on the leaderboard, the best accuracy is 89% overcoming human judgment. The dataset is available <a target="_blank" href="https://rajpurkar.github.io/SQuAD-explorer/" rel="noreferrer noopener">here</a>.</p>



<h3 class="wp-block-heading">BoolQ</h3>



<p>This dataset contains yes/no questions. Particularly, the creators of the dataset gathered questions from other datasets such as Natural Questions or constructed triples of questions, passages, and answers using other sources to build a dataset only with yes/no questions. They claim that to answer the questions, one must infer the answer from the passages while reasoning is mandatory. They introduced six types of reasoning. Their best model was one that trained on Natural Language Inference dataset and fine-tuned on the boolq dataset [4]. The dataset is available <a target="_blank" href="https://github.com/google-research-datasets/boolean-questions" rel="noreferrer noopener">here</a>.</p>



<h3 class="wp-block-heading">BioASQ</h3>



<p>A biomedical domain QA dataset which was constructed by biomedical experts for the BioASQ Challenge dated back to 2013. The dataset contains questions of several types (yes/no, factoid, list, summary), while the systems should answer a question giving a short answer (exact answer) and a paragraph-like answer (ideal answer) [5]. The dataset is available <a target="_blank" href="http://participants-area.bioasq.org/" rel="noreferrer noopener">here</a>. Note that if one wants to use the dataset, he must also register in the platform.</p>



<h3 class="wp-block-heading">Bibliography</h3>



<p>[1]  Kwiatkowski, T., Palomaki, J., Redfield, O., Collins, M., Parikh, A., Alberti, C., &#8230; &amp; Toutanova, K. (2019). Natural questions: a benchmark for question answering research.&nbsp;<em>Transactions of the Association for Computational Linguistics</em>,&nbsp;<em>7</em>, 453-466.</p>



<p>[2]  Rajpurkar, P., Zhang, J., Lopyrev, K., &amp; Liang, P. (2016). Squad: 100,000+ questions for machine comprehension of text.&nbsp;<em>arXiv preprint arXiv:1606.05250</em>. </p>



<p>[3] Rajpurkar, P., Jia, R., &amp; Liang, P. (2018). Know What You Don&#8217;t Know: Unanswerable Questions for SQuAD.&nbsp;<em>arXiv preprint arXiv:1806.03822</em>. </p>



<p>[4] Clark, C., Lee, K., Chang, M. W., Kwiatkowski, T., Collins, M., &amp; Toutanova, K. (2019). BoolQ: Exploring the Surprising Difficulty of Natural Yes/No Questions.&nbsp;<em>arXiv preprint arXiv:1905.10044</em>. </p>



<p>[5] An overview of the BIOASQ large-scale biomedical semantic indexing and question answering competition: George Tsatsaronis, Georgios Balikas, Prodromos Malakasiotis, Ioannis Partalas, Matthias Zschunke, Michael R Alvers, Dirk Weissenborn, Anastasia Krithara, Sergios Petridis, Dimitris Polychronopoulos, Yannis Almirantis, John Pavlopoulos, Nicolas Baskiotis, Patrick Gallinari, Thierry Artiéres, Axel Ngonga, Norman Heino, Eric Gaussier, Liliana Barrio-Alvers, Michael Schroeder, Ion Androutsopoulos and Georgios Paliouras,&nbsp;<em>in BMC bioinformatics</em>, 2015 </p>
<p>The post <a rel="nofollow" href="https://dndimitri.eu/2019/11/02/datasets-in-question-answering/">Datasets In Question Answering</a> appeared first on <a rel="nofollow" href="https://dndimitri.eu">Dimitris Dimitriadis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://dndimitri.eu/2019/11/02/datasets-in-question-answering/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">473</post-id>	</item>
	</channel>
</rss>
