<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://fabienpoulard.info/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Blog d'un jeune (chercheur) entrepreneur en TAL - Sciences &amp; Recherche</title>
  <link>http://fabienpoulard.info/</link>
  <atom:link href="http://www.fabienpoulard.info/feed/category/Recherche/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>fr</language>
  <pubDate>Thu, 23 May 2013 19:36:21 +0200</pubDate>
  <copyright>© Fabien Poulard</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Web2Day 2013 : données et analyse prédictive</title>
    <link>http://fabienpoulard.info/post/2013/05/05/Web2Day-2013-%3A-donn%C3%A9es-et-analyse-pr%C3%A9dictive</link>
    <guid isPermaLink="false">urn:md5:892002089bfe17fbcafef71034bb32c9</guid>
    <pubDate>Sun, 05 May 2013 13:13:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>data science</category><category>dictanova</category><category>données</category><category>nantes</category><category>web2day</category>    
    <description>&lt;p&gt;Les 16 et 17 mai prochains se déroulera la 5ème édition du &lt;a href=&quot;http://www.web2day-nantes.org/&quot;&gt;web2day&lt;/a&gt;, le festival du numérique dédié à lʼinnovation et au Web. L'évènement est organisé par &lt;a href=&quot;http://www.atlantic2.org/&quot;&gt;lʼassociation Atlantic 2.0&lt;/a&gt;, le réseau des acteurs du Web et de lʼinnovation numérique en Pays de la Loire, et prendra place à &lt;a href=&quot;http://www.stereolux.org/&quot;&gt;Stereolux&lt;/a&gt;, &lt;a href=&quot;http://www.openstreetmap.org/?mlat=47.205195&amp;amp;mlon=-1.563427&amp;amp;zoom=16&amp;amp;layers=M&quot;&gt;sur lʼîle de Nantes&lt;/a&gt;, pour la deuxième année consécutive.&lt;/p&gt;


&lt;p&gt;Lors de cette édition j'aurai l'immense plaisir d'animer la partie du &lt;a href=&quot;http://www.web2day-nantes.org/topics/stakes-of-datas.html&quot;&gt;thème sur l'enjeux des données&lt;/a&gt; dédiée à l'analyse prédictive, ou «Comment peut-on utiliser les données du moment pour prédire les données à venir ?». L'autre partie du thème sur &lt;a href=&quot;http://www.web2day-nantes.org/events/data-economic-opportunities.html&quot;&gt;l'opportunité économique des données&lt;/a&gt; est gérée par Claire de &lt;a href=&quot;http://libertic.wordpress.com/&quot;&gt;Libertic&lt;/a&gt;, ultime experte de &lt;a href=&quot;http://libertic.wordpress.com/2011/12/12/le-film-de-lopen-data/&quot;&gt;l'open data&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;Personnellement, je suis convaincu que les données sont le pétrole de demain. Nous travaillons d'ailleurs, à &lt;a href=&quot;http://www.dictanova.com/&quot;&gt;Dictanova&lt;/a&gt;, sur des systèmes d'extractions et des raffineries dédiées à ces nouveaux composés numériques. Leur exploitation en masse offre des perspectives de nouveaux usages dont nous n'entrevoyons qu'une infime partie. Encore faut-il être en mesure d'aller puiser ces données au sein des entreprises ou sur le Web, de les nettoyer, les structurer, les consolider et enfin les exploiter.&lt;/p&gt;


&lt;p&gt;L'une des facettes les plus impressionnantes de l'exploitation massive des données est celle des modèles prédictifs. Ces systèmes sont en plein boom ! Sur &lt;a href=&quot;http://www.amazon.fr/&quot;&gt;Amazon&lt;/a&gt; ils vous invitent à consulter des articles qui peuvent vous intéresser. Sur &lt;a href=&quot;http://www.last.fm/&quot;&gt;Last.fm&lt;/a&gt; et &lt;a href=&quot;http://netflix.com/&quot;&gt;Netflix&lt;/a&gt; ils vous recommandent les prochaines œuvres musicales ou cinématographiques à consulter. Sur vos téléphones portables ils anticipent le contenu du message que vous êtes en train de rédiger. Pour l'opération &lt;a href=&quot;http://misstweet.tv/&quot;&gt;Miss Tweet&lt;/a&gt; (&lt;a href=&quot;http://www.slideshare.net/dictanova_officiel/miss-tweet-analyse-tempsrel-du-livetweet-de-miss-france-2013&quot;&gt;détail de l'analyse&lt;/a&gt;), nous les avons mis en œuvre pour prédire l'issue de l'élection de Miss France... et demain ?&lt;/p&gt;


&lt;p&gt;Et bien justement, nous en parlerons vendredi 17 Mai 2013 lors de la 5e édition du Web2Day, avec au menu :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.web2day-nantes.org/events/the-stakes-of-predictive-analysis.html&quot;&gt;Enjeux de l'analyse prédictive&lt;/a&gt; par &lt;a href=&quot;http://www.web2day-nantes.org/speakers/colin-delahiguera.html&quot;&gt;Colin de la Higuera&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.web2day-nantes.org/events/predictive-analysis-and-e-business.html&quot;&gt;Analyse prédictive &amp;amp; e-business&lt;/a&gt; par &lt;a href=&quot;http://www.web2day-nantes.org/speakers/vladimir-mosewicz.html&quot;&gt;Vladimir MOSEWICZ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.web2day-nantes.org/events/predictive-analysis-dictanova.html&quot;&gt;Comment a-t-on prédit l’élection de Miss France ?&lt;/a&gt; par &lt;a href=&quot;http://www.web2day-nantes.org/speakers/fabien-poulard.html&quot;&gt;votre serviteur&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;J'espère que vous viendrez nombreux pour échanger avec nous !&lt;/p&gt;</description>
    
    
    
          <comments>http://fabienpoulard.info/post/2013/05/05/Web2Day-2013-%3A-donn%C3%A9es-et-analyse-pr%C3%A9dictive#comment-form</comments>
      <wfw:comment>http://fabienpoulard.info/post/2013/05/05/Web2Day-2013-%3A-donn%C3%A9es-et-analyse-pr%C3%A9dictive#comment-form</wfw:comment>
      <wfw:commentRss>http://fabienpoulard.info/feed/atom/comments/136</wfw:commentRss>
      </item>
    
  <item>
    <title>Travaux Pratique TALN - Contexte syntaxique</title>
    <link>http://fabienpoulard.info/post/2011/11/21/Travaux-Pratique-TALN-Contexte-syntaxique</link>
    <guid isPermaLink="false">urn:md5:2d2b79c3877c8870ffdccd084274c72c</guid>
    <pubDate>Mon, 21 Nov 2011 23:42:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>corpus</category><category>enseignement</category><category>nltk</category><category>POS tagging</category><category>python</category><category>syntax</category>    
    <description>&lt;p&gt;Les séances précédentes ont été consacrées à l'analyse lexicale et morphologique. Il est temps de se détacher de la dimension lexicale des textes pour tendre vers la dimension syntaxique.&lt;/p&gt;    &lt;h2&gt;Les rôles grammaticaux&lt;/h2&gt;


&lt;p&gt;Tous les mots n'ont pas la même fonction dans la phrase, chaque mot a un rôle grammatical propre qui indique la façon dont il participe à la construction du sens. Ainsi les déterminants (&lt;em&gt;le&lt;/em&gt;, &lt;em&gt;la&lt;/em&gt;, &lt;em&gt;les&lt;/em&gt;, ...) ne jouent pas un rôle aussi crucial que les noms communs (&amp;quot;champion&amp;quot;, &amp;quot;médaille&amp;quot;, &amp;quot;concours&amp;quot;, ...). Ils font parti de l'outillage grammatical qui permet de faire &lt;em&gt;collaborer&lt;/em&gt; les mots afin de produire du sens.&lt;/p&gt;


&lt;p&gt;Dans le cadre de cette séance de TP, je propose de travailler sur les catégories grammaticales suivantes :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;l'article, le déterminant : &lt;em&gt;le&lt;/em&gt;, &lt;em&gt;la&lt;/em&gt;, &lt;em&gt;les&lt;/em&gt;, &lt;em&gt;l&lt;/em&gt;', &lt;em&gt;un&lt;/em&gt;, &lt;em&gt;une&lt;/em&gt;, &lt;em&gt;des&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;le nom : &lt;em&gt;médaille&lt;/em&gt;, &lt;em&gt;champion&lt;/em&gt;, &lt;em&gt;podium&lt;/em&gt;, &lt;em&gt;éléphant&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;l'adjectif : &lt;em&gt;grande&lt;/em&gt;, &lt;em&gt;téméraire&lt;/em&gt;, &lt;em&gt;puissant&lt;/em&gt;, &lt;em&gt;ordonnée&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;le pronom : &lt;em&gt;je&lt;/em&gt;, &lt;em&gt;me&lt;/em&gt;, &lt;em&gt;moi&lt;/em&gt;, &lt;em&gt;se&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;le verbe : &lt;em&gt;manger&lt;/em&gt;, &lt;em&gt;courir&lt;/em&gt;, &lt;em&gt;être&lt;/em&gt;, &lt;em&gt;penser&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;l'adverbe : &lt;em&gt;lentement&lt;/em&gt;, &lt;em&gt;doucement&lt;/em&gt;, &lt;em&gt;rapidement&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;la préposition : &lt;em&gt;à&lt;/em&gt;, &lt;em&gt;en&lt;/em&gt;, &lt;em&gt;sur&lt;/em&gt;, &lt;em&gt;sous&lt;/em&gt;, &lt;em&gt;sans&lt;/em&gt;, &lt;em&gt;avec&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;la conjonction : &lt;em&gt;mais&lt;/em&gt;, &lt;em&gt;ou&lt;/em&gt;, &lt;em&gt;et&lt;/em&gt;, &lt;em&gt;donc&lt;/em&gt;, ...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Les mots de chacune de ces catégories ont une fonction propre dans la phrase : qualifier le nom, faire référence à une personne ou un objet, décrire l'action ou l'état, coordonner des propositions... Si vous voulez en savoir plus, vous pouvez aller &lt;a href=&quot;http://www.scribd.com/doc/2260156/analyse-grammaticale&quot; hreflang=&quot;fr&quot;&gt;lire ceci&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Il est possible de lister de manière exhaustive (ou suffisamment exhaustive) les mots de certaines catégories grammaticales : les déterminants, les pronoms, les conjonctions et dans une certaine mesure les prépositions. Toutefois, il est très difficile de lister les noms, les verbes, les adjectifs ou encore les adverbes ; et ce pour deux raisons : les mots pouvant prendre ces rôles sont très nombreux et il est possible d'en générer une quasi-infinité de nouveaux, par composition notamment.&lt;/p&gt;


&lt;h2&gt;Lister les mots des catégories déterminant, pronom, conjonction et préposition&lt;/h2&gt;


&lt;p&gt;Même si l'ont peut donner une liste quasi-exhaustive des mots qui appartiennent aux catégories grammaticales déterminant, pronom, conjonction et préposition ; il peut être difficile de réaliser ces listes de tête.&lt;/p&gt;


&lt;p&gt;Encore une fois, le corpus peut-être d'un grand secours. En effet, du fait de la combinaison de leur nombre réduit (par comparaison aux noms et verbes par exemple) et de leur rôle primordial dans la phrase, ces mots sont sont parmi les mots les plus fréquents. Un simple comptage d'occurrence permet donc d'en découvrir un certain nombre :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Chargement du corpus prétraité (découpé en mots)&lt;/span&gt;
fh = &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;.&lt;span style=&quot;color: #008000;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Discours-Sarkozy-v20111025.preproc.txt&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;r&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
words   = fh.&lt;span style=&quot;color: black;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
fh.&lt;span style=&quot;color: black;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Comptage des mots&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; nltk &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; FreqDist
fd = FreqDist&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; w &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; words:
	fd.&lt;span style=&quot;color: black;&quot;&gt;inc&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;w.&lt;span style=&quot;color: black;&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Affichage du Top 50 avec leur nombre d'occurrence&lt;/span&gt;
fd.&lt;span style=&quot;color: black;&quot;&gt;items&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;:&lt;span style=&quot;color: #ff4500;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
 
&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;','&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;111161&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'de'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;83656&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'.'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;76146&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'la'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;57608&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, 
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;l'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;41454&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'et'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;38519&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'le'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;37246&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'les'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;35018&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'que'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;33457&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e0'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;31767&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'est'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;29416&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'des'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;27233&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;d'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;26458&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'je'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;21483&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'qui'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;21432&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'en'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;21317&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'pas'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;20128&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'un'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;19782&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'pour'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;18374&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'il'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;17286&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'une'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;16512&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'nous'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;16031&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;c'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;15082&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'a'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;14891&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'dans'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;13862&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'on'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;13849&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'vous'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;13799&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'du'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;13605&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'ne'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;13502&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'ce'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;13231&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;qu'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;12629&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;n'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;12400&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'au'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;9723&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'plus'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;9494&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'y'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;7980&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'sur'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;7845&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, 
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'france'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;7687&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'mais'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;7638&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'avec'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;6869&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;':'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;6556&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;j'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;6408&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'se'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5870&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;s'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5809&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'sont'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5791&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, 
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'par'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5724&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'cela'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5536&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'cette'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5430&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'ont'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5230&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,
&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'aux'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5145&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'si'&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;5009&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cette approche combinée à notre connaissance de la grammaire française nous permet de constituer assez rapidement la liste des mots de chacune des catégories déterminant, pronom, conjonction et préposition.&lt;/p&gt;


&lt;p&gt;Cette approche n'est toutefois pas satisfaisant pour les &amp;quot;puristes&amp;quot;, notamment car le corpus est loin d'être représentatif de la langue mais également car nous nous limitons ici aux mots et négligeons les locutions.&lt;/p&gt;


&lt;p&gt;Voici néanmoins une proposition de liste construite de cette manière :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Proposition de liste non exhaustive de mots pour les rôles grammaticaux&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# déterminants, pronoms, conjonctions et prépositions&lt;/span&gt;
dico = &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# ARTICLES / DETERMINANTS&lt;/span&gt;
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;DET&amp;quot;&lt;/span&gt;: &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;le&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;la&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;les&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;l'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;un&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;une&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;des&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;d'&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;du&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;de&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;au&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aux&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ce&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;cet&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;cette&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ces&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;mon&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;son&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ma&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ta&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sa&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;mes&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ses&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;notre&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;votre&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;leur&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;nos&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;vos&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;leurs&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aucun&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aucune&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aucuns&amp;quot;&lt;/span&gt;, 
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;tel&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;telle&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;tels&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;telles&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;tout&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;toute&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;tous&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;toutes&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;chaque&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;,
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# PRONOM&lt;/span&gt;
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;PRO&amp;quot;&lt;/span&gt;: &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;je&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;tu&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;il&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;elle&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;on&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;nous&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;vous&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ils&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;elles&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;me&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;m'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;moi&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;te&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;t'&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;toi&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;se&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;y&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;le&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;lui&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;soi&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;leur&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;eux&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;lui&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;qui&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;que&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;quoi&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;dont&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;où&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;,
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# CONJONCTION&lt;/span&gt;
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;CONJ&amp;quot;&lt;/span&gt;: &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;mais&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ou&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;et&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;donc&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;or&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ni&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;car&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;que&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;quand&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;comme&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;si&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;lorsque&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;quoique&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;puisque&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;,
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# PREPOSITION&lt;/span&gt;
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;PREP&amp;quot;&lt;/span&gt;: &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;à&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;derrière&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;malgré&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sauf&amp;quot;&lt;/span&gt;,
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;selon&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;avant&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;devant&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sous&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;avec&amp;quot;&lt;/span&gt;, 
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;en&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;par&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sur&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;entre&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;parmi&amp;quot;&lt;/span&gt;, 
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;envers&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;pendant&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;vers&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;dans&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;pour&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;de&amp;quot;&lt;/span&gt;, 
		&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;près&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;depuis&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sans&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;


&lt;h2&gt;Le contexte syntaxique en renfort&lt;/h2&gt;


&lt;p&gt;Les différents mots extraits précédemment vont nous être utiles pour capturer les mots des autres catégories.&lt;/p&gt;


&lt;p&gt;Nous allons fouiller le contexte des mots listés précédemment afin d'identifier des règles qui nous permettraient de trouver automatiquement les catégories grammaticales des autres mots. Pour ce faire nous allons utiliser un outil bien connu des linguistes : le &lt;a href=&quot;http://fr.wikipedia.org/wiki/Concordancier&quot; hreflang=&quot;fr&quot;&gt;concordancier&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Nltk fournit un concordancier qui est certes un peu limité mais bien suffisant pour notre étude :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;t = nltk.&lt;span style=&quot;color: black;&quot;&gt;Text&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;words, name=&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;discours_sarkozy&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
t.&lt;span style=&quot;color: black;&quot;&gt;concordance&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;je&amp;quot;&lt;/span&gt;, width=&lt;span style=&quot;color: #ff4500;&quot;&gt;50&lt;/span&gt;, lines=&lt;span style=&quot;color: #ff4500;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;ce qui nous donne le résultat :&lt;/p&gt;

&lt;pre&gt;
Displaying 10 of 21483 matches:
re avec vous ce matin . Je sais qu' il y a plus de
onsulat dans le monde . Je salue tous ces Français
 , c' est sympathique ! Je suis donc venu vous voi
France-Syrie du Sénat . Je suis également venu ave
la Syrie et la France . Je n' oublie pas Bernard B
des parents d' élèves . Je voudrais vous féliciter
État sera à vos côtés . Je trouve cela formidable 
aissera pas tomber . Et je trouve que c' est merve
nt engagés à ce point . Je veux saluer également l
nsi que les autorités . Je salue ici la présence 
&lt;/pre&gt;


&lt;p&gt;L'utilisation du concordancier nous permet de lister un certain nombre de règles qui semblent généralisables :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le &amp;quot;or&amp;quot; en début de phrase est une conjonction alors que le &amp;quot;or&amp;quot; précédé d'un déterminant est un nom ;&lt;/li&gt;
&lt;li&gt;les déterminants semblent précéder des noms ;&lt;/li&gt;
&lt;li&gt;les pronoms sont en général suivis d'un verbe ou d'un autre pronom&lt;/li&gt;
&lt;li&gt;les adjectifs sont en général précédés d'un verbe ou d'un nom&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Outre ces quelques règles auxquelles il est très certainement possible de trouver des contre-exemples, on peut surtout noter que les mots ne s'acoquinent pas avec n'importe qui. Chaque mot a des accointances privilégiées avec certaines catégories grammaticales (le déterminant avec le nom par exemple, ...). En d'autres termes, il semble exister une structure syntaxique propre à la langue... sa compréhension nous permettrait de faire un pas de plus dans la compréhension du langage par la machine.&lt;/p&gt;


&lt;h2&gt;Algorithme de Brill&lt;/h2&gt;


&lt;h3&gt;Intuition&lt;/h3&gt;


&lt;p&gt;Prenons une phrase du corpus :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'Je'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'sais'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;qu'&amp;quot;&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'il'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'y'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'a'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'plus'&lt;/span&gt;,
 u&lt;span style=&quot;color: #483d8b;&quot;&gt;'de'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'3 000'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'Fran&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e7ais'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'en'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'Syrie'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;','&lt;/span&gt;, 
 u&lt;span style=&quot;color: #483d8b;&quot;&gt;'&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e0'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'Damas'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;','&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e0'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'Alep'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;','&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'o&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;f9'&lt;/span&gt;, 
 u&lt;span style=&quot;color: #483d8b;&quot;&gt;'nous'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'avons'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'notre'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'plus'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'ancien'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'consulat'&lt;/span&gt;, 
 u&lt;span style=&quot;color: #483d8b;&quot;&gt;'dans'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'le'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'monde'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'.'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Un certain nombre des mots qui composent cette phrase sont connus car ils appartiennent aux catégories grammaticales déterminant, pronom, préposition ou conjonction. C'est le cas notamment de &lt;em&gt;Je&lt;/em&gt;, &lt;em&gt;qu&lt;/em&gt;', &lt;em&gt;il&lt;/em&gt;, &lt;em&gt;y&lt;/em&gt;, &lt;em&gt;de&lt;/em&gt;, &lt;em&gt;en&lt;/em&gt;, &lt;em&gt;à&lt;/em&gt;, &lt;em&gt;à&lt;/em&gt;, &lt;em&gt;où&lt;/em&gt;, &lt;em&gt;nous&lt;/em&gt;, &lt;em&gt;notre&lt;/em&gt;, &lt;em&gt;dans&lt;/em&gt; et &lt;em&gt;le&lt;/em&gt;. L'idée est donc d'affecter à ces mots leur étiquette la plus probable et aux autres l'étiquette &lt;em&gt;?&lt;/em&gt;, soit :&lt;/p&gt;

&lt;pre&gt;
[('Je', 'PRO'), ('sais', '?'), (&amp;quot;qu'&amp;quot;, 'PRO'), ('il', 'PRO'),
 ('y', 'PRO'),  ('a', '?'), ('plus', '?'), ('de', 'PREP'), 
 ('3 000', '?'), ('Fran\xe7ais', '?'), ('en', 'PREP'), 
 ('Syrie', '?'), (',', 'PUN'), ('\xe0', 'PREP'), ('Damas', '?'), 
 (',', 'PUN'), ('\xe0', 'PREP'), ('Alep', '?'), (',', 'PUN') , 
 ('o\xf9', 'PREP'), ('nous', 'PRO'), ('avons', '?'), 
 ('notre', 'DET'), ('plus', '?'), ('ancien', '?'), ('consulat', '?'), 
 ('dans', 'PREP'), ('le', 'DET'), ('monde', '?'), ('.', 'PUN')]
&lt;/pre&gt;


&lt;p&gt;L'application de règles simples naïves telles que :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Un pronom est suivi d'un pronom ou d'un verbe ;&lt;/li&gt;
&lt;li&gt;Un déterminant est suivi d'un adjectif ou d'un nom ;&lt;/li&gt;
&lt;li&gt;Une préposition est suivie d'un nom propre, d'un pronom ou d'un déterminant ;&lt;/li&gt;
&lt;li&gt;Un adjectif est suivi d'un adjectif, d'un nom ou d'une ponctuation ;&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;permettent de deviner les catégories grammaticales qui peuvent s'appliquer aux mots inconnus de nos dictionnaires. Nous pourrons ensuite compléter notre dictionnaire de ces nouveaux et ainsi enrichir notre connaissance itérativement.&lt;/p&gt;


&lt;p&gt;C'est &lt;em&gt;grosso modo&lt;/em&gt; le concept de l'&lt;a href=&quot;http://en.wikipedia.org/wiki/Brill_tagger&quot; hreflang=&quot;en&quot;&gt;algorithme de Brill&lt;/a&gt;...&lt;/p&gt;


&lt;h3&gt;Fonctionnement&lt;/h3&gt;


&lt;p&gt;L'algorithme de Brill parcourt les mots du texte. Si la forme textuelle est présente dans son dictionnaire, il lui associe la catégorie grammaticale la plus probable, c-à-d celle la plus communément rencontrée pour ce mot. Lorsque la forme textuelle n'est pas présente dans le dictionnaire, il lui associe l'étiquette &lt;em&gt;NOM&lt;/em&gt; ou &lt;em&gt;NOM PROPRE&lt;/em&gt; si elle commence par une majuscule. Une fois cette première passe opérée, l'algorithme applique des règles de transformation des étiquettes telles que vues précédemment.&lt;/p&gt;


&lt;p&gt;On dit que l'algorithme est guidé par l'erreur (&lt;em&gt;error-driven&lt;/em&gt;) car il fait appel à de l'apprentissage supervisé (sélection des règles).&lt;/p&gt;


&lt;p&gt;Pour en savoir plus, vous pouvez lire cet &lt;a href=&quot;http://dl.acm.org/citation.cfm?id=1075553&quot; hreflang=&quot;en&quot;&gt;article écrit par Brill lui-même&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;Brill dans nltk&lt;/h2&gt;


&lt;p&gt;Nltk intègre &lt;a href=&quot;http://nltk.googlecode.com/svn/trunk/doc/api/nltk.tag.brill.BrillTagger-class.html&quot; hreflang=&quot;en&quot;&gt;une implémentation de l'algorithme de Brill&lt;/a&gt;, ainsi que l'&lt;a href=&quot;http://nltk.googlecode.com/svn/trunk/doc/api/nltk.tag.brill.BrillTaggerTrainer-class.html&quot; hreflang=&quot;en&quot;&gt;outillage nécessaire à l'entraînement d'un nouvel étiqueteur&lt;/a&gt;.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Travaux Pratique TALN - Morphologie et contexte syntaxique</title>
    <link>http://fabienpoulard.info/post/2011/10/25/Travaux-Pratique-TALN-Le-lexique</link>
    <guid isPermaLink="false">urn:md5:d4fe421dfe957ecc07e14fdea0fa7a6c</guid>
    <pubDate>Mon, 14 Nov 2011 18:55:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>analyse lexicale</category><category>analyse morphologique</category><category>corpus</category><category>enseignement</category><category>nltk</category><category>POS tagging</category><category>python</category><category>regexp</category>    
    <description>&lt;p&gt;Dans &lt;a href=&quot;http://fabienpoulard.info/post/2011/10/24/Travaux-Pratique-TALN-Le-lexique&quot;&gt;le TP précédent&lt;/a&gt; nous nous sommes limité à l'analyse des mots en-dehors de tout contexte. Il s'est alors agi de découper un texte en mots puis de compter ces derniers.&lt;/p&gt;


&lt;p&gt;Dans ce second TP, nous allons nous intéresser à la morphologie des mots (leur forme textuelle). Nous explorerons notamment deux procédés de normalisation morphologique : la racinisation et la lemmatisation. Nous découvrirons ensuite que le contexte des mots, combiné à leur morphologie, peut nous apprendre bien des choses.&lt;/p&gt;    &lt;p&gt;Je considère comme acquis le découpage en phrases et en mots (si ce n'est pas le cas, vous pouvez vous rafraîchir la mémoire &lt;a href=&quot;http://fabienpoulard.info/post/2011/10/24/Travaux-Pratique-TALN-Le-lexique&quot;&gt;ici&lt;/a&gt;). Nous allons dans cette partie directement travailler sur &lt;a href=&quot;http://fabienpoulard.info/download/Recherche/Corpus/Discours-Sarkozy-v20111025.preproc.txt.gz&quot; hreflang=&quot;fr&quot; title=&quot;Corpus des discours de N. Sarkozy après découpage en unités linguistiques&quot;&gt;une version du corpus des discours de N. Sarkozy déjà découpée en phrases et en mots&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;La fonction ci-dessous permet de charger la liste des phrases du corpus et pour chaque phrase la liste des mots qui la compose :&lt;/p&gt;
&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; load_preprocessed_corpus&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;finput=&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Discours-Sarkozy-v20111025.preproc.txt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
	Load the content of a preprocessed file as a list of sentences which happen
	to be a list of words.
	&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
	fh = &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;.&lt;span style=&quot;color: #008000;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;finput, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;r&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	corpus = fh.&lt;span style=&quot;color: black;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	fh.&lt;span style=&quot;color: black;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	sents = &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; sent &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; corpus.&lt;span style=&quot;color: black;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
		sents.&lt;span style=&quot;color: black;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt; sent.&lt;span style=&quot;color: black;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; sents&lt;/pre&gt;


&lt;p&gt;Exemple d'utilisation :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; sentences = load_preprocessed_corpus&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Discours-Sarkozy-v20111025.preproc.txt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Nombre de phrases  : %d&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;sentences&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #483d8b;&quot;&gt;'Nombre de phrases  : 84325'&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Nombre de mots : %d&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;w &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; s &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; sentences &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; w &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; s&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #483d8b;&quot;&gt;'Nombre de mots : 2017309'&lt;/span&gt;&lt;/pre&gt;


&lt;h2&gt;Morphologie : des expressions rationnelles à l'algorithme de Porter&lt;/h2&gt;


&lt;p&gt;Nous allons avoir besoin d'un outil puissant pour exprimer par intention les formes textuelles que nous allons manipuler : les &lt;a href=&quot;http://fr.wikipedia.org/wiki/Expression_rationnelle&quot; hreflang=&quot;fr&quot;&gt;expressions rationnelles&lt;/a&gt;. Celles-ci permettent de décrire un langage régulier pour lequel il sera possible de générer un automate acceptant. La plupart des langages informatiques récents offrent des bibliothèques permettant de manipuler  ces expressions et les automates en découlant. &lt;a href=&quot;http://docs.python.org/howto/regex.html#regex-howto&quot; hreflang=&quot;en&quot;&gt;Python ne fait pas exception à la règle&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Les expressions rationnelles sont gérés sous Python par le module &lt;em&gt;re&lt;/em&gt;. Il serait trop long de présenter l'utilisation des expressions rationnelles avec Python ici, et &lt;a href=&quot;http://diveintopython.adrahon.org/regular_expressions/index.html&quot; hreflang=&quot;fr&quot;&gt;d'autres le font beaucoup mieux que moi&lt;/a&gt;.&lt;/p&gt;


&lt;h3&gt;France, Français, Française, Françaises...&lt;/h3&gt;


&lt;p&gt;Le &lt;a href=&quot;http://fabienpoulard.info/public/2011/TP-TALN/nuage-mots-sarkozy.png&quot;&gt;nuage de mots&lt;/a&gt; généré &lt;a href=&quot;http://fabienpoulard.info/post/2011/10/24/Travaux-Pratique-TALN-Le-lexique&quot;&gt;précédemment&lt;/a&gt; contient des mots très similaires, c'est le cas notamment de &lt;em&gt;français&lt;/em&gt; et &lt;em&gt;française&lt;/em&gt;. Les expressions rationnelles peuvent nous permettre de les considérer ensemble :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;findall&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;bfrançais&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;b&amp;quot;&lt;/span&gt;, text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff4500;&quot;&gt;1031&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;findall&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;bfrançaise&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;b&amp;quot;&lt;/span&gt;, text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff4500;&quot;&gt;1286&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;findall&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;bfran[cç]ais&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;w&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;b&amp;quot;&lt;/span&gt;, text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff4500;&quot;&gt;2661&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; tous_francais = &lt;span style=&quot;color: #008000;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; m &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;finditer&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;bfran[cç]ais&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;w*&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;b&amp;quot;&lt;/span&gt;, text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
...     &lt;span style=&quot;color: black;&quot;&gt;tous_francais&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt; m.&lt;span style=&quot;color: black;&quot;&gt;group&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; tous_francais
&lt;span style=&quot;color: #008000;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'fran&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e7aise'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'fran&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e7ais'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'fran&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\x&lt;/span&gt;e7aises'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;Généralisation : vers l'algorithme de Porter&lt;/h3&gt;


&lt;p&gt;L'exemple précédent nous montre que nous pourrions profiter d'une normalisation morphologique des mots collectés  afin de rendre mieux compte de la distribution lexicale. Après tout &lt;em&gt;français&lt;/em&gt;, &lt;em&gt;française&lt;/em&gt; et &lt;em&gt;françaises&lt;/em&gt; correspondent tous trois au même mot &lt;em&gt;français&lt;/em&gt; tel qu'on le trouve dans &lt;a href=&quot;http://atilf.atilf.fr/dendien/scripts/tlfiv5/visusel.exe?16;s=2523494280;r=1;nat=;sol=9;&quot; hreflang=&quot;fr&quot;&gt;le dictionnaire&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;En effet, &lt;em&gt;française&lt;/em&gt; et &lt;em&gt;françaises&lt;/em&gt; sont des flexions de l'adjectif &lt;em&gt;français&lt;/em&gt;. En linguistique, on oppose flexions et dérivations :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;La flexion consiste à ajouter un affixe au mot afin de refléter un changement au niveau grammatical, du genre, du nombre, de la personne, etc., sans que cette modification morphologique n'altère le sens du lexème d'origine ;&lt;/li&gt;
&lt;li&gt;La dérivation consiste à créer un nouveau lexème, c-à-d un nouveau mot avec un nouveau sens, par l'ajout d'un affixe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Les règles flexionnelles en français semblent assez régulières : ajout d'un &amp;quot;e&amp;quot; pour marquer le féminin, d'un &amp;quot;s&amp;quot; pour le pluriel... Ne pourrait-on pas définir un algorithme capable de déconstruire ces flexions afin de retrouver le lexème d'origine, au masculin singulier ?&lt;/p&gt;


&lt;p&gt;Petit exercice :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tentez de produire une liste exhaustive des suffixes utilisés pour marquer le genre et le nombre en français&lt;/li&gt;
&lt;li&gt;Recherchez toutes les formes textuelles qui utilisent ces suffixes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Proposition de corrigé :&lt;/p&gt;
&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;all_words = &lt;span style=&quot;color: #008000;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;w.&lt;span style=&quot;color: black;&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; w &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; words&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
 
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; evaluation_suffix&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;suffix&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;global&lt;/span&gt; raw_text
	regexp = &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: #008000;&quot;&gt;compile&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;r&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\b&lt;/span&gt;(&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\w&lt;/span&gt;+)%s&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\b&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt;suffix, &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;I&lt;/span&gt;|re.&lt;span style=&quot;color: black;&quot;&gt;U&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	&lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt; = &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Collecter les mots avec le suffixe&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; m &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; regexp.&lt;span style=&quot;color: black;&quot;&gt;finditer&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;raw_text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
		avec_suffixe = m.&lt;span style=&quot;color: black;&quot;&gt;group&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		sans_suffixe = m.&lt;span style=&quot;color: black;&quot;&gt;group&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;has_key&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;avec_suffixe&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
			&lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;avec_suffixe&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt; = &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;
				&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sans_suffixe&amp;quot;&lt;/span&gt;: sans_suffixe,
				&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sans_suffixe_existe&amp;quot;&lt;/span&gt;: &lt;span style=&quot;color: #008000;&quot;&gt;False&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Chercher les occurrences sans suffixe&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; k &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;keys&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
		sans_suffixe = &lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;k&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sans_suffixe&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		&lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;k&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sans_suffixe_existe&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt; = &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;sans_suffixe &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; all_words&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Rapport&lt;/span&gt;
	nb_est_suffixe = &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;k &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; k &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;keys&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;k&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;sans_suffixe_existe&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	nb_est_pas_suffixe = &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; - nb_est_suffixe
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; nb_est_suffixe &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt; nb_est_pas_suffixe:
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;%s est un suffixe (%d/%d)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;suffix, nb_est_suffixe, nb_est_pas_suffixe&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;else&lt;/span&gt;:
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;%s n'est PAS un suffixe (%d/%d)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;suffix, nb_est_suffixe, nb_est_pas_suffixe&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
 
suffixes = &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ous&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aux&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;e&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ais&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ives&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ent&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;es&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ai&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ons&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ez&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;t&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ait&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ions&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;iez&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aient&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ant&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;le&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;les&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ne&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;nes&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;x&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
 
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; suffix &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; suffixes:
	evaluation_suffix&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;suffix&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;Algorithme de Porter&lt;/h3&gt;


&lt;p&gt;L'algorithme de Porter offre un cadre algorithmique pour la désuffixation des mots. Le fonctionnement de l'algorithme est décrit en de nombreux endroits sur le Web, notamment &lt;a href=&quot;http://fabienpoulard.info/post/2011/10/25/www-igm.univ-mlv.fr/~lecroq/cours/porter.pdf&quot; hreflang=&quot;fr&quot; title=&quot;Présentation de l'algorithme de Porter par Thierry Lecroq de l'Université de Rouen&quot;&gt;ici&lt;/a&gt; ou &lt;a href=&quot;http://fabienpoulard.info/post/2008/02/21/Lalgorithme-de-Porter&quot; hreflang=&quot;fr&quot; title=&quot;Présentation de l'algorithme de Porter par Fabien Poulard&quot;&gt;sur mon propre blog&lt;/a&gt;. S'il a été mis au point pour l'anglais, il est tout à fait envisageable de l'utiliser pour le français (&lt;a href=&quot;http://snowball.tartarus.org/&quot; hreflang=&quot;en&quot; title=&quot;Implémentation multilingue de l'algorithme de Porter&quot;&gt;d'ailleurs certains l'ont fait&lt;/a&gt;).&lt;/p&gt;


&lt;p&gt;L'idée de l'algorithme de Porter est de déconstruire les flexions pour retrouver la forme canonique des mots : le lemme. Par exemple : retirer le suffixe &amp;quot;aux&amp;quot; de &lt;em&gt;chevaux&lt;/em&gt; et le remplacer par &amp;quot;al&amp;quot; pour obtenir le singulier. Les règles de Porter sont déclenchées lorsque deux conditions sont réunies :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;le mot se termine par un suffixe particulier&lt;/li&gt;
&lt;li&gt;le radical (mot privé dudit suffixe) respecte un motif particulier, le plus généralement un certain nombre de pseudo-syllabes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Le code python ci-dessous est une proposition d'implémentation de la règle de Porter pour normaliser &lt;em&gt;journaux&lt;/em&gt; et &lt;em&gt;chevaux&lt;/em&gt; en respectivement &lt;em&gt;journal&lt;/em&gt; et &lt;em&gt;cheval&lt;/em&gt; :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; compute_m&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;w&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
     pseudosyllabs = &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;
     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; c &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; w:
             &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; c &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;'a'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'e'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'i'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'o'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'u'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'y'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;:
                     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;pseudosyllabs&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;==&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;or&lt;/span&gt; pseudosyllabs&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;-&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;==&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;C&amp;quot;&lt;/span&gt;:
                             pseudosyllabs += &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;V&amp;quot;&lt;/span&gt;
             &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;else&lt;/span&gt;:
                     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;pseudosyllabs&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;==&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;or&lt;/span&gt; pseudosyllabs&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;-&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;==&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;V&amp;quot;&lt;/span&gt;:
                             pseudosyllabs += &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;C&amp;quot;&lt;/span&gt;
     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; pseudosyllabs.&lt;span style=&quot;color: black;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;VC&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Règle de Porter : (m=1 &amp;amp;&amp;amp; *c) aux -&amp;gt; al&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Le mot se termine par aux, a un radical composé d'une pseudo-syllabe et qui se termine par une consomne&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; regle_porter_aux&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;w&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; w.&lt;span style=&quot;color: black;&quot;&gt;endswith&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;aux&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
          radical = w&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;:-&lt;span style=&quot;color: #ff4500;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
          &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;not&lt;/span&gt; radical&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;-&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;'a'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'e'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'i'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'o'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'u'&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;'y'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;:
               &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; radical + &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;al&amp;quot;&lt;/span&gt;
     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; w
 
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; regle_porter_aux&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;journaux&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #483d8b;&quot;&gt;'journal'&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; regle_porter_aux&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;chevaux&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #483d8b;&quot;&gt;'cheval'&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; regle_porter_aux&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;agneaux&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #483d8b;&quot;&gt;'agneaux'&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Petit exercice :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Écrire d'autres règles pour le français dans le formalisme proposé par Porter&lt;/li&gt;
&lt;li&gt;À partir du &lt;a href=&quot;http://atoll.inria.fr/~sagot/lefff.html&quot; hreflang=&quot;fr&quot;&gt;travail de compilation des formes flexionnelles du français par B. Sagot&lt;/a&gt;, pouvez-vous inférer automatiquement toutes les règles de Porter pour le français ?&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Travaux Pratique TALN - Le lexique</title>
    <link>http://fabienpoulard.info/post/2011/10/24/Travaux-Pratique-TALN-Le-lexique</link>
    <guid isPermaLink="false">urn:md5:aa022e2b9c0d0f2ff31a5820a3b04ee4</guid>
    <pubDate>Mon, 24 Oct 2011 22:38:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>analyse lexicale</category><category>corpus</category><category>enseignement</category><category>nltk</category><category>python</category><category>scikit-learn</category>    
    <description>&lt;p&gt;Malgré &lt;a href=&quot;http://www.dictanova.com&quot; hreflang=&quot;fr&quot; title=&quot;Page de présentation de Dictanova&quot;&gt;notre projet de création d'entreprise&lt;/a&gt;, je tenais à continuer à enseigner le TALN à l'Université. Outre l'intérêt pragmatique du chef d'entreprise qui souhaite ainsi repérer les éléments prometteurs à recruter, l'enseignement est une des meilleures manières de prendre du recul sur un domaine.&lt;/p&gt;


&lt;p&gt;Cette année je compte mettre de côté UIMA pour me concentrer sur l'expérimentation. J'ai donc décidé de me tourner vers Python, mon langage de cœur, et les bibliothèques &lt;a href=&quot;http://www.nltk.org/&quot; hreflang=&quot;en&quot;&gt;NLTK&lt;/a&gt; et &lt;a href=&quot;http://scikit-learn.sourceforge.net/stable/&quot; hreflang=&quot;en&quot;&gt;scikit-learn&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Pour ce premier TP, je compte faire réfléchir les étudiants sur l'analyse lexicale : découpage d'un texte en mots, calculer une distribution sur un document, puis un corpus, filtrer les mots qui participent peu à l'expression du sens et visualiser un texte à partir de son lexique.&lt;/p&gt;    &lt;h2&gt;Constitution du corpus&lt;/h2&gt;


&lt;p&gt;Si la construction du corpus est toujours primordiale, celle-ci revêt un enjeu d'autant plus stratégique en enseignement que le corpus peut captiver ou repousser les étudiants.&lt;/p&gt;


&lt;p&gt;J'ai un temps été tenté par les messages de condoléances laissés par les fans d'Apple à l'occasion de la mort de Steve Jobs. Neil Kodner a réalisé &lt;a href=&quot;http://www.neilkodner.com/2011/10/an-analysis-of-steve-jobs-tribute-messages-displayed-by-apple/&quot; hreflang=&quot;en&quot;&gt;une superbe analyse sur le sujet&lt;/a&gt;. Toutefois, je préfère faire travailler mes étudiants sur le français qui a des propriétés particulières qu'on ne retrouve pas en anglais, notamment sa forte flexionnalité.&lt;/p&gt;


&lt;p&gt;À l'occasion du lancement par Google d'un concours de visualisation de données sur la thématique des élections présidentielles 2012, je me suis une nouvelle fois tourné vers les discours politiques. Ceux-ci sont souvent chargés de symboles qui s'expriment souvent par le lexique, d'où l'intérêt de les utiliser dans ce genre d'étude. Bien sûr l'objectif n'est pas de chercher à atteindre la qualité des études menées avec brillo par &lt;a href=&quot;http://blog.veronis.fr/&quot; hreflang=&quot;fr&quot;&gt;Jean Véronis&lt;/a&gt;, mais simplement se faire la main sur quelques textes contemporains d'intérêts.&lt;/p&gt;


&lt;p&gt;Pour la constitution du corpus, je me suis simplement tourné vers &lt;a href=&quot;http://www.elysee.fr/&quot; hreflang=&quot;fr&quot;&gt;le site de l'Élysée&lt;/a&gt;. J'avais commencé à &lt;a href=&quot;http://fabienpoulard.info/post/2010/03/13/Corpus-des-discours-de-Nicolas-Sarkozy-%28M%C3%80J%29&quot;&gt;collecter les différents discours de notre président&lt;/a&gt;, mais une mise-à-jour du site (fortement inspiré du &lt;a href=&quot;http://www.whitehouse.gov/&quot; hreflang=&quot;en&quot;&gt;site de la Maison Blanche&lt;/a&gt;) m'avait coupé dans mon élan. Le point positif est que ce nouveau site met l'accent sur l'accessibilité. J'ai écrit un petit script Python qui permet d'aller récupérer tous les discours. Il est un peu simpliste et ramène donc un peu de bruit, mais suffisamment peu pour que le résultat soit exploitable :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#!/usr/bin/env python&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# -*- coding: utf-8 -*-&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Scrap the speeches from M. President Sarkozy :)&lt;/span&gt;
 
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;urllib2&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; BeautifulSoup &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; BeautifulSoup
 
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; did &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;12300&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
	&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stdout&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Dealing with page %d...&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt;did&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;try&lt;/span&gt;:
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Collect the page&lt;/span&gt;
		uh    = &lt;span style=&quot;color: #dc143c;&quot;&gt;urllib2&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;urlopen&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;http://www.elysee.fr/president/root/bank/print/%d.htm&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; did&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		html  = uh.&lt;span style=&quot;color: black;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		uh.&lt;span style=&quot;color: black;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Check it is a discourse (discourse subcategory)&lt;/span&gt;
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; html.&lt;span style=&quot;color: black;&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;/president/root/core/D00018&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;= &lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;:
			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Extract the text&lt;/span&gt;
			soup  = BeautifulSoup&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;html&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
			zone  = soup.&lt;span style=&quot;color: black;&quot;&gt;body&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;div&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #008000;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;zonePrincipale&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
			texts = &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;t.&lt;span style=&quot;color: black;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; t &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; zone.&lt;span style=&quot;color: black;&quot;&gt;findAll&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;text=&lt;span style=&quot;color: #008000;&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;t.&lt;span style=&quot;color: black;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Export it&lt;/span&gt;
			fh = &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;.&lt;span style=&quot;color: #008000;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;%d.txt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt;did, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;w&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
			&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; t &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; texts:
				fh.&lt;span style=&quot;color: black;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;t + &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
			fh.&lt;span style=&quot;color: black;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
			&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stdout&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;done&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;else&lt;/span&gt;:
			&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stdout&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;ignored&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;except&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;Exception&lt;/span&gt;:
		&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stdout&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;error&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;À l'heure de l'écriture de ce billet, le script permet de collecter 588 discours (ou pages identifiées comme tels) pour un total de 1943116 mots. L'export de l'extraction peut-être téléchargé &lt;a href=&quot;http://fabienpoulard.info/download/Recherche/Corpus/Discours-Sarkozy-v20111025.tar.gz&quot; hreflang=&quot;fr&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;Découpage en mots&lt;/h2&gt;


&lt;p&gt;J'ai déjà discuté plusieurs fois du découpage en mots sur ce blog : avec &lt;a href=&quot;http://fabienpoulard.info/post/2008/03/05/Tokenisation-en-mots-avec-NLTK&quot;&gt;NLTK&lt;/a&gt; ou de &lt;a href=&quot;http://fabienpoulard.info/post/2010/09/08/Un-rapide-tokeniseur-en-mots-pour-le-fran%C3%A7ais&quot;&gt;manière plus théorique&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Je vois trois façons d'approcher le problème du découpage en mots :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Rechercher les sous-chaînes qui constituent les mots ;&lt;/li&gt;
&lt;li&gt;Rechercher les sous-chaînes qui séparent les mots ;&lt;/li&gt;
&lt;li&gt;Identifier les frontières entre les mots et les non-mots.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;La première approche est celle qui a été auparavant discutée sur ce blog. L'idée générale est qu'un mot (ou plus précisément un &lt;a href=&quot;http://ldelafosse.pagesperso-orange.fr/Glossaire/L.htm#lexeme&quot; hreflang=&quot;fr&quot;&gt;lexème&lt;/a&gt;) est une séquence continue de lettres ou de chiffres. Les choses se compliquent lorsque l'on considère les cas particuliers : les articles et pronoms contractés (l', d', j', m', ...) ; les composés lexicaux à apostrophe (aujourd'hui, ...) ; les composés lexicaux à traits d'union (arc-en-ciel, peut-être, sauve-qui-peut, ...) ; les valeurs numériques (14 000, 14,18, 30 %, ...) ; les acronymes (ASSEDIC, ASCII, ...) ; les sigles (C-4, c-à-d, i.e., ...) ou encore les unités de mesure (A/m, km/h, ...).&lt;/p&gt;


&lt;p&gt;La seconde approche me semble biaisée par nature. Elle fonctionne suffisamment bien pour l'anglais où l'on peut envisager découper un texte en mots en coupant à l'endroit des espaces. Elle est toutefois inefficace pour le français étant donné le nombre de cas où les mots sont séparés par une chaîne vide (présence d'un apostrophe, ponctuation, ...).&lt;/p&gt;


&lt;p&gt;La dernière approche serait celle que je mettrais en œuvre si je devais implémenter un algorithme de découpage en mot par &lt;a href=&quot;http://fr.wikipedia.org/wiki/Apprentissage_automatique&quot; hreflang=&quot;fr&quot;&gt;apprentissage&lt;/a&gt;. L'idée serait alors de classer chaque caractère dans une des catégories : début de mot, fin de mot ou n'appartenant pas à un mot. Je ne connais pas l'état de l'art des techniques de tokenisation automatique, mais une approche par n-grammes caractères devrait assez bien fonctionner. Il faudrait toutefois étudier lequel du contexte gauche ou droit est le plus important (si l'un des deux est plus important que l'autre).&lt;/p&gt;


&lt;p&gt;Pour l'exercice nous utiliserons le &lt;a href=&quot;http://nltk.googlecode.com/svn/trunk/doc/api/nltk.tokenize.regexp.RegexpTokenizer-class.html&quot; hreflang=&quot;en&quot;&gt;RegexpTokenizer&lt;/a&gt; de nltk avec l'expression régulière suivante (à améliorer éventuellement) :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; nltk.&lt;span style=&quot;color: #dc143c;&quot;&gt;tokenize&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;regexp&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; RegexpTokenizer
 
reg_words = r&lt;span style=&quot;color: #483d8b;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;'(?x)
          aujourd'&lt;/span&gt;hui    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# exception 1&lt;/span&gt;
        | prud&lt;span style=&quot;color: #483d8b;&quot;&gt;'hom&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\w&lt;/span&gt;+ # exception 2
        | &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\d&lt;/span&gt;+(,&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\d&lt;/span&gt;+)?&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;*[%€$] # les valeurs
        | &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\d&lt;/span&gt;+                # les nombres
        | &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\w&lt;/span&gt;'&lt;/span&gt;                 &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# les contractions d', l', j', t', s'&lt;/span&gt;
        | \w+&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;-\w+&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;+    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# les mots composés&lt;/span&gt;
        | &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;\d|\w&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;+         &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# les combinaisons alphanumériques&lt;/span&gt;
        | \w+               &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# les mots simples&lt;/span&gt;
        &lt;span style=&quot;color: #483d8b;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;'
tokenizer = RegexpTokenizer(reg_words, flags=re.UNICODE|re.IGNORECASE)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;L'utilisation du RegexpTokenizer est des plus simple, il suffit d'appeler la méthode &lt;em&gt;tokenize&lt;/em&gt; sur un texte pour obtenir en retour la liste des mots extraits dudit texte :&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt;&amp;gt; tokenizer.tokenize(text)

[u'Hommage', u'\xe0', u'M', u'Aim\xe9', u'C\xc9SAIRE', u'ALLOCUTION', u'DE', u'M', u'LE', u'PR\xc9SIDENT', u'DE', u'LA', 
u'R\xc9PUBLIQUE', u'FRAN\xc7AISE', u'A\xe9roport', u'de', u'Fort-de-France', u'Martinique', u'Dimanche', u'20', u'Avril', u'2008', u&amp;quot;C'&amp;quot;, 
u'est', u'avec', u'une', u'profonde', u'\xe9motion', u'que', u'je', u'viens', u&amp;quot;aujourd'hui&amp;quot;, u'rendre', u&amp;quot;l'&amp;quot;, u'hommage', u'de', u'la', 
u'Nation', u'\xe0', u'Aim\xe9', u'C\xc9SAIRE', u'qui', u'nous', u'a', u'quitt\xe9s', u'jeudi', u'dernier', u'Ma', u'place', u'ne', u'pouvait', 
u'\xeatre', u&amp;quot;aujourd'hui&amp;quot;, u'que', u'sur', u'cette', u'terre', u'de', u'Martinique', u'aux', u'c\xf4t\xe9s', u'de', u'ceux', u'qui', u'sont', 
u'dans', u'la', u'peine', u'Mes', u'premi\xe8res', u'pens\xe9es', u'vont', u'naturellement', u'\xe0', u'la', u'famille', u'endeuill\xe9e', 
u'qu', u'avec', u'les', u'ministres', u'je', u'rencontrerai', u'dans', ...
&lt;/pre&gt;


&lt;h2&gt;Distribution des mots&lt;/h2&gt;


&lt;p&gt;L'objet du découpage en mot est, outre de se confronter à la difficulté bien réelle de la tâche, de mesurer la distribution du lexique dans le corpus des discours. Plus simplement dit, il s'agit de compter le nombre d'occurrences de chacun des mots utilisés. Par mot, j'entends ici &lt;a href=&quot;http://ldelafosse.pagesperso-orange.fr/Glossaire/L.htm#lexie&quot; hreflang=&quot;fr&quot;&gt;lexie&lt;/a&gt; (bien sûr ^^), soit la forme textuelle qui fait référence au mot tel qu'on le trouve dans le dictionnaire.&lt;/p&gt;


&lt;p&gt;Pour le comptage des mots, il est possible d'utiliser un simple dictionnaire en gérant l'ajout d'une clé pour chaque nouveau mot rencontré. NLTK propose toutefois une classe qui permet de s'affranchir de cette déclaration et de se concentrer uniquement sur le comptage : la classe &lt;a href=&quot;http://nltk.googlecode.com/svn/trunk/doc/api/nltk.probability.FreqDist-class.html&quot; hreflang=&quot;en&quot;&gt;FreqDist&lt;/a&gt;.&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; nltk.&lt;span style=&quot;color: black;&quot;&gt;probability&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; FreqDist
 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Comptage des mots à la création&lt;/span&gt;
fdist = FreqDist&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;  tokenizer.&lt;span style=&quot;color: #dc143c;&quot;&gt;tokenize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;  &lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# ... ou bien en parcourant la liste&lt;/span&gt;
fdist = FreqDist&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; word &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt;  tokenizer.&lt;span style=&quot;color: #dc143c;&quot;&gt;tokenize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;text&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
     fdist.&lt;span style=&quot;color: black;&quot;&gt;inc&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt; word.&lt;span style=&quot;color: black;&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;En plus d'économiser la déclaration des mots, la classe ordonne automatiquement les mots par fréquence décroissante :&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt;&amp;gt; fdist.items()[:30]

[(u'de', 53), (u'la', 36), (u'qui', 23), (u'et', 19), (u&amp;quot;l'&amp;quot;, 18), (u'un', 17), (u'\xe0', 14), (u'des', 13),
 (u'que', 13), (u'les', 12), (u'le', 11), (u'a', 10), (u'est', 10), (u'homme', 10), (u'sa', 9),
 (u'aim\xe9', 8), (u'c\xe9saire', 8), (u'je', 8), (u&amp;quot;c'&amp;quot;, 7), (u'dans', 7), (u'du', 7), (u'cet', 6),
 (u'france', 6), (u'martinique', 6), (u'nous', 6), (u'ses', 6), (u'avec', 5), (u'ce', 5), (u&amp;quot;d'&amp;quot;, 5), (u'martiniquais', 5)]
&lt;/pre&gt;


&lt;h2&gt;Filtrage des mots non signifiants&lt;/h2&gt;


&lt;p&gt;Tous les mots d'un texte ne jouent pas le même rôle : certains participent à la construction du sens (je les appellerai &lt;em&gt;signifiants&lt;/em&gt;), d'autres ont un rôle d'assemblage (je les appellerai &lt;em&gt;outils&lt;/em&gt;). La catégorisation est volontairement extrêmement grossière. Toute la profondeur de l'analyse lexicale réside précisément dans le juste filtrage des mots qui n'apporte pas de sens dans le contexte de l'énonciation. Comment les sélectionner ?&lt;/p&gt;


&lt;p&gt;Une hypothèse simple, mais qui fonctionne assez bien, est de considérer que les mots les plus communs ne participent pas à l'élaboration du sens. L'hypothèse est globalement validé si l'on observe le top 50 des mots du corpus :&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt;&amp;gt; fdist.items()[:50]

[(u'de', 101164), (u'la', 67872), (u'le', 48749), (u'et', 42159), (u&amp;quot;l'&amp;quot;, 41465), (u'les', 36784), (u'que', 33999),
 (u'\xe0', 31771), (u'des', 30118), (u'est', 30097), (u&amp;quot;d'&amp;quot;, 26459), (u'en', 22888), (u'qui', 22072), (u'je', 21717),
 (u'un', 20687), (u'pas', 20162), (u'pour', 19479), (u'du', 18521), (u'il', 17603), (u'une', 17362), (u'a', 16495),
 (u'nous', 16219), (u&amp;quot;c'&amp;quot;, 15088), (u'dans', 14612), (u'vous', 14175), (u'on', 13874), (u'ce', 13645), (u'ne', 13540),
 (u'qu', 12816), (u&amp;quot;n'&amp;quot;, 12401), (u'au', 11463), (u'plus', 9716), (u'sur', 8973), (u'france', 8316), (u'avec', 8311), (u'y', 8047),
 (u'mais', 7662), (u'pr\xe9sident', 7540), (u&amp;quot;j'&amp;quot;, 6409), (u'par', 6384), (u'se', 6252), (u'sous', 6225), (u'r\xe9publique', 6179),
 (u'sont', 5905), (u&amp;quot;s'&amp;quot;, 5809), (u'aux', 5673), (u'publi\xe9', 5586), (u'class\xe9', 5576), (u'cette', 5564), (u'cela', 5555)]
&lt;/pre&gt;


&lt;p&gt;Dans les faits, il semble important de conserver des mots tels que &lt;em&gt;france&lt;/em&gt; ou &lt;em&gt;république&lt;/em&gt;. Au final, il est donc préférable d'opérer la sélection manuellement.&lt;/p&gt;


&lt;p&gt;Une première phase de filtrage consiste à supprimer toutes les entrées qui correspondent aux mots outils classiques (déterminants, pronoms, verbes être et avoir, ...). NLTK propose une telle liste de mots :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; nltk.&lt;span style=&quot;color: black;&quot;&gt;corpus&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; stopwords
 
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; sw &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; stopwords.&lt;span style=&quot;color: black;&quot;&gt;words&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;french&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; fdist.&lt;span style=&quot;color: black;&quot;&gt;has_key&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;sw&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
          fdist.&lt;span style=&quot;color: black;&quot;&gt;pop&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;sw&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il faut ensuite la compléter en observant manuellement, parmi les mots les plus fréquents, ceux qui n'apportent pas d'information sur le contenu d'un discours politique. J'ai déposé une proposition d'anti-dictionnaire composé de 318 mots, encodés en UTF-8, dans &lt;a href=&quot;http://fabienpoulard.info/download/Recherche/Corpus/antidictionnaire&quot; hreflang=&quot;fr&quot;&gt;l'espace de téléchargement du corpus&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Le top 50 des mots du corpus une fois l'anti-dictionnaire appliqué est beaucoup plus parlant :&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt;&amp;gt; fdist.items()[:50]

[(u'france', 8316), (u'pr\xe9sident', 7540), (u'r\xe9publique', 6179), (u'monde', 4083), (u'fran\xe7ais', 3194),
 (u'europe', 3189), (u'travail', 2434), (u'ministre', 2331), (u'\xe9tat', 2175), (u'politique', 2130),
 (u'fran\xe7aise', 1812), (u'question', 1770), (u'crise', 1755), (u'avenir', 1515), (u'entreprises', 1480),
 (u'r\xe9forme', 1430), (u's\xe9curit\xe9', 1424), (u'vie', 1424), (u'besoin', 1420), (u'conseil', 1397),
 (u'international', 1319), (u'emploi', 1318), (u'recherche', 1314), (u'gouvernement', 1308), (u'\xe9conomie', 1253),
 (u'd\xe9veloppement', 1194), (u'etat', 1153), (u'palais', 1136), (u'paris', 1123), (u'droit', 1098),
 (u'histoire', 1079), (u'service', 1074), (u'\xe9conomique', 1054), (u'syst\xe8me', 1046), (u'enfants', 1006),
 (u'jeunes', 1000), (u'afrique', 985), (u'moyens', 954), (u'europ\xe9enne', 950), (u'plan', 941), (u'croissance', 925),
 (u'nationale', 903), (u'amis', 900), (u'loi', 888), (u'ministres', 885), (u'sant\xe9', 885), (u'projet', 873),
 (u'hommes', 842), (u'euros', 833), (u'culture', 829)]
&lt;/pre&gt;


&lt;h2&gt;Visualisation&lt;/h2&gt;


&lt;p&gt;La dernière étape du TP consiste à visualiser les données ainsi collectées. Il existe plusieurs méthodes de visualisation de ce type de données (voir notamment &lt;a href=&quot;http://blog.veronis.fr/2006/04/2007-larbre-des-thmes.html&quot; hreflang=&quot;fr&quot;&gt;ce billet de Jean Véronis&lt;/a&gt;), j'ai choisi la plus simple de toutes : le nuage de mots.&lt;/p&gt;


&lt;p&gt;J'utilise l'&lt;a href=&quot;http://www.wordle.net/&quot; hreflang=&quot;en&quot;&gt;outil Wordle&lt;/a&gt; pour générer mes nuages, et plus particulièrement &lt;a href=&quot;http://www.wordle.net/advanced&quot; hreflang=&quot;en&quot;&gt;l'interface avancée&lt;/a&gt; qui permet d'indiquer soit même les mots retenus et leur pondération.&lt;/p&gt;


&lt;p&gt;J'ai retenu pour le nuage les 500 mots les plus présents dans le corpus. Leur pondération est calculée à partir de leur fréquence multipliée par 10000 :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; w &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; fdist.&lt;span style=&quot;color: black;&quot;&gt;keys&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;:&lt;span style=&quot;color: #ff4500;&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;:
     &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;%s:%d&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;w, &lt;span style=&quot;color: #008000;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;fdist.&lt;span style=&quot;color: black;&quot;&gt;freq&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;w&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;10000&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le résultat est visible dans &lt;a href=&quot;http://www.wordle.net/show/wrdl/4298454/Discours_de_N._Sarkozy&quot; hreflang=&quot;fr&quot;&gt;la galerie publique de Wordle&lt;/a&gt;, ou ci-dessous :&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/2011/TP-TALN/nuage-mots-sarkozy.png&quot; title=&quot;Nuage de mots du corpus des discours publiques de N. Sarkozy en tant que président de la République (jusqu'au 24 octobre 2011).&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/2011/TP-TALN/.nuage-mots-sarkozy_m.jpg&quot; alt=&quot;Nuage de mots du corpus des discours publiques de N. Sarkozy en tant que président de la République (jusqu'au 24 octobre 2011).&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Nuage de mots du corpus des discours publiques de N. Sarkozy en tant que président de la République (jusqu'au 24 octobre 2011)., oct. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Présentation aux Rendez-vous de la recherche à la Cantine de Nantes</title>
    <link>http://fabienpoulard.info/post/2011/04/05/Pr%C3%A9sentation-aux-Rendez-vous-de-la-recherche-%C3%A0-la-Cantine-de-Nantes</link>
    <guid isPermaLink="false">urn:md5:3cb0107c2c447670cba466de40398dfd</guid>
    <pubDate>Tue, 05 Apr 2011 20:45:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>La Cantine</category><category>présentation</category><category>RdvR</category><category>recherche</category>    
    <description>    &lt;p&gt;Aujourd'hui, J'ai joué le jeu des &lt;em&gt;Rendez-vous de la Recherche&lt;/em&gt; (RdvR pour les intimes) à &lt;a href=&quot;http://cantine-nantes.org/&quot;&gt;La Cantine de Nantes&lt;/a&gt;. J'y ai présenté mon parcours de jeune chercheur, mon équipe et mon domaine de recherche : le &lt;a href=&quot;http://www.atala.org/&quot; hreflang=&quot;fr&quot;&gt;Traitement Automatique des Langues&lt;/a&gt; (TAL).&lt;/p&gt;


&lt;p&gt;Les &lt;em&gt;Rendez-vous de la Recherche&lt;/em&gt; sont organisés par &lt;a href=&quot;http://www.linkedin.com/in/jeanbezivin&quot; hreflang=&quot;en&quot;&gt;Jean Bézivin&lt;/a&gt; et &lt;a href=&quot;http://www.univ-nantes.fr/guedon-jp/0/fiche___annuaireksup/&quot; hreflang=&quot;fr&quot;&gt;Jean-Pierre Guédon&lt;/a&gt;, L'objectif de ces présentations informelles est de faire se rencontrer le monde de la recherche et de l'industrie. Le chercheur présente ses travaux, son équipe et son domaine. Les industriels piochent dans le flot d'information les éléments qui pourraient permettre de résoudre certaines de leurs problématiques et échangent sur ce sujet avec le chercheur. Ceci peut déboucher sur des collaborations, des initiatives...&lt;/p&gt;


&lt;p&gt;Le support de ma présentation est disponible sur &lt;a href=&quot;http://www.scribd.com/doc/52351094/&quot; hreflang=&quot;fr&quot;&gt;scribd&lt;/a&gt;.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Je soutiens ma thèse !</title>
    <link>http://fabienpoulard.info/post/2011/03/17/Je-soutiens-ma-th%C3%A8se-%21</link>
    <guid isPermaLink="false">urn:md5:ecbf2a5017cef2291d148070345d1dcc</guid>
    <pubDate>Thu, 17 Mar 2011 17:00:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>these</category>    
    <description>&lt;p&gt;Je soutiendrai ma thèse le &lt;strong&gt;Jeudi 24 mars 2011 à 9h30&lt;/strong&gt; dans la &lt;a href=&quot;http://www.openstreetmap.org/?mlat=47.237051&amp;amp;mlon=-1.552404&amp;amp;zoom=18&amp;amp;layers=M&quot;&gt;salle 3 du LINA&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Non seulement la séance est publique, mais de plus vous êtes tous cordialement invité à y assister. Le contenu est détaillé dans la suite du billet.&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Titre de la thèse :&lt;/strong&gt; Détection de dérivation de texte&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Mots-clés :&lt;/strong&gt; détection de dérivation, révisions, plagiat, approche par signature, mesures de similarité, recherche d'information&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Résumé de la thèse :&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;L'Internet permet la production et la diffusion de contenu sans effort et à grande vitesse. Cela pose la question du contrôle de leur origine. Ce travail s'intéresse à la détection des liens de dérivation entre des textes. Un lien de dérivation unit un texte dérivé et les textes préexistants à partir desquels il a été écrit. Nous nous sommes concentré sur la tâche d'identification des textes dérivés étant donné un texte source, et ce pour différentes formes de dérivation. Notre première contribution consiste en la définition d'un cadre théorique posant les concepts de la dérivation ainsi qu'un modèle mulitidimensionnel cadrant les différentes formes de dérivation. Nous avons ensuite mis en place un cadre expérimental constitué d'une infrastructure logicielle libre, de corpus d'évaluation et d'un protocole expérimental inspiré de la RI. Les corpus Piithie et Wikinews que nous avons développé sont à notre connaissance les seuls corpus en français pour la détection de dérivation. Finalement, nous avons exploré différentes méthodes de détection fondées sur l'approche par signature. Nous avons notamment introduit les notions de singularité et d'invariance afin de guider le choix des descripteurs utilisés pour la modélisation des textes en vue de leur comparaison.
Nos résultats montrent que le choix motivé des descripteurs, linguistiques notamment, permet de réduire la taille de la modélisation des textes, et par conséquence des coûts de la méthode, tout en offrant des performances comparables à l'approche état de l'art beaucoup plus volumineuse.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Jury de la thèse :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.limsi.fr/Individu/yvon/mysite/mysite.php&quot;&gt;M. François Yvon&lt;/a&gt;, Professeur à l'Université de Paris Sud 11 (rapporteur)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.univ-avignon.fr/en/research/annuaire-chercheurs/membrestruc/personnel/bellot-patrice.html&quot;&gt;M. Patrice Bellot&lt;/a&gt;, Maître de conférences à l'Université d'Avignon (rapporteur)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.irit.fr/~Josiane.Mothe/&quot;&gt;Mme Josiane Mothe&lt;/a&gt;, Professeur à l'Institut Universitaire de Formation des Maître de Toulouse (examinateur)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.syllabs.com/perso/loupy/cv/&quot;&gt;M. Claude de Loupy&lt;/a&gt;, Dirigeant et co-fondateur de Syllabs (invité)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.bdaille.fr/&quot;&gt;Mme Béatrice Daille&lt;/a&gt;, Professeur à l'Université de Nantes (directrice de thèse)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://e.nicolas.hernandez.free.fr/&quot;&gt;M. Nicolas Hernandez&lt;/a&gt;, Maître de conférences à l'Université de Nantes (encadrant)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Publications :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Poulard, F., N. Hernandez and B. Daille. 2011, &lt;em&gt;Detecting derivatives using specific and invariant descriptors&lt;/em&gt;, Proceedings of the 12th International Conference on Computational Linguistics and Intelligent Text Processing (CICLing 2011), Tokyo, Japan.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Hernandez, N., F. Poulard, M. Vernier and J. Rocheteau. 2010, &lt;em&gt;Building a French-speaking community around UIMA, gathering research, education and industrial partners, mainly in Natural Language Processing and Speech Recognizing domains&lt;/em&gt;, Workshop Abstracts LREC 2010 Workshop 'New Challenges for NLP Frameworks', La Valleta Malte, p.64. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00481459/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00481459/en/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F., N. Hernandez, S. D. Afantenos and B. Daille. 2010, &lt;em&gt;Evaluation de descripteurs statistiques et linguistiques pour la détection de dérivation de texte&lt;/em&gt;, Document numérique, 13, 3/2010, p.69-93. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00554351/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00554351/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Dejean, C., M. Fortun, C. Massot, V. Pottier, F. Poulard and M. Vernier. 2010, &lt;em&gt;Un  étiqueteur de rôles grammaticaux libre pour le français intégré à Apache UIMA&lt;/em&gt;, Actes de la 17e Conférence sur le Traitement Automatique des Langues Naturelles 17e Conférence sur le Traitement Automatique des Langues Naturelles, Montréal, Canada. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00493847/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00493847/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F., S. D. Afantenos and N. Hernandez. 2009, &lt;em&gt;Nouvelles considérations pour la détection de réutilisation de texte&lt;/em&gt;, Actes de la 16ème conférence sur le Traitement Automatique des Langues Naturelles, Senlis France, p.67. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00401072/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00401072/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Hernandez, N., F. Poulard, S. Afantenos, M. Vernier J.  Rocheteau.  2009, &lt;em&gt;Apache UIMA pour le Traitement Automatique des Langues&lt;/em&gt;, 16ème conférence sur le Traitement Automatique des Langues Naturelles (TALN'09) - Session Démonstration. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00423728/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00423728/en/&lt;/a&gt;,&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F., T. Waszak, N. Hernandez and P. Bellot. 2008, &lt;em&gt;Repérage de citations, classification des styles de discours rapporté et identification des constituants citationnels en écrits journalistiques&lt;/em&gt;, Actes de la 15e Conférence sur le Traitement Automatique des Langues Naturelles Traitement Automatique des Langues Naturelles, Avignon, France, p.450-459. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00401011/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00401011/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F. 2008, &lt;em&gt;Analyse quantitative et qualitative de citations extraites d'un corpus journalistique&lt;/em&gt;, Actes de la 12e édition de RECITAL Rencontre des Etudiants-Chercheurs en Informatique et en Traitement Automatique des Langues (RÉCITAL), Avignon France, p.101-110. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00401001/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00401001/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>I'm going to defend my PhD thesis !</title>
    <link>http://fabienpoulard.info/post/2011/03/17/I-m-going-to-defend-my-PhD-thesis-%21</link>
    <guid isPermaLink="false">urn:md5:b40b3eff2a46392815fffb7149d3ff71</guid>
    <pubDate>Thu, 17 Mar 2011 16:30:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>these</category>    
    <description>&lt;p&gt;I will defend my PhD thesis on &lt;strong&gt;March, 24th 2011 at 9:30 am&lt;/strong&gt; in &lt;a href=&quot;http://www.openstreetmap.org/?mlat=47.237051&amp;amp;mlon=-1.552404&amp;amp;zoom=18&amp;amp;layers=M&quot;&gt;room 3 of LINA&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Not only is the defense public, but you are welcome to attend. The thesis content is detailed in the rest of this bill.&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Title:&lt;/strong&gt; Detecting textual derivatives&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Keywords:&lt;/strong&gt; detection of derivation, revisions, plagiarism, signature approach, similarity metrics, information retrieval&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Abstract:&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;Thanks to the Internet, the production and publication of content is possible with ease and speed. This possibility raises the issue of controling the origins of this content. This work focuses on detecting derivation links between texts. A derivation link associates a derivative text and the pre-existing texts from which it was written. We focused on the task of identifying derivative texts given a source text for various forms of derivation. Our first contribution is the definition of a theoretical framework defines the concept of derivation as well as a model framing the different forms of derivation. Then, we set up an experimental framework consisting of free software tools, evaluation corpora and evaluation metrics based on IR. The Piithie and Wikinews corpora we have developed are to our knowledge the only ones in French for the detection of derivation links. Finally, we explored different methods of detection based on the signature-based approach. In particular, we have introduced the notions of specificity and invariance to guide the choice of descriptors used to modelize the texts in the expectation of their comparison. Our results show that the choice of motivated descriptors, including linguistically motivated ones, can reduce the size of the modelization of texts, and therefore the cost of the method, while offering performances comparable to the much more voluminous state of the art approach.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Thesis jury:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.limsi.fr/Individu/yvon/mysite/mysite.php&quot;&gt;M. François Yvon&lt;/a&gt;, Professor at Université de Paris Sud 11 (rapporteur)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.univ-avignon.fr/en/research/annuaire-chercheurs/membrestruc/personnel/bellot-patrice.html&quot;&gt;M. Patrice Bellot&lt;/a&gt;, Assistant professor at Université d'Avignon (rapporteur)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.irit.fr/~Josiane.Mothe/&quot;&gt;Mme Josiane Mothe&lt;/a&gt;, Professor at Institut Universitaire de Formation des Maître de Toulouse (examiner)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.syllabs.com/perso/loupy/cv/&quot;&gt;M. Claude de Loupy&lt;/a&gt;, Director and co-founder of Syllabs (guest)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.bdaille.fr/&quot;&gt;Mme Béatrice Daille&lt;/a&gt;, Professor at Université de Nantes (director)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://e.nicolas.hernandez.free.fr/&quot;&gt;M. Nicolas Hernandez&lt;/a&gt;, Assistant professor at Université de Nantes (supervisor)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Publications:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Poulard, F., N. Hernandez and B. Daille. 2011, &lt;em&gt;Detecting derivatives using specific and invariant descriptors&lt;/em&gt;, Proceedings of the 12th International Conference on Computational Linguistics and Intelligent Text Processing (CICLing 2011), Tokyo, Japan.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Hernandez, N., F. Poulard, M. Vernier and J. Rocheteau. 2010, &lt;em&gt;Building a French-speaking community around UIMA, gathering research, education and industrial partners, mainly in Natural Language Processing and Speech Recognizing domains&lt;/em&gt;, Workshop Abstracts LREC 2010 Workshop 'New Challenges for NLP Frameworks', La Valleta Malte, p.64. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00481459/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00481459/en/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F., N. Hernandez, S. D. Afantenos and B. Daille. 2010, &lt;em&gt;Evaluation de descripteurs statistiques et linguistiques pour la détection de dérivation de texte&lt;/em&gt;, Document numérique, 13, 3/2010, p.69-93. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00554351/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00554351/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Dejean, C., M. Fortun, C. Massot, V. Pottier, F. Poulard and M. Vernier. 2010, &lt;em&gt;Un  étiqueteur de rôles grammaticaux libre pour le français intégré à Apache UIMA&lt;/em&gt;, Actes de la 17e Conférence sur le Traitement Automatique des Langues Naturelles 17e Conférence sur le Traitement Automatique des Langues Naturelles, Montréal, Canada. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00493847/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00493847/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F., S. D. Afantenos and N. Hernandez. 2009, &lt;em&gt;Nouvelles considérations pour la détection de réutilisation de texte&lt;/em&gt;, Actes de la 16ème conférence sur le Traitement Automatique des Langues Naturelles, Senlis France, p.67. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00401072/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00401072/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Hernandez, N., F. Poulard, S. Afantenos, M. Vernier J.  Rocheteau.  2009, &lt;em&gt;Apache UIMA pour le Traitement Automatique des Langues&lt;/em&gt;, 16ème conférence sur le Traitement Automatique des Langues Naturelles (TALN'09) - Session Démonstration. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00423728/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00423728/en/&lt;/a&gt;,&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F., T. Waszak, N. Hernandez and P. Bellot. 2008, &lt;em&gt;Repérage de citations, classification des styles de discours rapporté et identification des constituants citationnels en écrits journalistiques&lt;/em&gt;, Actes de la 15e Conférence sur le Traitement Automatique des Langues Naturelles Traitement Automatique des Langues Naturelles, Avignon, France, p.450-459. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00401011/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00401011/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Poulard, F. 2008, &lt;em&gt;Analyse quantitative et qualitative de citations extraites d'un corpus journalistique&lt;/em&gt;, Actes de la 12e édition de RECITAL Rencontre des Etudiants-Chercheurs en Informatique et en Traitement Automatique des Langues (RÉCITAL), Avignon France, p.101-110. &lt;a href=&quot;http://hal.archives-ouvertes.fr/hal-00401001/en/&quot;&gt;http://hal.archives-ouvertes.fr/hal-00401001/en/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Visualiser un espace à plusieurs dimensions en 3D</title>
    <link>http://fabienpoulard.info/post/2011/03/17/Visualiser-un-espace-%C3%A0-plusieurs-dimensions-en-3D</link>
    <guid isPermaLink="false">urn:md5:105d6b741780cc2a77ab3047731a4c56</guid>
    <pubDate>Thu, 17 Mar 2011 00:03:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>clustering</category><category>matplotlib</category><category>nlp</category><category>python</category><category>scikit-learn</category>    
    <description>&lt;p&gt;L'&lt;a href=&quot;http://fr.wikipedia.org/wiki/Analyse_en_composantes_principales&quot; hreflang=&quot;fr&quot;&gt;analyse en composantes principales&lt;/a&gt; (ACP) permet de calculer les hyperplans d'un espace vectoriel tel qu'une projection sur ces plans conserve un maximum d'entropie. Cette approche permet entre autres choses de projeter des espaces ayant un très grand nombre de dimensions dans des espaces de dimensions réduites tout en limitant la perte d'information.&lt;/p&gt;


&lt;p&gt;L'utilisation combinée de &lt;a href=&quot;http://scikit-learn.sourceforge.net/&quot; hreflang=&quot;en&quot;&gt;scikit-learn&lt;/a&gt; et de &lt;a href=&quot;http://matplotlib.sourceforge.net/&quot; hreflang=&quot;en&quot;&gt;matplotlib&lt;/a&gt; permet de produire très rapidement des réductions de dimension et de les visualiser. J'utilise ces bibliothèques pour visualiser dans un espace à 2 ou 3 dimensions des espaces vectoriels correspondant à des représentations de documents à l'aide de traits particuliers.&lt;/p&gt;    &lt;p&gt;Je travaille actuellement sur le &lt;a href=&quot;http://www.ttc-project.eu/&quot; hreflang=&quot;en&quot;&gt;projet TTC&lt;/a&gt; au sein de mon équipe. Je suis chargé de développer un classifieur de pages Web selon leurs intentions de communication. S'il existe bon nombre de travaux sur la classification des documents Web, dans notre cas nous cherchons une approche indépendante de la langue. Nous travaillons en effet sur sept langues différentes plus ou moins éloignées (français, anglais, allemand, espagnol, letton, russe et chinois). Voilà le contexte et le problème posé.&lt;/p&gt;


&lt;p&gt;J'explore un certain nombre de traits qui pourraient s'avérer pertinent pour ladite tâche (URL, structure HTML, n-grammes caractères...). Il est cependant compliqué d'évaluer qualitativement si les traits retenus permettent de différencier les &amp;quot;intentions de communication&amp;quot; auxquelles nous nous intéressons. Une manière très subjective, mais également très efficace, de mesurer cette capacité est de visualiser les clusters formés par les documents dans l'espace vectoriel défini par nos traits. Chaque document est représenté par un vecteur des valeurs correspondant aux différents traits sélectionnés. Ces traits sont cependant très nombreux et l'espace vectoriel correspondant ne peut pas être directement représenté sous forme graphique.&lt;/p&gt;


&lt;p&gt;Afin d'aisément visualiser les documents dans ces espaces vectoriels j'effectue une projection sur seulement trois dimensions et je visualise le résultat sous forme d'un graphique de type &lt;a href=&quot;http://fr.wikipedia.org/wiki/Nuage_de_points&quot; hreflang=&quot;en&quot;&gt;&amp;quot;nuage de points&amp;quot;&lt;/a&gt;. Les trois combinaisons sont en réalité des combinaisons algébriques de l'ensemble des dimensions de mon espace vectoriel obtenues par une &lt;a href=&quot;http://fr.wikipedia.org/wiki/Analyse_en_composantes_principales&quot; hreflang=&quot;fr&quot;&gt;approche en composantes principales&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Il est assez aisé de mettre en œuvre une telle approche avec &lt;a href=&quot;http://scikit-learn.sourceforge.net/&quot; hreflang=&quot;en&quot;&gt;scikit-learn&lt;/a&gt; :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Importation de l'approche par composantes principales&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; scikits.&lt;span style=&quot;color: black;&quot;&gt;learn&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;pca&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; PCA
 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# On utilise un ensemble de données exemple classique : Iris&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; scikits.&lt;span style=&quot;color: black;&quot;&gt;learn&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; datasets
iris = datasets.&lt;span style=&quot;color: black;&quot;&gt;load_iris&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Préparation de la méthode PCA pour une projection sur 3 dimensions&lt;/span&gt;
pca = PCA&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;n_components=&lt;span style=&quot;color: #ff4500;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Calcul de la projection à partir des données exemples&lt;/span&gt;
pca.&lt;span style=&quot;color: black;&quot;&gt;fit&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;iris.&lt;span style=&quot;color: black;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Application de la projection aux données&lt;/span&gt;
newdata = pca.&lt;span style=&quot;color: black;&quot;&gt;transform&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;iris.&lt;span style=&quot;color: black;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;La variable &lt;em&gt;newdata&lt;/em&gt; contient alors une projection de nos données sur le nouvel espace vectoriel en 3 dimensions. Je peux ainsi visualiser les documents dans ce nouvel espace en utilisant &lt;em&gt;Pylab&lt;/em&gt; issue de &lt;a href=&quot;http://matplotlib.sourceforge.net/&quot; hreflang=&quot;en&quot;&gt;matplotlib&lt;/a&gt; :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Utilisation de Pylab et de mplot3d intégré à matplotlib&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; pylab &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;as&lt;/span&gt; pl
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; mpl_toolkits.&lt;span style=&quot;color: black;&quot;&gt;mplot3d&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;axes3d&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;as&lt;/span&gt; p3
 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Création de la figure dans laquelle nous allons représenté notre nuage de points&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# qui sera composée de 3 dimensions (Axes3D)&lt;/span&gt;
fig=pl.&lt;span style=&quot;color: black;&quot;&gt;figure&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
ax = p3.&lt;span style=&quot;color: black;&quot;&gt;Axes3D&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;fig&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Les données Iris se répartissent entre 3 classes (0, 1 et 2), nous allons coloré chacune de&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# ces classes différemment afin de les visualiser&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Nous utilisons également le nom réel (iris.target_names) des classes dans la légende&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; color, classe, nom_classe &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;zip&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;rgb&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;, iris.&lt;span style=&quot;color: black;&quot;&gt;target_names&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# newdata[iris.target==classe,0] permet de récupérer la première colonne (0) de la &lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# sous-matrice correspondant aux instances de la classe &amp;quot;classe&amp;quot;&lt;/span&gt;
	ax.&lt;span style=&quot;color: black;&quot;&gt;scatter3D&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;newdata&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;iris.&lt;span style=&quot;color: black;&quot;&gt;target&lt;/span&gt;==classe,&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;, 
	  newdata&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;iris.&lt;span style=&quot;color: black;&quot;&gt;target&lt;/span&gt;==classe,&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;, newdata&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;iris.&lt;span style=&quot;color: black;&quot;&gt;target&lt;/span&gt;==classe,&lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;, 
	  c=color, label=nom_classe&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# On ajoute les données à la figure et on dessine le tout&lt;/span&gt;
fig.&lt;span style=&quot;color: black;&quot;&gt;add_axes&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;ax&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
pl.&lt;span style=&quot;color: black;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Et voici le résultat :&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/Python/iris-pca-3d.png&quot; title=&quot;Projection 3D des instances de la base iris&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/Python/.iris-pca-3d_m.jpg&quot; alt=&quot;Projection 3D des instances de la base iris&quot; style=&quot;float:left; margin: 0 1em 1em 0;&quot; title=&quot;Projection 3D des instances de la base iris, mar. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;La projection en 3D permet très facilement (et très subjectivement) d'identifier les trois clusters correspondant aux trois classes et d'ainsi valider les traits retenus pour représenter les instances.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Cours de TALN (3) : n-grammes</title>
    <link>http://fabienpoulard.info/post/2011/01/12/Cours-de-TALN-%283%29-%3A-n-grammes</link>
    <guid isPermaLink="false">urn:md5:35284590c666ed40779bca513ee05080</guid>
    <pubDate>Wed, 12 Jan 2011 00:00:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>enseignement</category><category>exercice</category><category>markov</category><category>n-grammes</category><category>python</category><category>visualisation</category>    
    <description>&lt;p&gt;Voilà le troisième et dernier opus du cours dont je parlais &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Enseignement-du-TAL&quot;&gt;ici&lt;/a&gt;. J'avais présenté le premier opus &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Cours-de-TALN-%281%29-%3A-expressions-rationnelles&quot;&gt;ici&lt;/a&gt; et le second &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/09/Cours-de-TALN-%282%29-%3A-morphologie-et-%C3%A9tiquetage-des-r%C3%B4les-grammaticaux&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;L'intégralité du cours et des ressources nécessaires sont disponibles &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/&quot;&gt;ici&lt;/a&gt;, ce qui inclut notamment &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/3-tdtp-ngrammes.pdf&quot; hreflang=&quot;fr&quot;&gt;le support de cours&lt;/a&gt;. Le travail intègre les éléments vus précédemment et les étudiants exploitent encore &lt;a href=&quot;http://fabienpoulard.info/post/2010/03/13/Corpus-des-discours-de-Nicolas-Sarkozy-%28M%C3%80J%29&quot;&gt;le corpus des discours de Nicolas Sarkozy&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;J'ai revu les objectifs à la baisse. J'ai essayé de recentrer un peu le contenu sur la partie théorique étant donné que celle-ci est beaucoup plus présente dans cette partie (&lt;a href=&quot;http://fr.wikipedia.org/wiki/Propri%C3%A9t%C3%A9_de_Markov&quot; hreflang=&quot;fr&quot;&gt;propriété de Markov&lt;/a&gt; et &lt;a href=&quot;http://fr.wikipedia.org/wiki/Probabilit%C3%A9_conditionnelle&quot;&gt;probabilités conditionnelles&lt;/a&gt;). Je ne délaisse pour autant pas les exercices de mise en pratique qui me semblent fondamentaux pour un module de &amp;quot;découverte&amp;quot;.&lt;/p&gt;


&lt;p&gt;À l'issue de cette dernière séance j'espère que les étudiants auront compris :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le principe de la propriété de Markov ;&lt;/li&gt;
&lt;li&gt;comment celle-ci est mise en œuvre au travers des n-grammes ;&lt;/li&gt;
&lt;li&gt;l'importance du contexte dans la compréhension du texte ;&lt;/li&gt;
&lt;li&gt;ce qu'on entend derrière un &amp;quot;modèle de langage&amp;quot;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Et j'espère encore une fois qu'ils auront pris du plaisir dans mon cours... Normalement ils devraient être en mesure de créer de nouveaux nuages de mots en utilisant cette fois des filtrages un peu plus élaborés. Voici ceux que j'ai généré à partir de l'énoncé en utilisant l'&lt;a href=&quot;http://worditout.com/word-cloud/make-a-new-one&quot;&gt;outil WordItOut&lt;/a&gt; et mon &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/extraction-trigrammes.py&quot;&gt;script d'extraction&lt;/a&gt; :&lt;/p&gt;


&lt;p&gt;Nuage des &lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/trigrams-sarkozy.txt&quot;&gt;100 trigrammes mots les plus fréquents des discours de Nicolas Sarkozy&lt;/a&gt; :
&lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/clouds-sarkozy-trigrams.png&quot; title=&quot;Nuage des 100 trigrammes mots les plus fréquents&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/Enseignements/.clouds-sarkozy-trigrams_m.jpg&quot; alt=&quot;Nuage des 100 trigrammes mots les plus fréquents&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Nuage des 100 trigrammes mots les plus fréquents, janv. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Nuage des &lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/trigrams-sarkozy-stopwords.txt&quot;&gt;100 trigrammes mots les plus fréquents des discours de Nicolas Sarkozy après suppression des mots ouils&lt;/a&gt; :
&lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/clouds-sarkozy-trigrams-stopwords.png&quot; title=&quot;Nuage des 100 trigrammes mots les plus fréquents, mots outils exclus&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/Enseignements/.clouds-sarkozy-trigrams-stopwords_m.jpg&quot; alt=&quot;Nuage des 100 trigrammes mots les plus fréquents, mots outils exclus&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Nuage des 100 trigrammes mots les plus fréquents, mots outils exclus, janv. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Nuage des &lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/trigrams-sarkozy-nominaux.txt&quot;&gt;100 trigrammes mots les plus fréquents des discours de Nicolas Sarkozy, restriction aux noms et adjectifs uniquement&lt;/a&gt; :
&lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/clouds-sarkozy-trigrams-nominaux.png&quot; title=&quot;Nuage des 100 trigrammes mots (noms et adjectifs) les plus fréquents&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/Enseignements/.clouds-sarkozy-trigrams-nominaux_m.jpg&quot; alt=&quot;Nuage des 100 trigrammes mots (noms et adjectifs) les plus fréquents&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Nuage des 100 trigrammes mots (noms et adjectifs) les plus fréquents, janv. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Nuage des &lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/trigrams-sarkozy-verbaux.txt&quot;&gt;100 trigrammes mots les plus fréquents des discours de Nicolas Sarkozy, restriction aux verbes et adverbes uniquement&lt;/a&gt; :
&lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/clouds-sarkozy-trigrams-verbaux.png&quot; title=&quot;Nuage des 100 trigrammes mots (verbes et adverbes) les plus fréquents&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/Enseignements/.clouds-sarkozy-trigrams-verbaux_m.jpg&quot; alt=&quot;Nuage des 100 trigrammes mots (verbes et adverbes) les plus fréquents&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Nuage des 100 trigrammes mots (verbes et adverbes) les plus fréquents, janv. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Cours de TALN (2) : morphologie et étiquetage des rôles grammaticaux</title>
    <link>http://fabienpoulard.info/post/2011/01/09/Cours-de-TALN-%282%29-%3A-morphologie-et-%C3%A9tiquetage-des-r%C3%B4les-grammaticaux</link>
    <guid isPermaLink="false">urn:md5:0a7ad84c9e1f9ade8a91b0b8629f6b9f</guid>
    <pubDate>Sun, 09 Jan 2011 22:59:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>enseignement</category><category>POS tagging</category><category>python</category><category>treetagger</category>    
    <description>&lt;p&gt;Voilà le second opus du cours dont je parlais &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Enseignement-du-TAL&quot;&gt;ici&lt;/a&gt;. J'avais présenté le premier opus &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Cours-de-TALN-%281%29-%3A-expressions-rationnelles&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;L'intégralité du cours et des ressources nécessaires est disponible &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/&quot;&gt;ici&lt;/a&gt;, ce qui inclut :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/2-tdtp-morphologie.pdf&quot; hreflang=&quot;fr&quot;&gt;le support de cours&lt;/a&gt; ;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/la-cigale-et-la-fourmi.txt&quot; hreflang=&quot;fr&quot;&gt;deux&lt;/a&gt; &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/le-corbeau-et-le-renard.txt&quot; hreflang=&quot;fr&quot;&gt;fables&lt;/a&gt; de La Fontaine, découpées en mots, pour expérimenter l'analyse morpho-syntaxique ;&lt;/li&gt;
&lt;li&gt;un &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/extraction-noms-sarkozy.py&quot;&gt;script python&lt;/a&gt; pour extraire les noms communs du corpus des discours de Nicolas Sarkozy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;La plupart des ressources utilisées lors du corpus précédent seront réexploitées dans ce cours. Les étudiants peuvent ainsi valoriser les connaissances précédemment acquises.&lt;/p&gt;


&lt;p&gt;À l'issue de cette seconde séance mon objectif est d'avoir enseigné aux étudiants :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;des connaissances suffisantes à la compréhension de l'algorithme de Porter ;&lt;/li&gt;
&lt;li&gt;l'intérêt de l'analyse morphologique pour la compréhension des textes ;&lt;/li&gt;
&lt;li&gt;l'utilisation de &lt;a href=&quot;http://www.ims.uni-stuttgart.de/projekte/corplex/TreeTagger/DecisionTreeTagger.html&quot;&gt;Tree Tagger&lt;/a&gt;, un étiqueteur de rôles grammaticaux ;&lt;/li&gt;
&lt;li&gt;l'intérêt de la catégorisation des mots selon leurs rôles grammaticaux.&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Python et Tree Tagger</title>
    <link>http://fabienpoulard.info/post/2011/01/09/Python-et-Tree-Tagger</link>
    <guid isPermaLink="false">urn:md5:922078cf50e7ef76c55588f6b49ccae9</guid>
    <pubDate>Sun, 09 Jan 2011 19:30:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>POS tagging</category><category>python</category><category>treetagger</category>    
    <description>&lt;p&gt;&lt;a href=&quot;http://www.ims.uni-stuttgart.de/projekte/corplex/TreeTagger/DecisionTreeTagger.html&quot; hreflang=&quot;en&quot;&gt;Tree Tagger&lt;/a&gt; est un outil d'étiquetage des rôles grammaticaux disponible pour plusieurs plateformes et pour plusieurs langues.
Si sa &lt;a href=&quot;http://www.ims.uni-stuttgart.de/~schmid/Tagger-Licence&quot;&gt;licence&lt;/a&gt; n'est pas libre, il peut être utilisé dans un cadre de recherche ou bien pour l'éducation.&lt;/p&gt;


&lt;p&gt;Il existe &lt;a href=&quot;http://perso.limsi.fr/pointal/?id=dev:treetaggerwrapper&quot; hreflang=&quot;en&quot;&gt;un projet de wrapper Python&lt;/a&gt; pour cet outil qui pourrait m'être utile pour &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Enseignement-du-TAL&quot; hreflang=&quot;en&quot;&gt;mon cours de TALN&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;Pour utiliser le wrapper, il faut tout d'abord installer Tree Tagger. Pour Linux et le français, la démarche est la suivante :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Télécharger l'&lt;a href=&quot;ftp://ftp.ims.uni-stuttgart.de/pub/corpora/tree-tagger-linux-3.2.tar.gz&quot;&gt;archive&lt;/a&gt; contenant l'outil ;&lt;/li&gt;
&lt;li&gt;La décompresser dans un répertoire dédié ;&lt;/li&gt;
&lt;li&gt;Télécharger &lt;a href=&quot;ftp://ftp.ims.uni-stuttgart.de/pub/corpora/french-par-linux-3.2-utf8.bin.gz&quot;&gt;le fichier de paramètre pour le français (utf-8)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Le décompresser et le déplacer dans un répertoire &lt;em&gt;lib&lt;/em&gt; à la racine du répertoire contenant Tree Tagger en le renommant &lt;em&gt;french.par&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Vous pouvez alors tester le bon fonctionnement de l'étiqueteur en vous plaçant dans ledit répertoire, puis :&lt;/p&gt;

&lt;pre&gt;
shell$ echo -e &amp;quot;Ceci\nest\nun\ntrès\ncourt\ntexte\nà\nétiqueter\n.&amp;quot;\
  |bin/tree-tagger -token -lemma -quiet lib/french.par
Ceci	PRO:DEM	ceci
est	VER:pres	être
un	DET:ART	un
très	ADV	très
court	ADJ	court
texte	NOM	texte
à	PRP	à
étiqueter	VER:infi	étiqueter
.	SENT	.
&lt;/pre&gt;


&lt;p&gt;La signification des étiquettes est expliquée &lt;a href=&quot;http://www.ims.uni-stuttgart.de/~schmid/french-tagset.html&quot; hreflang=&quot;en&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Une fois l'étiqueteur installé sur le système, il faut récupérer &lt;a href=&quot;http://perso.limsi.fr/pointal/?id=dev:treetaggerwrapper&quot; hreflang=&quot;en&quot;&gt;le wrapper Python&lt;/a&gt;. Il n'en existe pas de version directement téléchargeable à ma connaissance. Il faut donc le récupérer depuis &lt;a href=&quot;http://sourcesup.cru.fr/scm/?group_id=647&quot; hreflang=&quot;fr&quot;&gt;le dépôt du projet&lt;/a&gt;  par subversion :&lt;/p&gt;

&lt;pre&gt;
svn co https://subversion.cru.fr/ttpw/trunk/treetaggerwrapper.py
&lt;/pre&gt;


&lt;p&gt;La version présente sur le dépôt au moment de la rédaction de cet billet n'est pas fonctionnelle. J'ai remonté &lt;a href=&quot;https://sourcesup.cru.fr/tracker/index.php?func=detail&amp;amp;aid=7399&amp;amp;group_id=647&amp;amp;atid=2232&quot; hreflang=&quot;en&quot;&gt;un bug&lt;/a&gt; à ce sujet à l'auteur. Il suffit d'appliquer &lt;a href=&quot;https://sourcesup.cru.fr/tracker/download.php/647/2232/7399/958/popen-issue.patch&quot;&gt;le patch&lt;/a&gt; que j'ai proposé pour rendre le wrapper fonctionnel.&lt;/p&gt;


&lt;p&gt;L'utilisation est ensuite assez simple, il suffit d'importer le module dans le code Python, puis de préciser la langue (&lt;em&gt;TAGLANG&lt;/em&gt;) et le répertoire d'installation (&lt;em&gt;TAGDIR&lt;/em&gt;). Par défaut, le wrapper est configuré pour exploiter l'encodage &lt;em&gt;latin1&lt;/em&gt;. Le fichier de paramètre pour le français est en &lt;em&gt;utf-8&lt;/em&gt;, tout comme mon environnement de développement. J'ai donc également précisé que je voulais utiliser cet encodage (&lt;em&gt;TAGINENC&lt;/em&gt; et &lt;em&gt;TAGOUTENC&lt;/em&gt;) :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; treetaggerwrapper
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Construction et configuration du wrapper&lt;/span&gt;
tagger = treetaggerwrapper.&lt;span style=&quot;color: black;&quot;&gt;TreeTagger&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;TAGLANG=&lt;span style=&quot;color: #483d8b;&quot;&gt;'fr'&lt;/span&gt;,TAGDIR=&lt;span style=&quot;color: #483d8b;&quot;&gt;'/tmp'&lt;/span&gt;,
  TAGINENC=&lt;span style=&quot;color: #483d8b;&quot;&gt;'utf-8'&lt;/span&gt;,TAGOUTENC=&lt;span style=&quot;color: #483d8b;&quot;&gt;'utf-8'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Utilisation&lt;/span&gt;
tags = tagger.&lt;span style=&quot;color: black;&quot;&gt;TagText&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Ceci est un très court texte à étiqueter.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; tags&lt;/pre&gt;


&lt;p&gt;Le résultat du traitement est une liste des triplets mot, &lt;a href=&quot;http://fr.wikipedia.org/wiki/%C3%89tiquetage_grammatical&quot; hreflang=&quot;fr&quot;&gt;rôle grammatical&lt;/a&gt; et &lt;a href=&quot;http://fr.wikipedia.org/wiki/Lemme_(linguistique)&quot; hreflang=&quot;fr&quot;&gt;lemme&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
[u'Ceci\tPRO:DEM\tceci', u'est\tVER:pres\t\xeatre', 
 u'un\tDET:ART\tun', u'tr\xe8s\tADV\ttr\xe8s', 
 u'court\tADJ\tcourt', u'texte\tNOM\ttexte', u'\xe0\tPRP\t\xe0',
 u'\xe9tiqueter\tVER:infi\t\xe9tiqueter', u'.\tSENT\t.']
&lt;/pre&gt;


&lt;p&gt;Voici un petit morceau de code qui permet de structurer un petit peu mieux cette sortie :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;class&lt;/span&gt; TreeTaggerWord:
  &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #0000cd;&quot;&gt;__init__&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;self&lt;/span&gt;, triplet&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
    &lt;span style=&quot;color: #008000;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;word&lt;/span&gt;,&lt;span style=&quot;color: #008000;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;postag&lt;/span&gt;,&lt;span style=&quot;color: #008000;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;lemma&lt;/span&gt; = triplet&lt;/pre&gt;
&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; formatTTG&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;output&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;:
  words = &lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;
  &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; w &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; output:
    words.&lt;span style=&quot;color: black;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;TreeTaggerWord&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;w.&lt;span style=&quot;color: black;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
  &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; words&lt;/pre&gt;


&lt;p&gt;Les données en sortie sont alors accessibles comme des attributs de la classe &lt;em&gt;TreeTaggerWord&lt;/em&gt; :&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; treetaggerwrapper
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Construction et configuration du wrapper&lt;/span&gt;
tagger = treetaggerwrapper.&lt;span style=&quot;color: black;&quot;&gt;TreeTagger&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;TAGLANG=&lt;span style=&quot;color: #483d8b;&quot;&gt;'fr'&lt;/span&gt;,TAGDIR=&lt;span style=&quot;color: #483d8b;&quot;&gt;'/tmp'&lt;/span&gt;,
  TAGINENC=&lt;span style=&quot;color: #483d8b;&quot;&gt;'utf-8'&lt;/span&gt;,TAGOUTENC=&lt;span style=&quot;color: #483d8b;&quot;&gt;'utf-8'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Utilisation&lt;/span&gt;
tags = tagger.&lt;span style=&quot;color: black;&quot;&gt;TagText&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Ceci est un très court texte à étiqueter.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
data = formatTTG&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;tags&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; data&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;word&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; data&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;postag&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; data&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;lemma&lt;/span&gt;&lt;/pre&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>PPDA accusé de plagiat... une opportunité pour ma thèse ?</title>
    <link>http://fabienpoulard.info/post/2011/01/06/PPDA-accus%C3%A9-de-plagiat...-une-opportunit%C3%A9-pour-ma-th%C3%A8se</link>
    <guid isPermaLink="false">urn:md5:0604460dbde610b065748e59579d1d1c</guid>
    <pubDate>Thu, 06 Jan 2011 14:05:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>plagiat</category><category>these</category>    
    <description>&lt;p&gt;C'est l'un des sujets chauds de cette rentrée hivernale : il semblerait que le livre à paraître sur &lt;a href=&quot;http://fr.wikipedia.org/wiki/Ernest_Hemingway&quot; hreflang=&quot;fr&quot;&gt;Hemingway&lt;/a&gt; de &lt;a href=&quot;http://fr.wikipedia.org/wiki/Patrick_Poivre_d%27Arvor&quot; hreflang=&quot;fr&quot;&gt;PPDA&lt;/a&gt; publié par les &lt;a href=&quot;http://www.arthaud.fr&quot; hreflang=&quot;fr&quot;&gt;Éditions Arthaud&lt;/a&gt; soit un &lt;em&gt;plagiat&lt;/em&gt;. C'est le quotidien &lt;a href=&quot;http://www.lexpress.fr/culture/livre/le-plagiat-de-ppda_949676.html&quot; hreflang=&quot;fr&quot;&gt;L'Express&lt;/a&gt; qui a levé le lièvre, rapidement relayé par &lt;a href=&quot;http://news.google.fr/news/story?pz=1&amp;amp;cf=all&amp;amp;cf=all&amp;amp;ncl=dW-ibCUnrS-3CZMWRVqz4wwrHgTEM&quot;&gt;bien d'autres&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Cette histoire serait une très belle illustration pour conclure ma thèse sur la dérivation de texte ! Si PPDA ou les éditions d'Arthaud voulaient bien m'envoyer une version du livre, je pourrais la confronter à l'aide de mes algorithmes sur la biographie signée Peter Griffin et parue en français aux éditions Gallimard. Mais parle-t-on bien de plagiat et qu'est-ce que cela signifie ?&lt;/p&gt;    &lt;h2&gt;Qu'est-ce que le plagiat ?&lt;/h2&gt;


&lt;p&gt;Le &lt;a href=&quot;http://atilf.atilf.fr/&quot;&gt;TLFI&lt;/a&gt; (Trésor de la Langue Française Informatisée) définit le plagiat comme &lt;em&gt;l'action d'emprunter à un ouvrage original et à son auteur des éléments dont on s'attribue abusivement la paternité en les reproduisant, avec plus ou moins de fidélité, dans une œuvre que l'on présente comme personnelle&lt;/em&gt;. Le plagiat  est condamné par la morale en ce que le plagiaire profite d'une gloire indue qui aurait dû profiter à l'auteur original. Ce qui représentait pour Diderot le &lt;em&gt;délit le plus grave qui puisse se trouver dans la République des Lettres&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;En réalité, le plagiat est un délit moral qui n'a pas forcément de pendant juridique. Les délits assimilables à du plagiat se distribuent entre les atteintes au droit d'auteur (&lt;em&gt;&lt;a href=&quot;http://www.legifrance.gouv.fr/affichCode.do?idArticle=LEGIARTI000006278868&amp;amp;idSectionTA=LEGISCTA000006161633&amp;amp;cidTexte=LEGITEXT000006069414&amp;amp;dateTexte=20110106&quot; hreflang=&quot;fr&quot;&gt;Code de la propriété intellectuelle, Première partie : la propriété littéraire et artistique&lt;/a&gt;&lt;/em&gt;) et la contrefaçon (&lt;em&gt;&lt;a href=&quot;http://www.legifrance.gouv.fr/affichCode.do?idArticle=LEGIARTI000022357523&amp;amp;idSectionTA=LEGISCTA000006161665&amp;amp;cidTexte=LEGITEXT000006069414&amp;amp;dateTexte=20110106&quot; hreflang=&quot;fr&quot;&gt;Code de la propriété intellectuelle, Deuxième partie : la propriété industrielle&lt;/a&gt;&lt;/em&gt;) mais une grande partie de ces délits n'est pas constituée. Les affaires ne sont d'ailleurs portées devant les tribunaux que lorsque le préjudice a des conséquences commerciales (en littérature majoritairement). Ce serait potentiellement le cas pour le cas de PPDA, excepté que seul la partie concernée (Gallimard très probablement) peut déposer une plainte ; &lt;a href=&quot;http://www.maitre-eolas.fr/&quot; hreflang=&quot;fr&quot;&gt;Me Éolas&lt;/a&gt; serait bien plus compétent que moi sur ce sujet.&lt;/p&gt;


&lt;p&gt;Ce qui est paradoxale c'est que le plagiat est perçu comme un acte moralement condamnable tandis que la réutilisation de contenu ou d'idées est souvent associée au processus créatif. En réalité, la frontière entre les deux est assez floue. Ainsi, pour &lt;a href=&quot;http://fr.wikipedia.org/wiki/Siegfried_%28Giraudoux%29&quot;&gt;Giraudoux (1928, Acte I, scène 6)&lt;/a&gt;, &lt;em&gt;le plagiat est la base de toutes les littératures, excepté de la première, qui d'ailleurs est inconnue&lt;/em&gt;. Dans le &lt;a href=&quot;http://www.amazon.fr/Palimpsestes-G%C3%A9rard-Genette/dp/2020189054&quot;&gt;Palimpsestes&lt;/a&gt; (Genette, 1982), Genette analyse des enchevêtrements d'œuvres : de la copie à l'allusion lointaine. Il montre qu'un texte peut toujours en cacher un autre, mais qu'il le dissimule rarement tout à fait, prenant pour exemple l'Ulysse de Joyce qui est, d'après sa terminologie, l'hypertexte (œuvre dérivée) de l'Odyssée d'Homère qui en est l'hypotexte (œuvre originale). Les pastiches et les parodies sont autant d'exemples du potentiel créatif de la réutilisation.&lt;/p&gt;


&lt;p&gt;En réalité, comme tout ce qui relève de la morale, le plagiat est une notion culturelle. Ainsi, bien que le droit d'auteur soit assez uniformisé au niveau international par le traité de Berne (1886), chaque pays possède son propre système de protection du droit d'auteur, lorsqu'il en possède. Les États-Unis par exemple n'ont signé le traité qu'un siècle plus tard, réticents à la vision franco-allemande centrée sur l'auteur et son
droit moral. Cette notion est même encore plus éparse puisqu'elle est perçue différemment au sein des branches d'un même métier. &lt;a href=&quot;http://blog.seattlepi.com/thenewschick/archives/169587.asp&quot; hreflang=&quot;en&quot;&gt;Thomas (2009)&lt;/a&gt; montre qu'un processus d'écriture considéré comme du plagiat par la presse écrite et qui entraînerait le renvoi du journaliste est très couramment usité à la TV et à la Radio. &lt;a href=&quot;http://ir.shef.ac.uk/cloughie/papers/thesis.pdf&quot; hreflang=&quot;en&quot;&gt;Clough (2003a)&lt;/a&gt; notamment consacre un chapitre de sa thèse à la description de la réutilisation dans le journalisme.&lt;/p&gt;


&lt;h2&gt;Quelles sont les preuves ?&lt;/h2&gt;


&lt;p&gt;Les accusations de plagiat défraient la chronique assez courrament, particulièrement lorsqu'elles concernent des &lt;a href=&quot;http://www.guardian.co.uk/books/2010/feb/18/harry-potter-jk-rowling-willy-wizard&quot; hreflang=&quot;en&quot;&gt;œuvres à succès telles qu'Harry Potter&lt;/a&gt;. Pourtant très peu de ces accusations se concluent sur des condamnations. En fait, les institutions juridiques commencent tout juste à s'équiper de moyens leur permettant de prendre des décisions concernant les affaires de &amp;quot;plagiat&amp;quot;. Ainsi, l&lt;em&gt;'&lt;a href=&quot;http://www.linguisticevidence.org/&quot; hreflang=&quot;en&quot;&gt;Institute for Linguistic Evidences&lt;/a&gt;&lt;/em&gt;, financé notamment par le &lt;a href=&quot;http://www.justice.gov/&quot; hreflang=&quot;en&quot;&gt;United States Department of Justice&lt;/a&gt; travaille à la mise au point de méthodes permettant d'obtenir des preuves reconnues par un tribunal. Cet institut travaille notamment sur l'&lt;a href=&quot;http://www.aliastechnology.com/ALIAS_Technology/Linguistic_Evidence.html&quot; hreflang=&quot;en&quot;&gt;outil ALIAS&lt;/a&gt; (&lt;em&gt;Automated Linguistic Identification and Assessment System&lt;/em&gt;) (&lt;a href=&quot;http://www.aeap.es/ficheros/03cdffbf1deb3dcf0e64934d35615813.pdf&quot; hreflang=&quot;en&quot;&gt;Chaski, 2001&lt;/a&gt;) qui a partiellement passé les normes de &lt;a href=&quot;http://en.wikipedia.org/wiki/Daubert_standard&quot; hreflang=&quot;en&quot;&gt;Frye et Daubert&lt;/a&gt; qui définissent l'admissibilité d'un témoignage scientifique lors d'un procès aux États-Unis.&lt;/p&gt;


&lt;p&gt;Dans le cas de PPDA, les accusations de &lt;a href=&quot;http://www.lexpress.fr/culture/livre/le-plagiat-de-ppda_949676.html&quot; hreflang=&quot;fr&quot;&gt;Jérôme Dupuis&lt;/a&gt; sont soutenues par &lt;em&gt;des dizaines et des dizaines de paragraphes &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/06/qui&quot; title=&quot;qui&quot;&gt;qui&lt;/a&gt; s'apparentent à des &amp;quot;copier-coller&amp;quot;, souvent grossièrement maquillés par des inversions de phrases ou l'usage effréné de synonymes&lt;/em&gt;. Il présente même &lt;a href=&quot;http://www.lexpress.fr/culture/livre/trois-exemples-du-plagiat-de-ppda_949665.html&quot; hreflang=&quot;fr&quot;&gt;plusieurs exemples&lt;/a&gt; de ces copier-coller fallacieux, précisant que des suppressions, des inversions et des paraphrases ont été opérées pour tenter de dissimuler la reprise.&lt;/p&gt;


&lt;p&gt;En tant que chercheur, j'en ai l'eau à la bouche. Toutes ces modifications sont difficiles à réunir sous forme d'un corpus afin d'être étudiées ou bien pour évaluer les algorithmes de détection. PPDA m'offrirait là un joli cadeau de noël ! Il serait intéressant de &lt;a href=&quot;http://fabienpoulard.info/post/2010/08/26/Calculer-le-recouvrement-de-deux-textes-avec-NLTK&quot; hreflang=&quot;fr&quot;&gt;calculer la couverture&lt;/a&gt; des deux textes et évaluer ainsi quantitativement et objectivement la quantité de reprise. Pour l'heure on est tenu de croire (ou non) aux preuves du journaliste de l'Express.&lt;/p&gt;


&lt;h2&gt;La défense de PPDA et de son éditeur&lt;/h2&gt;


&lt;p&gt;PPDA et son éditeur s'alignent sur la même ligne de défense : &lt;a href=&quot;http://www.lexpress.fr/culture/livre/plagiat-ppda-accuse-son-editeur_950341.html&quot; hreflang=&quot;en&quot;&gt;ils nient tout en bloc accusant l'envoie d'une version de travail provisoire&lt;/a&gt; :&lt;/p&gt;


&lt;p&gt;&lt;q&gt;... les Editions Arthaud tiennent à préciser que le texte imprimé, qui a été diffusé par erreur à la presse en décembre, était une version de travail provisoire. Elle ne correspond pas à la version définitive validée par l'auteur...&lt;/q&gt;&lt;/p&gt;


&lt;p&gt;Je ne suis pas convaincu et &lt;a href=&quot;http://www.arretsurimages.net/vite.php?id=10005&quot; hreflang=&quot;fr&quot;&gt;je ne suis pas le seul&lt;/a&gt; ! Je passerai sur la vieille &lt;a href=&quot;http://fr.wikipedia.org/wiki/N%C3%A8gre_litt%C3%A9raire&quot; hreflang=&quot;fr&quot;&gt;combine du nègre&lt;/a&gt; qui est illégale en droit français pour me concentrer sur la &lt;em&gt;version de travail provisoire&lt;/em&gt;. L'auteur et l'éditeur reconnaissent ici qu'une version de travail temporaire contenait des passages complets de la &lt;a href=&quot;http://www.amazon.fr/Along-Youth-Hemingway-Early-Years/dp/0195036808&quot; hreflang=&quot;en&quot;&gt;biographie écrite par Peter Griffin&lt;/a&gt;. Je me pose plusieurs questions :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;si c'est une version de travail temporaire, pourquoi y coller des passages d'un autre livre et ne pas plutôt laisser des blancs ?&lt;/li&gt;
&lt;li&gt;pourquoi tenter de modifier ces passages recopiés s'ils sont destinés à être supprimés par la suite ?&lt;/li&gt;
&lt;li&gt;si ce ne sont les passages, il semble du moins que le plan du livre de PPDA soit très similaire à celui de Griffin, n'est-ce pas une forme de plagiat ?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;La notion morale de plagiat me posant problème dans ma thèse, j'y ai introduit une notion plus scientifique à mon goût : la dérivation. Je définis la dérivation comme ceci (&lt;em&gt;extrait de ma thèse&lt;/em&gt;) :&lt;/p&gt;


&lt;p&gt;&lt;q&gt;Nous considérons qu'un texte dérive d'un autre lorsque la préexistence de l'un, que nous appelons texte source, est une condition nécessaire à l'aboutissement de l'écriture de l'autre, que nous appelons texte dérivé. Le texte source influence (dans ses idées, dans son expression, dans sa structure...) l'auteur du texte dérivé, de telle façon qu'il a eu un impact dans ses choix d'écriture. Il en découle que si cet auteur est privé de la connaissance d'un texte source alors il produira un texte différent de celui qu'il aurait produit en sa connaissance.&lt;/q&gt;&lt;/p&gt;


&lt;p&gt;Il me semble que dans le contexte présent il existe bel et bien un lien de dérivation entre le livre de Peter Griffin et celui de PPDA... Je meurs d'envie de fouiller un peu plus dans ce sens là. Si jamais quelqu'un possède une version électronique de chacun des livres, je serais heureux de pouvoir les analyser. D'ici là, je retourne à la rédaction du mien de manuscrit :)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Petit script pour découvrir les expressions rationnelles</title>
    <link>http://fabienpoulard.info/post/2011/01/04/Petit-script-pour-d%C3%A9couvrir-les-expressions-rationnelles</link>
    <guid isPermaLink="false">urn:md5:ab7421b44fedc2e79456f308adad4dff</guid>
    <pubDate>Tue, 04 Jan 2011 15:21:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>enseignement</category><category>exercice</category><category>python</category><category>regexp</category>    
    <description>&lt;p&gt;Comme j'en discutais dans &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Cours-de-TALN-%281%29-%3A-expressions-rationnelles&quot;&gt;mon billet précédent&lt;/a&gt;, mon premier cours cette année a principalement porté sur les &lt;a href=&quot;http://fr.wikipedia.org/wiki/Expression_rationnelle&quot; hreflang=&quot;fr&quot;&gt;expressions rationnelles&lt;/a&gt;. J'ai tiré deux bilans de ce cours :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;il faut que les étudiants manipulent au maximum&lt;/li&gt;
&lt;li&gt;il faut qu'ils comprennent mieux ce qui se passe dans les moteurs d'expressions rationnelles pour corriger leurs erreurs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;J'ai donc écrit un script Python pour les accompagner dans leur découverte des expressions rationnelles.&lt;/p&gt;    &lt;p&gt;Le script est disponible &lt;a href=&quot;http://fabienpoulard.info/download//Enseignements/EPUN/2011/test-re.py&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Il prend en paramètre une expression de la forme &lt;code&gt;'m/&amp;lt;regexp&amp;gt;/'&lt;/code&gt; ou &lt;code&gt;'s/&amp;lt;regexp&amp;gt;/&amp;lt;remplacement&amp;gt;/'&lt;/code&gt; selon la tâche à tester.&lt;/p&gt;


&lt;p&gt;Petit exemple de fonctionnement :&lt;/p&gt;

&lt;pre&gt;
$ ./test-re.py 's/([0-9]{1,3}\.[0-9]{1,3})\.[0-9]{1,3}\.[0-9]{1,3}/Réseau IP \1.0.0/'
Checking configuration...Replacing mode.
Ready. Hit ^D to stop the program.
test-re&amp;gt;&amp;gt; 192.168.1.1
RES&amp;gt; Matching
	Matched: ...192.168.1.1... (0, 11)
	Context: -&amp;gt;[192.168.1.1]&amp;lt;-
	Groups:
		1- 192.168
Substitution
	Original:	 192.168.1.1
	Replaced:	 Réseau IP 192.168.0.0
test-re&amp;gt;&amp;gt; mon adresse ip : 174.12.32.65 mon masque 255.255.255.0    
RES&amp;gt; Matching
	Matched: ...174.12.32.65... (17, 29)
	Context: -&amp;gt;mon adresse ip : [174.12.32.65] mon masque 255.255.255.0&amp;lt;-
	Groups:
		1- 174.12
Substitution
	Original:	 mon adresse ip : 174.12.32.65 mon masque 255.255.255.0
	Replaced:	 mon adresse ip : Réseau IP 174.12.0.0 mon masque Réseau IP 255.255.0.0
&lt;/pre&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Cours de TALN (1) : expressions rationnelles</title>
    <link>http://fabienpoulard.info/post/2011/01/03/Cours-de-TALN-%281%29-%3A-expressions-rationnelles</link>
    <guid isPermaLink="false">urn:md5:f7ffa870bcd865ced11f874efb57f9a8</guid>
    <pubDate>Mon, 03 Jan 2011 16:54:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>corpus</category><category>enseignement</category><category>exercice</category><category>python</category><category>tokenisation</category>    
    <description>&lt;p&gt;Voilà, suite à &lt;a href=&quot;http://fabienpoulard.info/post/2011/01/03/Enseignement-du-TAL&quot;&gt;mon précédent billet&lt;/a&gt;, je me suis décidé à me lancer dans l'écriture du cours que je dois donner demain.&lt;/p&gt;    &lt;p&gt;L'intégralité du cours et des ressources nécessaires est disponible &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/&quot; hreflang=&quot;fr&quot;&gt;ici&lt;/a&gt;, ce qui inclut :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/1-tdtp-expressions-rationnelles.pdf&quot; hreflang=&quot;fr&quot;&gt;le support de cours&lt;/a&gt; ;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/discours-sarkozy-all.tar.bz2&quot; hreflang=&quot;fr&quot;&gt;une version allégée du corpus&lt;/a&gt; des &lt;a href=&quot;http://fabienpoulard.info/post/2010/03/13/Corpus-des-discours-de-Nicolas-Sarkozy-%28M%C3%80J%29&quot; hreflang=&quot;fr&quot;&gt;discours de Nicolas Sarkozy&lt;/a&gt; ;&lt;/li&gt;
&lt;li&gt;un corpus de fichiers de logs (&lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/auth-access.log.gz&quot;&gt;logs d'authentification&lt;/a&gt;, &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/httpd-error.log.gz&quot;&gt;d'erreurs d'Apache&lt;/a&gt; et &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/httpd-access.log.gz&quot;&gt;de connexions à un vhost Apache&lt;/a&gt;) ;&lt;/li&gt;
&lt;li&gt;et &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/count-ip-ssh-attacks.py&quot;&gt;quelques&lt;/a&gt; &lt;a href=&quot;http://fabienpoulard.info/download/Enseignements/EPUN/2011/decoupage-corpus-sarkozy.py&quot;&gt;exemples&lt;/a&gt; de code en Python.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;À l'issue de cette première séance mon objectif est d'avoir enseigné aux étudiants :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;des connaissances suffisantes à la compréhension et à l'écriture d'expressions rationnelles ;&lt;/li&gt;
&lt;li&gt;l'utilisation des expressions rationnelles à travers les outils &lt;em&gt;grep&lt;/em&gt; et &lt;em&gt;sed&lt;/em&gt; ainsi qu'au sein du langage Python ;&lt;/li&gt;
&lt;li&gt;et qu'ils aient perçu les difficultés d'une problématique classique en TALN : le découpage en mots.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bien entendu un autre objectif implicite est de leur avoir donné envie de creuser un peu plus loin et d'avoir suffisamment aiguisé leur curiosité pour qu'ils s'intéressent à la suite du cours... et au TALN en général. Bilan des objectifs demain :)&lt;/p&gt;


&lt;p&gt;En bonus pour les plus efficaces, la possibilité de générer un joli nuage des mots les plus prononcés dans les discours de notre président dans le style de celui-ci :&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/Enseignements/nuage-discours-sarkozy.png&quot; title=&quot;Nuage des mots les plus prononcés dans les discours de Nicolas Sarkozy&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/Enseignements/.nuage-discours-sarkozy_m.jpg&quot; alt=&quot;Nuage des mots les plus prononcés dans les discours de Nicolas Sarkozy&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Nuage des mots les plus prononcés dans les discours de Nicolas Sarkozy, janv. 2011&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Un cours de TALN parfait ?</title>
    <link>http://fabienpoulard.info/post/2011/01/03/Enseignement-du-TAL</link>
    <guid isPermaLink="false">urn:md5:b08304fc60d04e1dbe0602f48ad3efc3</guid>
    <pubDate>Mon, 03 Jan 2011 00:55:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>corpus</category><category>enseignement</category><category>exercice</category><category>nlp</category><category>nltk</category><category>python</category><category>éducation</category>    
    <description>&lt;p&gt;Depuis le début de mon doctorat j'ai eu la chance de pouvoir dispenser plusieurs enseignements autour du TALN. Malheureusement je n'ai jamais été responsable du module et je n'ai jamais tellement eu la liberté d'enseigner comme je le souhaitais. Personnellement je n'ai pas aimé la façon dont le TALN m'a été enseigné et par conséquent je n'aime pas l'enseigner de la même façon qu'il me l'a été.&lt;/p&gt;


&lt;p&gt;Quelle aurait été le cours de TALN que j'aurais aimé avoir ? Certainement quelque chose mieux ancré dans le TALN d'aujourd'hui et orienté vers les méthodes et les applications !&lt;/p&gt;    &lt;p&gt;Cette année, j'enseigne encore une fois le TALN à l'&lt;a href=&quot;http://www.polytech.univ-nantes.fr/&quot; hreflang=&quot;fr&quot;&gt;EPUN&lt;/a&gt; : 9h de TP destinés à des étudiants de 1ère année d'ingénieur. La différence c'est que cette fois j'ai plus ou moins quartier libre. Cette liberté est toute relative puisque je ne suis responsable que des TP et que ceux-ci devront coller aux cours (sur lesquels je n'ai aucune prise). Toutefois, cette année je ne suis pas tenu de donner un projet noté. En d'autres termes, je peux exploiter la totalité des heures pour faire des exercices : apprendre en faisant comme on dit.&lt;/p&gt;


&lt;p&gt;Habituellement, les travaux pratiques sont faits en &lt;a href=&quot;http://www.perl.org/&quot;&gt;Perl&lt;/a&gt;, un langage que je n'apprécie pas du tout alors qu'il est certainement le langage favoris de ma communauté. Sans disserter sur les raisons de notre désamour, je pense qu'il n'apporte rien d'autre qu'un bon moteur pour les &lt;a href=&quot;http://fr.wikipedia.org/wiki/Expression_rationnelle&quot;&gt;expressions rationnelles&lt;/a&gt;. S'il y a dix ans cette spécificité justifiait son choix, aujourd'hui tous les langages généralistes supportent aussi bien les expressions rationnelles. Le comble est qu'il n'existe pas (à ma connaissance) de plateforme (modules, extensions...) permettant de faire du TALN en Perl, alors qu'on en trouve pour &lt;a href=&quot;http://www.nltk.org&quot;&gt;Python&lt;/a&gt; et &lt;a href=&quot;http://uima.apache.org&quot;&gt;Java&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Plutôt que Perl, je pense que je vais faire travailler mes étudiants avec &lt;a href=&quot;http://www.python.org&quot;&gt;Python&lt;/a&gt;. Outre le fait qu'il me sera beaucoup plus aisé de corriger les projets (les programmes Perl des gens qui ne maîtrisent pas le langage peuvent être la cause de sérieuses crises de nerf), l'apprentissage du langage Python leur sera utile pour d'autres projets scientifiques (voir &lt;a href=&quot;http://ftp.traduc.org/doc-vf/gazette-linux/html/2005/114/lg114-A.html&quot; hreflang=&quot;fr&quot;&gt;ici&lt;/a&gt;, &lt;a href=&quot;http://ftp.traduc.org/doc-vf/gazette-linux/html/2005/115/lg115-A.html&quot; hreflang=&quot;fr&quot;&gt;ici&lt;/a&gt; ou encore &lt;a href=&quot;http://matthieu-brucher.developpez.com/livre/python/scientifiques/&quot; hreflang=&quot;fr&quot;&gt;là&lt;/a&gt;). De plus, le cadriciel &lt;a href=&quot;http://www.nltk.org&quot;&gt;nltk&lt;/a&gt; permet d'aborder rapidement les principales tâches du TALN sans avoir à tout réimplémenter. Le cadriciel est notamment &lt;a href=&quot;http://www.nltk.org/book&quot; hreflang=&quot;en&quot;&gt;très bien documenté&lt;/a&gt;, ce qui ne gâche rien !&lt;/p&gt;


&lt;p&gt;Au niveau corpus, je ne sais pas encore très bien sur quoi je vais les faire travailler car il y a malheureusement assez peu de corpus français intéressants pour l'enseignement. Remplacez &lt;em&gt;intéressants pour l'enseignement&lt;/em&gt; par &lt;em&gt;on se fout qu'il soit représentatif, on veut juste pouvoir faire des exercices marrants et observer des phénomènes linguistiques simples&lt;/em&gt;. J'hésite entre &lt;a href=&quot;http://fabienpoulard.info/post/2010/03/13/Corpus-des-discours-de-Nicolas-Sarkozy-%28M%C3%80J%29&quot;&gt;mon corpus sur les discours de Nicolas Sarkozy&lt;/a&gt; ou celui que j'ai constitué à partir de &lt;a href=&quot;http://fr.wikinews.org/&quot; hreflang=&quot;fr&quot;&gt;Wikinews&lt;/a&gt;. Je pourrais également utiliser le French TreeBank qui a l'avantage d'être arboré (découpage en mots et annotation des rôles grammaticaux) mais je ne suis pas sûr que sa licence le permette. Je pourrais également explorer certaines œuvres du &lt;a href=&quot;http://www.gutenberg.org/&quot;&gt;projet Guteberg&lt;/a&gt;. Il manque clairement un corpus libre tout plein d'annotations pour le français !&lt;/p&gt;


&lt;p&gt;Enfin au niveau du contenu il va falloir que je me creuse un petit peu la tête. Le cours présente pas mal (trop ?) de choses : &lt;a href=&quot;http://fr.wikipedia.org/wiki/Expression_rationnelle&quot; hreflang=&quot;fr&quot;&gt;expressions rationnelles&lt;/a&gt;, &lt;a href=&quot;http://fr.wikipedia.org/wiki/Morphologie_(linguistique)&quot; hreflang=&quot;fr&quot;&gt;analyse morphologique&lt;/a&gt; (&lt;a href=&quot;http://fabienpoulard.info/post/2008/02/21/Lalgorithme-de-Porter&quot;&gt;algorithme de Porter&lt;/a&gt; notamment), &lt;a href=&quot;http://fr.wikipedia.org/wiki/Syntaxe&quot; hreflang=&quot;fr&quot;&gt;analyse syntaxique&lt;/a&gt; mais également un peu de &lt;a href=&quot;http://fr.wikipedia.org/wiki/N-gramme&quot; hreflang=&quot;fr&quot;&gt;n-grammes&lt;/a&gt;, des &lt;a href=&quot;http://fr.wikipedia.org/wiki/Mod%C3%A8le_de_Markov_cach%C3%A9&quot;&gt;modèles de Markov cachés&lt;/a&gt; et j'en oublie certainement...&lt;/p&gt;


&lt;p&gt;Le premier cours est mardi prochain, il va falloir que je me casse la tête d'ici là. Je pense les faire travailler sur des choses simples :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;quelques exercices sur les expressions rationnelles&lt;/li&gt;
&lt;li&gt;prise en main de NLTK&lt;/li&gt;
&lt;li&gt;découpage en mots&lt;/li&gt;
&lt;li&gt;loi de Zipf&lt;/li&gt;
&lt;li&gt;une super application de l'utilisation du découpage en mots et des expressions rationnelles ???&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Si certains d'entre-vous ont des ressources, des supports de cours ou des idées qui pourraient m'inspirer... n'hésitez pas ! :)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>UIMA insights : le doigt dans le workflow</title>
    <link>http://fabienpoulard.info/post/2010/09/20/UIMA-insights-%3A-le-doigt-dans-le-workflow</link>
    <guid isPermaLink="false">urn:md5:e9b8506e92897f934e70af90cb619b53</guid>
    <pubDate>Mon, 20 Sep 2010 00:08:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>java</category><category>uima</category>    
    <description>&lt;p&gt;Les opérations logicielles en traitement automatique des langues sont souvent très importantes, très coûteuse, mais également parallélisables. C'est l'un des avantages indéniables d'&lt;a href=&quot;http://uima.apache.org/&quot; hreflang=&quot;en&quot;&gt;UIMA&lt;/a&gt;, par le choix d'une architecture par composants, de permettre de paralléliser les traitements assez simplement.&lt;/p&gt;


&lt;p&gt;La programmation d'un composant UIMA doit donc se faire avec en tête l'idée qu'il pourrait être déployé pour un traitement parallélisé. Lorsque comme moi on n'a pas cette habitude, on se heurte rapidement à des petits obstacles techniques. Dans le cas présent, il s'agissait de développer un composant qui exportait les résultats d'un calcul dans un fichier CSV.&lt;/p&gt;    &lt;h2&gt;Mon problème&lt;/h2&gt;


&lt;p&gt;La chaîne de traitement que j'utilise pour ma thèse calcule des scores de similarité entre des documents. Afin de simplifier l'évaluation de mon système, je souhaite réunir tous ces scores de similarité dans un même fichier CSV.&lt;/p&gt;


&lt;p&gt;La solution naïve qui fonctionne presque consiste à ce que le composant ouvre un fichier et y écrive au fur et à mesure. Les systèmes ne rechignent pas à ce que plusieurs processus écrivent en même temps dans le même fichier... Malheureusement ils ne s'assurent pas non plus d'ordonnancer les requêtes d'écriture au risque que chacun écrive sur la copie de son voisin !&lt;/p&gt;


&lt;p&gt;Voici le résultat que j'attends :&lt;/p&gt;


&lt;pre&gt; source-document00003.txt;suspicious-document00016.txt;not-derivative;0.0016992353
 source-document00003.txt;suspicious-document00040.txt;not-derivative;0.23280424
 source-document00267.txt;suspicious-document00055.txt;derivative;0.14148398&lt;/pre&gt;


&lt;p&gt;et voici ce que ça peut donner quand les différents processus décident d'écrire en même temps :&lt;/p&gt;


&lt;pre&gt; source-document00003.txt;suspicious-docsource-document00003.txt;suspicious-source-document00267.txt;suspicious-document00055.txt;derivative;0.14148398
 ument00016.txt;not-derivative;0.0016992353
 document00040.txt;not-derivative;0.23280424&lt;/pre&gt;


&lt;h2&gt;Le workflow d'UIMA&lt;/h2&gt;


&lt;p&gt;J'avais déjà rapidement présenté le workflow d'UIMA dans &lt;a href=&quot;http://fabienpoulard.info/post/2010/07/16/Du-bon-usage-des-ressources-dans-UIMA&quot; hreflang=&quot;en&quot;&gt;mon billet sur les ressources&lt;/a&gt;. Un petit résumé des épisodes précédents ne sera peut-être pas de trop.&lt;/p&gt;


&lt;p&gt;Comme d'habitude, pour simplifier, on va considérer qu'on utilise uniquement le &lt;a href=&quot;http://uima.apache.org/downloads/releaseDocs/2.3.0-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.flow_controller&quot; hreflang=&quot;en&quot;&gt;flow controler&lt;/a&gt; par défaut qui fait s'enchaîner séquentiellement les composants. Cela revient à considérer que la sortie d'un composant alimente directement l'entrée du composant suivant, à la manière des &lt;a href=&quot;http://fr.wikipedia.org/wiki/Tube_(shell)&quot; hreflang=&quot;fr&quot;&gt;pipes&lt;/a&gt; dans le monde Unix.&lt;/p&gt;


&lt;p&gt;Dans cette configuration, UIMA regroupe les chaînes de &lt;a href=&quot;http://uima.apache.org/downloads/releaseDocs/2.3.0-incubating/docs/html/references/references.html#ugr.ref.xml.cpe_descriptor.descriptor.cas_processors&quot; hreflang=&quot;en&quot;&gt;CAS processors&lt;/a&gt; (les composants qui manipulent les CAS) dans autant de processing pipelines que l'attribut processingUnitThreadCount du CPE le demande, comme l'illustre le schéma ci-dessous :&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/UIMA/cpe-detail.png&quot; title=&quot;cpe-detail.png&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/UIMA/.cpe-detail_m.jpg&quot; alt=&quot;cpe-detail.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;cpe-detail.png, juil. 2010&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;l est nécessaire d'instancier les composants utilisés autant de fois qu'il y a de &lt;em&gt;processing pipelines&lt;/em&gt;. Jusque-là, rien de bien nouveau en réalité. Mais ce que j'ai découvert récemment, douloureusement bien entendu, c'est que cette instanciation ne se faisait pas au sein des &lt;em&gt;pipelines&lt;/em&gt;, mais au sein du thread principal du CPE. Soit la procédure suivante, pour chaque composant :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Instanciation du composant dans le thread principal du CPE ;&lt;/li&gt;
&lt;li&gt;&lt;ins&gt;Appel de la méthode &lt;em&gt;initialize()&lt;/em&gt; toujours dans le thread principal&lt;/ins&gt; ;&lt;/li&gt;
&lt;li&gt;Création des threads des pipelines et rattachement des composants à ces derniers ;&lt;/li&gt;
&lt;li&gt;Appels successifs à &lt;em&gt;process()&lt;/em&gt; au sein de ces threads ;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Ma solution&lt;/h2&gt;


&lt;p&gt;J'aurais certes pu faire le choix d'utiliser le système des ressources pour mon composant, comme je le préconise dans &lt;a href=&quot;http://fabienpoulard.info/post/2010/07/16/Du-bon-usage-des-ressources-dans-UIMA&quot;&gt;mon billet précédent&lt;/a&gt;. Toutefois, je n'ai pas eu le temps de manipuler le système des ressources et il est grand temps que j'en finisse avec ma thèse :) Je me suis donc tourné vers quelque chose de plus &lt;em&gt;direct&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Mon choix s'est donc porté sur la création d'autant de fichiers qu'il y a d'instances de mon composant. Je suffixe tout simplement le nom du fichier par l'identifiant du thread courant. Cette méthode fonctionne suffisamment bien, mais nécessite bien entendu de concaténer l'ensemble des fichiers à la fin du traitement. De plus elle ne permet pas directement de garder une trace de l’ordonnancement des écritures ! Dans mon cas ce n'était pas un prérequis.&lt;/p&gt;


&lt;p&gt;Pour la petite histoire, j'ai découvert que la méthode &lt;em&gt;initialize()&lt;/em&gt; était appelée dans le thread principal car tous mes fichiers étaient suffixés par l'identifiant 1. J'ai donc simplement déplacé l'ouverture des fichiers dans la méthode &lt;em&gt;process()&lt;/em&gt; en ajoutant un test pour s'assurer que cette initialisation n'avait pas déjà eu lieu.&lt;/p&gt;


&lt;p&gt;Voici le code (synthétique) correspondant, toute l'astuce réside dans le &lt;em&gt;Thread.currentThread().getId()&lt;/em&gt; :&lt;/p&gt;

&lt;pre class=&quot;java java&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;void&lt;/span&gt; process&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;JCas aJCas&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; AnalysisEngineProcessException &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;
	&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Check the streams have been initialized&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;theStream &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;
		&lt;span style=&quot;color: #003399;&quot;&gt;Long&lt;/span&gt; tid &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003399;&quot;&gt;Thread&lt;/span&gt;.&lt;span style=&quot;color: #006633;&quot;&gt;currentThread&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: #006633;&quot;&gt;getId&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
		theStream &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #003399;&quot;&gt;PrintStream&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt; 
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #003399;&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt; theExportSuffix &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;.__&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; tid&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;
	&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Select the right view&lt;/span&gt;
	JCas view &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; aJCas.&lt;span style=&quot;color: #006633;&quot;&gt;getView&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;theViewName&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	...&lt;/pre&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Un rapide tokeniseur en mots pour le français</title>
    <link>http://fabienpoulard.info/post/2010/09/08/Un-rapide-tokeniseur-en-mots-pour-le-fran%C3%A7ais</link>
    <guid isPermaLink="false">urn:md5:1fccddc635893e99176c852146ad62fe</guid>
    <pubDate>Wed, 08 Sep 2010 00:10:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>java</category><category>tokenisation</category><category>uima</category>    
    <description>&lt;p&gt;Parmi les addons distribués avec UIMA, le composant &lt;a href=&quot;http://uima.apache.org/sandbox.html#whitespace.tokenizer&quot; hreflang=&quot;en&quot;&gt;WhitespaceTokenizer&lt;/a&gt; permet de découper les textes en &amp;quot;mots&amp;quot; en s'appuyant sur les espaces et autres blancs. Malheureusement si cette approche est acceptable pour l'anglais, elle est beaucoup plus problématique pour le français.
Le découpage en mots n'est pas une tâche forcément évidente et qui nécessiterait un réel travail. Partagé entre la nécessité d'une tokenisation correcte et le peu de temps qui me reste pour terminer ma thèse, voici une proposition suffisamment acceptable pour mes besoins.&lt;/p&gt;    &lt;h2&gt;Idée et objectifs&lt;/h2&gt;
&lt;p&gt;Mon idée est d'exploiter &lt;a href=&quot;http://en.wikipedia.org/wiki/Unicode_character_properties#General_Category&quot; hreflang=&quot;en&quot;&gt;la catégorie générale des caractère&lt;/a&gt; telles que définies dans la norme Unicode pour détecter les frontières des mots. Une rupture dans la catégorie des caractères indiquant vraisemblablement un changement de mot.&lt;/p&gt;
&lt;p&gt;Je souhaite que mon composant soit en mesure d'identifier correctement tous les mots détectés par le WhitespaceTokenizer (c'est un minimum), ainsi que les cas problématiques tels que :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;les articles et pronoms contractés (&lt;em&gt;l', d', j', m', ...&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;les composés lexicaux à apostrophe (&lt;em&gt;aujourd'hui, ...&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;les composés lexicaux à traits d'union (&lt;em&gt;arc-en-ciel, peut-être, sauve-qui-peut, ...&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;les valeurs numériques (&lt;em&gt;14 000, 14,18, 30 %, ...&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;les acronymes (&lt;em&gt;ASSEDIC, ASCII, ...&lt;/em&gt;) et les sigles (&lt;em&gt;C-4, c-à-d, i.e., ...&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;les unités de mesure (&lt;em&gt;A/m, km/h, ...&lt;/em&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Mise en œuvre&lt;/h2&gt;
&lt;h3&gt;Catégories générales des caractères unicodes&lt;/h3&gt;
&lt;p&gt;La norme unicode offre sept catégories générales de caractère :&lt;/p&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Unicode&lt;/th&gt;&lt;th&gt;Java (getType)&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;les lettres (L)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Ll&lt;/td&gt;&lt;td&gt;	LOWERCASE_LETTER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lu&lt;/td&gt;&lt;td&gt;UPPERCASE_LETTER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lm&lt;/td&gt;&lt;td&gt;MODIFIER_LETTER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lo&lt;/td&gt;&lt;td&gt;OTHER_LETTER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lt&lt;/td&gt;&lt;td&gt;TITLECASE_LETTER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;les marques (M)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Mc&lt;/td&gt;&lt;td&gt;COMBINING_SPACING_MARK&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Me&lt;/td&gt;&lt;td&gt;ENCLOSING_MARK&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Mn&lt;/td&gt;&lt;td&gt;NON_SPACING_MARK&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;les nombres (N)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Nd&lt;/td&gt;&lt;td&gt;DECIMAL_DIGIT_NUMBER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Nl&lt;/td&gt;&lt;td&gt;LETTER_NUMBER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;OTHER_NUMBER&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;les ponctuations (P)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pc&lt;/td&gt;&lt;td&gt;CONNECTOR_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pd&lt;/td&gt;&lt;td&gt;DASH_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pe&lt;/td&gt;&lt;td&gt;END_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pi&lt;/td&gt;&lt;td&gt;INITIAL_QUOTE_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pf&lt;/td&gt;&lt;td&gt;FINAL_QUOTE_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Po&lt;/td&gt;&lt;td&gt;OTHER_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Ps&lt;/td&gt;&lt;td&gt;START_PUNCTUATION&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;les symboles (S)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Sc&lt;/td&gt;&lt;td&gt;CURRENCY_SYMBOL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Sm&lt;/td&gt;&lt;td&gt;MATH_SYMBOL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Sk&lt;/td&gt;&lt;td&gt;MODIFIER_SYMBOL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;So&lt;/td&gt;&lt;td&gt;OTHER_SYMBOL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;les séparateurs (Z)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Zl&lt;/td&gt;&lt;td&gt;LINE_SEPARATOR&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Zp&lt;/td&gt;&lt;td&gt;PARAGRAPH_SEPARATOR&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Zs&lt;/td&gt;&lt;td&gt;SPACE_SEPARATOR&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;divers (C)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cc&lt;/td&gt;&lt;td&gt;CONTROL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cf&lt;/td&gt;&lt;td&gt;FORMAT&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Co&lt;/td&gt;&lt;td&gt;PRIVATE_USE&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cs&lt;/td&gt;&lt;td&gt;SURROGATE&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cn&lt;/td&gt;&lt;td&gt;UNASSIGNED&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Le site &lt;a href=&quot;http://www.fileformat.info/info/unicode/category/index.htm&quot; hreflang=&quot;en&quot;&gt;Fileformat&lt;/a&gt; fournit une liste et une description exhaustive des caractères contenus dans ces différentes catégories.&lt;/p&gt;
&lt;h3&gt;Description des mots&lt;/h3&gt;
&lt;h4&gt;Mots pleins&lt;/h4&gt;
&lt;p&gt;Les mots pleins sont ceux qui se composent uniquement d'une suite de caractères alphanumériques, on peut les reconnaître à l'aide de l'automate suivant :&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/fsm-motsimple.png&quot; title=&quot;fsm-motsimple.png&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/.fsm-motsimple_s.jpg&quot; alt=&quot;fsm-motsimple.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;fsm-motsimple.png, sept. 2010&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Le cas de l'apostrophe&lt;/h4&gt;
&lt;p&gt;Les articles et pronoms contractés précédent un autre mot, ils se composent d'une seule lettre et d'un apostrophe. Les apostrophes appartiennent à la catégorie &lt;em&gt;Po&lt;/em&gt; qui contient également le point d'exclamation, le dièse, ... ou bien à &lt;em&gt;Lm&lt;/em&gt;. Il est préférable d'établir une liste des caractères correspondant. L'apostrophe (&lt;a href=&quot;http://www.fileformat.info/info/unicode/char/0027/index.htm&quot; hreflang=&quot;en&quot;&gt;U+0027&lt;/a&gt;) et le modifieur apostrophe (&lt;a href=&quot;http://www.fileformat.info/info/unicode/char/02bc/index.htm&quot; hreflang=&quot;en&quot;&gt;U+02BC&lt;/a&gt;) sont les deux caractères qui semblent correspondre pour le français.&lt;/p&gt;
&lt;p&gt;Les composés lexicaux à apostrophe sont quant à eux formés de deux séquences alphabétiques connectées par un apostrophe (&lt;em&gt;aujourd'hui, ...&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;L'automate permettant de reconnaître ces deux formes de mots :&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/fsm-apostrophe.png&quot; title=&quot;fsm-apostrophe.png&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/.fsm-apostrophe_s.jpg&quot; alt=&quot;fsm-apostrophe.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;fsm-apostrophe.png, sept. 2010&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Le cas du trait d'union&lt;/h4&gt;
&lt;p&gt;Le trait d'union est utilisé dans plusieurs configurations : pour les composés lexicaux (&lt;em&gt;arc-en-ciel, peut-être, sauve-qui-peut, ...&lt;/em&gt;) et certains sigles sigles (&lt;em&gt;C-4, c-à-d, ...&lt;/em&gt;). D'une manière générale certaines ponctuations sont employées au sein des mots : le point pour les abréviations (&lt;em&gt;i.e., M., ...&lt;/em&gt;), ou le slash pour les unités de mesure (&lt;em&gt;A/m, km/h, ...&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Les traits d'union sont regroupés dans la catégorie &lt;a href=&quot;http://www.fileformat.info/info/unicode/category/Pd/list.htm&quot; hreflang=&quot;en&quot;&gt;''Punctuation, dash'' (''Pd'')&lt;/a&gt;, les autres ponctuations (slash et point) sont placées dans &lt;a href=&quot;http://www.fileformat.info/info/unicode/category/Po/list.htm&quot; hreflang=&quot;en&quot;&gt;''Punctuation, other'' (''Po'')&lt;/a&gt;. L'important c'est que ladite ponctuation soit placée entre deux séquences de lettres :&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/fsm-union.png&quot; title=&quot;fsm-union.png&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/.fsm-union_s.jpg&quot; alt=&quot;fsm-union.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;fsm-union.png, sept. 2010&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Les valeurs numériques particulières&lt;/h4&gt;
&lt;p&gt;Finalement le dernier cas particulier concerne les valeurs numériques complexes (&lt;em&gt;14 000, 14,18, 30 %, -3, ...&lt;/em&gt;). La catégorie &lt;a href=&quot;http://www.fileformat.info/info/unicode/category/Sc/list.htm&quot; hreflang=&quot;en&quot;&gt;''Symbol, Currency'' (''Sc'')&lt;/a&gt; nous intéresse particulièrement. Le &lt;a href=&quot;http://www.fileformat.info/info/unicode/char/25/index.htm&quot; hreflang=&quot;en&quot;&gt;symbole ''%''&lt;/a&gt; se trouve dans la catégorie &lt;a href=&quot;http://www.fileformat.info/info/unicode/category/Po/list.htm&quot; hreflang=&quot;en&quot;&gt;''Punctuation, other' (''Po'')&lt;/a&gt;, tandis que le point et la virgule décimale correspondent respectivement à &lt;a href=&quot;http://www.fileformat.info/info/unicode/char/2e/index.htm&quot; hreflang=&quot;en&quot;&gt;U+002E&lt;/a&gt; et &lt;a href=&quot;http://www.fileformat.info/info/unicode/char/2c/index.htm&quot; hreflang=&quot;en&quot;&gt;U+002C&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/fsm-decimal.png&quot; title=&quot;fsm-decimal.png&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/.fsm-decimal_s.jpg&quot; alt=&quot;fsm-decimal.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;fsm-decimal.png, sept. 2010&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Algorithmie&lt;/h3&gt;
&lt;p&gt;La tokenisation s'effectue sur un flux continue de caractères. L'utilisation d'automates classiques tels que présentés précédemment n'est pas forcément possible car l'utilisation commune ne correspond pas forcément à une grammaire régulière et ils sont non déterministes. En gros nous pouvons nous retrouver dans ces cas de figure :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parfois l'espace sépare un mot, parfois il est contenu au sein d'un mot (entre le nombre et la monnaie par exemple) ;&lt;/li&gt;
&lt;li&gt;Parfois le passage d'un mot à un autre se fait en consommant un ou plusieurs caractères (espace), parfois le caractère de séparation appartient à l'un des deux mots (apostrophe) ;&lt;/li&gt;
&lt;li&gt;La consommation d'un caractère inattendu ne doit pas interrompre le fonctionnement : une décision doit être prise (couper le mot ou pas).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ma proposition consiste à mettre en œuvre une sorte de &lt;a href=&quot;http://fr.wikipedia.org/wiki/Transducteur_%C3%A0_%C3%A9tats_finis&quot; hreflang=&quot;fr&quot;&gt;transducteur&lt;/a&gt; &lt;a href=&quot;http://fr.wikipedia.org/wiki/Automate_%C3%A0_pile&quot; hreflang=&quot;fr&quot;&gt;à pile&lt;/a&gt;. La pile permet uniquement de conserver un historique des derniers caractères consommés afin de découper les mots à une position antérieure si nécessaire (symbole de monnaie non trouvé mais espace consommé par exemple). L'utilisation d'un transducteur permet d'enovyer des signaux indiquant si une coupure de mot doit avoir lieu ou non.&lt;/p&gt;
&lt;p&gt;Les signaux envoyés par le système peuvent être les suivants :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;start_word&lt;/em&gt; un nouveau mot commence ;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;end_word&lt;/em&gt; le mot courant se termine, le caractère juste consommé n'en faisant pas parti ;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;end_words_prev&lt;/em&gt; le mot courant se termine au caractère anté-précédent ;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;switch_word&lt;/em&gt; le mot courant se termine sur le caractère consommé, le caractère courant appartient à un nouveau mot ;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;switch_word_prev&lt;/em&gt; le mot courant se termine au caractère anté-précédent, le caractère courant appartient à un nouveau mot ;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;nop&lt;/em&gt; aucune opération&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;L'automate ci-dessous correspond à ce transducteur :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;les états en N (orange) correspondent à l'automate de reconnaissance des valeurs numériques ;&lt;/li&gt;
&lt;li&gt;les états en L (bleu) correspondent à une combinaison des automates de reconnaissance des mots alphabétiques ;&lt;/li&gt;
&lt;li&gt;les transitions en rouge correspondent aux cas d'erreur où il faut prendre une décision ;&lt;/li&gt;
&lt;li&gt;les transitions en vert correspondent aux cas attendus de changement de mot.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/fsm-complete.png&quot; title=&quot;fsm-complete.png&quot;&gt;&lt;img src=&quot;http://fabienpoulard.info/public/UIMA/tokeniseur/.fsm-complete_s.jpg&quot; alt=&quot;fsm-complete.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;fsm-complete.png, sept. 2010&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Implémentation&lt;/h3&gt;
&lt;p&gt;J'ai recherché une bibliothèque Java pour manipuler des transducteurs... mais je n'ai rien trouvé. J'ai donc tout implémenté manuellement ce qui n'est pas formidable pour le maintient du code. J'ai donc implémenté également plusieurs tests unitaires.&lt;/p&gt;
&lt;p&gt;Au final, les cas où les symboles monnétaires sont espacés des nombres par un espace pose problème, mais j'ai choisi de laisser tel quel car je ne vois pas de solution pratique (je ne vois plus grand chose en fait).&lt;/p&gt;
&lt;p&gt;Chose intéressante, mon implémentation à base de transducteur est plus rapide de près de 40% que le composant WhitespaceTokenizer sur un petit corpus de test, mais d'autres tests donnent les deux annotateurs ex-aequo. La qualité du résultat est sans comparaison, comme l'illustre l'exemple ci-dessous :&lt;/p&gt;
&lt;pre&gt; &amp;quot;Le Roi a reçu en audience en début d’après-midi au Château&lt;/pre&gt;
&lt;p&gt;Résultat du WhitespaceTokenizer : &lt;em&gt;{&amp;quot;, Le, Roi, a, reçu, en, audience, en, début, d, ’, après, -, midi, au, Château}&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Résultat de notre composant : &lt;em&gt;{&amp;quot;, Le, Roi, a, reçu, en, audience, en, début, d’, après-midi, au, Château}&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Distribution&lt;/h3&gt;
&lt;p&gt;Les jar avec les sources et le descripteur sont disponibles &lt;a href=&quot;http://uima.fabienpoulard.info/download/french-unicode-tokenizer-v1.0.jar&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;J'ai également ouvert &lt;a href=&quot;http://github.com/grdscarabe/uima-word-tokenizer&quot;&gt;un dépôt sur github&lt;/a&gt; pour ceux qui voudraient contribuer.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Calculer le recouvrement de deux textes avec NLTK</title>
    <link>http://fabienpoulard.info/post/2010/08/26/Calculer-le-recouvrement-de-deux-textes-avec-NLTK</link>
    <guid isPermaLink="false">urn:md5:c3b41b8dbcdfdc80f383c7f775d8833e</guid>
    <pubDate>Thu, 26 Aug 2010 00:11:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>nlp</category><category>nltk</category><category>python</category>    
    <description>&lt;p&gt;Mon travail de thèse, sobrement intitulée &lt;em&gt;Détection de dérivations de texte&lt;/em&gt;, consiste à évaluer la probabilité qu'un texte dérive d'un autre. Une des applications, que je déteste mais qui a l'avantage de parler à la plupart des gens, est la détection de plagiat.&lt;/p&gt;


&lt;p&gt;Une approche, naïve mais simple à mettre en œuvre, consiste à calculer le nombre de mots que deux textes partagent. Voici une proposition d'implémentation d'une telle technique tirant partie de la &lt;a href=&quot;http://www.nltk.org&quot; hreflang=&quot;en&quot;&gt;bibliothèque NLTK&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;Le calcul de la couverture en terme de mots de deux textes n'a rien de bien compliqué dans la mesure où&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;il nous est possible de découper le texte en mots&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;nous savons compter le nombre de mots qu'ils ont en commun.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour le découpage en mots, nous allons utiliser la &lt;a href=&quot;http://www.nltk.org&quot; hreflang=&quot;en&quot;&gt;bibliothèque NLTK&lt;/a&gt; (j'utilise la version bêta de la 2.0) qui propose une méthode &lt;em&gt;word_tokenize&lt;/em&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; nltk
nltk.&lt;span style=&quot;color: black;&quot;&gt;word_tokenize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;A sentence to be tokenized&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;u&lt;span style=&quot;color: #483d8b;&quot;&gt;'A'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'sentence'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'to'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'be'&lt;/span&gt;, u&lt;span style=&quot;color: #483d8b;&quot;&gt;'tokenized'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le tokeniseur est loin d'être parfait, notamment pour les textes qui ne sont pas de l'anglais, mais il fonctionne suffisamment bien pour l'utilisation que nous en avons. Ce serait beaucoup plus problématique pour une tâche de recherche d'information par exemple.&lt;/p&gt;


&lt;p&gt;Nous passerons donc le contenu des fichiers à comparer à cette fonction qui nous retourne la liste des mots correspondant. Il nous faut alors calculer l'intersection des deux listes de mots.&lt;/p&gt;


&lt;p&gt;Les objets &lt;em&gt;set&lt;/em&gt; offrent une méthode &lt;em&gt;intersection&lt;/em&gt; qui ferait l'affaire. Cependant la conversion en un ensemble va faire disparaître les doublons, or nous aimerions avoir un recouvrement aussi précis que possible. Nous définissons donc une fonction qui va calculer l'intersection de deux listes. Elle peut certainement être largement améliorée (ne pas hésiter à proposer une correction), mais suffira pour l'exemple&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; intersect_list&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst1, lst2&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
	Calcule l'intersection entre deux listes
	&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Intersection&lt;/span&gt;
	inter = &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Calcul des éléments en commun&lt;/span&gt;
	common = &lt;span style=&quot;color: #008000;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst1&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;intersection&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst2&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Construction de la liste commune&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; e &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; common:
		nbe = &lt;span style=&quot;color: #008000;&quot;&gt;min&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst1.&lt;span style=&quot;color: black;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;, lst2.&lt;span style=&quot;color: black;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;nbe&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:
			inter.&lt;span style=&quot;color: black;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; inter&lt;/pre&gt;


&lt;p&gt;Nous avons désormais en main tous les éléments nécessaire pour écrire un petit script qui calculera le taux de recouvrement en mots entre deux fichiers textes.&lt;/p&gt;


&lt;p&gt;Voici le script complet pour ceux que ça intéresse&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;python python&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#! /usr/bin/python&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# -*- coding: utf-8 -*-&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Script permettant de calculer le taux de recouvrement en mots entre les&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# deux textes passés en paramètre.&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; nltk
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;os&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;path&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; loadTxt&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;fic&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
	Charge le contenu textuel du fichier en paramètre
	&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
	fh  = &lt;span style=&quot;color: #dc143c;&quot;&gt;codecs&lt;/span&gt;.&lt;span style=&quot;color: #008000;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;fic, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;r&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;, errors=&lt;span style=&quot;color: #483d8b;&quot;&gt;'ignore'&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	txt = fh.&lt;span style=&quot;color: black;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	fh.&lt;span style=&quot;color: black;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; txt
&amp;nbsp;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; intersect_list&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst1, lst2&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:
	&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
	Calcule l'intersection entre deux listes
	&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Intersection&lt;/span&gt;
	inter = &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Calcul des éléments en commun&lt;/span&gt;
	common = &lt;span style=&quot;color: #008000;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst1&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;intersection&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst2&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Construction de la liste commune&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; e &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; common:
		nbe = &lt;span style=&quot;color: #008000;&quot;&gt;min&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;lst1.&lt;span style=&quot;color: black;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;, lst2.&lt;span style=&quot;color: black;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
		&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;nbe&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:
			inter.&lt;span style=&quot;color: black;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; inter
&amp;nbsp;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Vérifie qu'il y a bien deux fichiers passés en paramètre du script&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt; == &lt;span style=&quot;color: #ff4500;&quot;&gt;3&lt;/span&gt;:
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Charge les textes des fichiers&lt;/span&gt;
	txt1 = loadTxt&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	txt2 = loadTxt&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Tokenisation en mots&lt;/span&gt;
	txt1toks = nltk.&lt;span style=&quot;color: black;&quot;&gt;word_tokenize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;txt1&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	txt2toks = nltk.&lt;span style=&quot;color: black;&quot;&gt;word_tokenize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;txt2&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Calcul de la couverture&lt;/span&gt;
	incommon = intersect_list&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;txt1toks, txt2toks&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Affichage&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Couverture de %s par rapport à %s&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;%f&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;incommon&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;/&lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;txt1toks&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Couverture de %s par rapport à %s&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;%f&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;incommon&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;/&lt;span style=&quot;color: #008000;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;txt2toks&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;else&lt;/span&gt;:
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;Utilisation :&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;%s &amp;lt;fichier 1&amp;gt; &amp;lt;fichier 2&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Bien entendu, le taux de recouvrement en mots n'est pas très performant pour évaluer le degré de dérivation entre deux textes. Une manière de l'améliorer serait de calculer le taux de recouvrement de n-grammes plutôt. J'attends vos propositions :)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Parcours des annotations couvertes par une autre annotation</title>
    <link>http://fabienpoulard.info/post/2010/04/01/Parcours-des-annotations-couvertes-par-une-autre-annotation</link>
    <guid isPermaLink="false">urn:md5:fc104c8e958a296686565b3a48741a22</guid>
    <pubDate>Thu, 01 Apr 2010 11:11:00 +0200</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>uima</category>    
    <description>&lt;p&gt;Lorsque l'on travaille avec &lt;a href=&quot;http://incubator.apache.org/uima/&quot; hreflang=&quot;en&quot;&gt;Apache UIMA&lt;/a&gt; et que l'on ajoute un nombre important d'annotations, il arrive un moment où l'on va vouloir filtrer certaines de ces annotations en fonction d'autres. Ainsi, assez couramment on éprouve le besoin de devoir récupérer des annotations qui couvrent la même zone de texte qu'une autre. Par exemple&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;récupérer les mots contenus dans une phrases&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;récupérer les paragraphes dans un document&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Il y a au moins deux approches dans Apache UIMA qui permettent de répondre à ce besoin&amp;nbsp;: le &lt;a href=&quot;http://incubator.apache.org/uima/apidocs/org/apache/uima/cas/text/AnnotationIndex.html#subiterator%28org.apache.uima.cas.text.AnnotationFS%29&quot; hreflang=&quot;en&quot;&gt;subiterator&lt;/a&gt; et le &lt;a href=&quot;http://incubator.apache.org/uima/apidocs/org/apache/uima/cas/FSMatchConstraint.html&quot; hreflang=&quot;en&quot;&gt;FSMatchConstraint&lt;/a&gt;.&lt;/p&gt;    &lt;h2&gt;Utilisation du subiterator&lt;/h2&gt;


&lt;p&gt;L'approche basée sur le subiterator ne peut fonctionner que si les types que l'on cherche à accéder sont couverts par le type couvrant au sens de UIMA, c-à-d en terme de priorité des types (cf. &lt;a href=&quot;http://incubator.apache.org/uima/downloads/releaseDocs/2.3.0-incubating/docs/api/org/apache/uima/resource/metadata/TypePriorities.html&quot; hreflang=&quot;en&quot;&gt;[la javadoc de TypePriorities&lt;/a&gt;] ou &lt;a href=&quot;http://osdir.com/ml/apache.uima.general/2008-03/msg00030.html&quot;&gt;cet email&lt;/a&gt;).&lt;/p&gt;


&lt;p&gt;Considérons une annotation A qui couvre des annotations B de la manière suivante&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
Il y a du texte et les annotations sont sur ce texte ...
[-----A:1-----]   [---A:2---]  [--------A:3--------]
 [B:1] [B:2]       [B:3]        [B:4]  [B:5] [B:6]
&lt;/pre&gt;


&lt;p&gt;Dans l'exemple ci-dessus, nous sommes intéressés par les annotations B couvertes par l'annotation A:3, en d'autres termes les annotations B:4, B:5 et B:6.&lt;/p&gt;


&lt;p&gt;La méthode est la suivante&amp;nbsp;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;On récupère un pointeur sur l'annotation couvrante qui nous intéresse (A:3), à l'aide d'un itérateur par exemple&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;On récupére l'index des annotations couvertes (les B)&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;On appelle la méthode subiterator de l'index des annotations couvertes (B) en passant en paramètre l'annotation couvrante (A:3), la méthode nous retourne un itérateur sur les annotations B couvertes par A:3, soit B:4, B:5 et B:6.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Voici le code correspondant&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;java&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Récupération des index&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;AnnotationIndex annAIdx = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;AnnotationIndex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; jcas.&lt;span style=&quot;color: #006600;&quot;&gt;getAnnotationIndex&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;A.&lt;span style=&quot;color: #006600;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;AnnotationIndex annBIdx = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;AnnotationIndex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; jcas.&lt;span style=&quot;color: #006600;&quot;&gt;getAnnotationIndex&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;B.&lt;span style=&quot;color: #006600;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On recherche ''A:3''&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;FSIterator annAIt = annAIdx.&lt;span style=&quot;color: #006600;&quot;&gt;iterator&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;annAIt.&lt;span style=&quot;color: #006600;&quot;&gt;hasNext&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  A monA3 = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;A&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; annAIt.&lt;span style=&quot;color: #006600;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On récupére l'itérateur sur les annotations B couvertes par A3&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  FSIterator annBSousA3It = annBIdx.&lt;span style=&quot;color: #006600;&quot;&gt;subiterator&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;monA3&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #b1b100;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;annBSousA3It.&lt;span style=&quot;color: #006600;&quot;&gt;hasNext&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On récupére successivement B4, B5 et B6&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    B annB = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;B&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; annBSousA3It.&lt;span style=&quot;color: #006600;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Sous A3 : &amp;quot;&lt;/span&gt;+annB&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;h3&gt;Utilisation des contraintes (FSMatchConstraint)&lt;/h3&gt;


&lt;p&gt;Lorsque l'on ne connaît pas les priorités des types ou bien qu'elles ne correspondent pas à ce que l'on souhaite faire, il est nécessaire de passer par un mécanisme plus complexe (mais beaucoup plus puissant)&amp;nbsp;: le système de contraintes d'index.&lt;/p&gt;


&lt;p&gt;Dans le cas présent, nous allons définir &lt;a href=&quot;http://incubator.apache.org/uima/downloads/releaseDocs/2.3.0-incubating/docs/api/org/apache/uima/cas/ConstraintFactory.html&quot; hreflang=&quot;en&quot;&gt;une contrainte&lt;/a&gt; imposant que les attributs &lt;em&gt;begin&lt;/em&gt; et &lt;em&gt;end&lt;/em&gt; d'une annotation d'un type donné correspondent à une certaine valeur&amp;nbsp;: celle de l'annotation couvrante. Puis nous pourrons générer un itérateur qui retournera les annotations de l'index qui respectent cette contrainte.&lt;/p&gt;


&lt;p&gt;Voici l'implémentation d'une méthode qui fait cela&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;java&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* This method provides an iterator over typed annotations that either &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* have an offset embedded in that of a given annotation in a document, &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* or have the same offset as these annotation. &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @param theDocument  the document in which stand the source and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         target annotations&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @param theAnnotation  the source annotation under which target &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         annotations that have to be drawn out&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @param theType            the type of the target annotations that have &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         to be drawn out from the document under &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         the source annotation&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @param isStrict              the boolean that defines the offset matching,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         offsets strictly equal if isStrict is true, begin &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         offsets greater or equal and end offsets less &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                         or equal otherwise.  	&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @return                           the iterator over the type theType annotations &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                          which stand under the annotation theAnnotation &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*                                          in the document theDocument &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @author Fabien Poulard&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @author Jérôme Rocheteau&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* @license Apache 2.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; FSIterator subiterator&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;JCas theDocument, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Annotation&lt;/span&gt; theAnnotation,Type theType,&lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; isStrict&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Ajout: déclaration de la variable type&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	Type theAnnotationType = theAnnotation.&lt;span style=&quot;color: #006600;&quot;&gt;getType&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On utilise le constraint factory&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	ConstraintFactory theConstraints = theDocument.&lt;span style=&quot;color: #006600;&quot;&gt;getConstraintFactory&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On définit les contraintes sur le début de l'annotation&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSIntConstraint beginConstraint = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;createIntConstraint&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;isStrict&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		beginConstraint.&lt;span style=&quot;color: #006600;&quot;&gt;eq&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theAnnotation.&lt;span style=&quot;color: #006600;&quot;&gt;getBegin&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		beginConstraint.&lt;span style=&quot;color: #006600;&quot;&gt;geq&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theAnnotation.&lt;span style=&quot;color: #006600;&quot;&gt;getBegin&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	Feature beginFeature = theAnnotationType.&lt;span style=&quot;color: #006600;&quot;&gt;getFeatureByBaseName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;begin&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FeaturePath beginPath = theDocument.&lt;span style=&quot;color: #006600;&quot;&gt;createFeaturePath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	beginPath.&lt;span style=&quot;color: #006600;&quot;&gt;addFeature&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;beginFeature&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSMatchConstraint begin = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;embedConstraint&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;beginPath,beginConstraint&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// ... puis sur la fin de l'annotation&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSIntConstraint endConstraint = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;createIntConstraint&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;isStrict&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		endConstraint.&lt;span style=&quot;color: #006600;&quot;&gt;eq&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theAnnotation.&lt;span style=&quot;color: #006600;&quot;&gt;getEnd&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		endConstraint.&lt;span style=&quot;color: #006600;&quot;&gt;leq&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theAnnotation.&lt;span style=&quot;color: #006600;&quot;&gt;getEnd&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	Feature endFeature = theAnnotationType.&lt;span style=&quot;color: #006600;&quot;&gt;getFeatureByBaseName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;end&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FeaturePath endPath = theDocument.&lt;span style=&quot;color: #006600;&quot;&gt;createFeaturePath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	endPath.&lt;span style=&quot;color: #006600;&quot;&gt;addFeature&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;endFeature&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSMatchConstraint end = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;embedConstraint&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;endPath, endConstraint&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// JR: on définit une contrainte sur le type d'annotation&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSTypeConstraint typeConstraint = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;createTypeConstraint&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	typeConstraint.&lt;span style=&quot;color: #006600;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FeaturePath typePath = theDocument.&lt;span style=&quot;color: #006600;&quot;&gt;createFeaturePath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSMatchConstraint type = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;embedConstraint&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;typePath, typeConstraint&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On combine les contraintes&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSMatchConstraint beginAndEnd = theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;type,theConstraints.&lt;span style=&quot;color: #006600;&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;begin, end&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On génère un itérateur respectant ces contraintes&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	FSIterator filteredIterator =&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	theDocument.&lt;span style=&quot;color: #006600;&quot;&gt;createFilteredIterator&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theDocument.&lt;span style=&quot;color: #006600;&quot;&gt;getAnnotationIndex&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;iterator&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, beginAndEnd&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; filteredIterator&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Cette méthode prend en paramètre le JCas dans lequel travailler, l'annotation couvrante (l'annotation A3 dans l'exemple précédent), le type d'annotation qui nous intéresse (le type B pour reprendre l'exemple précédent) et un booléen qui permet de préciser si l'on souhaite une correspondance exacte ou approximative des frontières.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Tests unitaires pour UIMA avec UUTUC</title>
    <link>http://fabienpoulard.info/post/2010/03/16/Tests-unitaires-pour-UIMA-avec-UUTUC</link>
    <guid isPermaLink="false">urn:md5:501c8c65b198be3c46fb1a1e2dd7b135</guid>
    <pubDate>Tue, 16 Mar 2010 15:45:00 +0100</pubDate>
    <dc:creator>Fabien Poulard</dc:creator>
        <category>Sciences &amp; Recherche</category>
        <category>java</category><category>testing</category><category>these</category><category>uima</category>    
    <description>&lt;p&gt;La qualité du code  développé dans le cadre des activités de recherche scientifique n'est pas toujours aussi bon qu'on pourrait l'espérer. Outre &lt;a href=&quot;http://www.framablog.org/index.php/post/2010/03/07/recherche-scientifique-code-informatique&quot; hreflang=&quot;fr&quot;&gt;la nécessité (évidente à mes yeux) d'ouvrir le codes des activités scientifiques&lt;/a&gt; financées par l'État et les collectivités territoriales, il est également nécessaire de suivre de bonnes pratiques de programmation. L'écriture de tests unitaires et leur exécution régulière est une de ces bonnes pratiques.&lt;/p&gt;


&lt;p&gt;Je présente dans ce billet un cas d'utilisation de la bibliothèque &lt;a href=&quot;http://code.google.com/p/uutuc/&quot; hreflang=&quot;en&quot;&gt;UUTUC&lt;/a&gt;, présentée lors du &lt;a href=&quot;http://www.aclweb.org/anthology/W/W09/#1500&quot; hreflang=&quot;en&quot;&gt;Workshop sur l'Ingénierie Logiciel, les Tests et l'Assurance Qualité pour le Traitement des Langues Naturelles (SETQA-NLP 2009)&lt;/a&gt;, pour tester l'implémentation d'une bibliothèque développée et utilisée dans le cadre de ma thèse (tddts-uima-shingling).&lt;/p&gt;    &lt;h2&gt;Principe de UUTUC&lt;/h2&gt;


&lt;p&gt;&lt;a href=&quot;http://code.google.com/p/uutuc/&quot; hreflang=&quot;en&quot;&gt;UUTUC&lt;/a&gt; est une bibliothèque offrant un certain nombre de méthodes facilitant le processus de test des composants UIMA. On y trouve notamment un certain nombre de classes de type &lt;em&gt;&lt;a href=&quot;http://fr.wikipedia.org/wiki/Fabrique_%28patron_de_conception%29&quot; hreflang=&quot;fr&quot;&gt;Factory&lt;/a&gt;&lt;/em&gt; qui facilitent la mise en place de chaînes de traitement simples pour expérimenter les composants.&lt;/p&gt;


&lt;p&gt;À l'aide de ces classes, l'exécution d'un AE sur un simple fichier texte se résume à ces quelques lignes&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;java&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;AnalysisEngine engine = &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  AnalysisEngineFactory.&lt;span style=&quot;color: #006600;&quot;&gt;createAnalysisEngineFromPath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;descriptors/tutorial/ex1/RoomNumberAnnotator.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;JCas jCas = &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  AnalysisEngineFactory.&lt;span style=&quot;color: #006600;&quot;&gt;process&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;engine, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;data/WatsonConferenceRooms.txt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Le couplage de UUTUC avec &lt;a href=&quot;http://www.junit.org/&quot; hreflang=&quot;en&quot;&gt;JUnit&lt;/a&gt; permet de mettre en place un banc de tests unitaires&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Afin de tester la conformité de l'implémentation avec les spécifications attendues&amp;nbsp;;&lt;/li&gt;
&lt;li&gt;Prévenir les problèmes de régression lors de l'évolution des composants&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Écriture de tests unitaires&lt;/h2&gt;


&lt;p&gt;J'utilise le framework JUnit 4 pour les tests unitaires. Il suffit de faire précéder les méthodes considérées comme des tests par &lt;em&gt;@Test&lt;/em&gt; pour qu'elles soient reconnues comme telles par JUnit. Exemple&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;java&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.Test;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #a1a100;&quot;&gt;import static org.junit.Assert.*;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* This class defines the tests for the main methods of the Shingle class.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ShingleTest &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;  * This method just checks that the isComplete method works&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;  * @throws InvalidShingleException &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;  * @throws OverloadShingleException &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;  */&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  @Test&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; completeness&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; InvalidShingleException, OverloadShingleException &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	Shingle s1 = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Shingle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	assertFalse&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; s1.&lt;span style=&quot;color: #006600;&quot;&gt;isComplete&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// before any adding&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	s1.&lt;span style=&quot;color: #006600;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; theShingleItems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	assertFalse&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; s1.&lt;span style=&quot;color: #006600;&quot;&gt;isComplete&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// after a first adding&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	s1.&lt;span style=&quot;color: #006600;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; theShingleItems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	assertTrue&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; s1.&lt;span style=&quot;color: #006600;&quot;&gt;isComplete&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// should be complete by now&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Combiné à UUTUC, il permet de mettre en place un environnement UIMA assez simplement. Ainsi dans l'exemple ci-dessous, nous définissons une méthode à exécuter avant chaque test (&lt;em&gt;@Before&lt;/em&gt;) qui crée un JCas et y ajoute quelques annotations à l'aide des Factory de UUTUC&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;java&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** Static data for testing */&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; CAS_CONTENT = &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;   &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Suisse : inauguration d'une nouvelle synagogue, une première depuis 50 ans&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; CAS_OFFSETS = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;9&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;22&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;24&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;27&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;   &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;28&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;36&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;37&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;46&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;48&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;51&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;52&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;61&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;67&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;68&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;74&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* This method is used to set up the testing environment, creating the&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;* data necessary for the different tests methods.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;@Before &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setUp&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; UIMAException, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;IOException&lt;/span&gt;, ShinglingTestingException &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Set up a CAS with a couple of shingle items in&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	TypeSystemDescription tsd = TypeSystemDescriptionFactory&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			.&lt;span style=&quot;color: #006600;&quot;&gt;createTypeSystemDescription&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;shingling-ts&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	theTestingCas = JCasFactory.&lt;span style=&quot;color: #006600;&quot;&gt;createJCas&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;tsd&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	theTestingCas.&lt;span style=&quot;color: #006600;&quot;&gt;setDocumentText&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;CAS_CONTENT&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; idx: CAS_OFFSETS&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		AnnotationFactory.&lt;span style=&quot;color: #006600;&quot;&gt;createAnnotation&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;theTestingCas, &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						idx&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, idx&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, ShingleItem.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Malheureusement il y a assez peu de documentation concernant UUTUC. Il est ainsi régulièrement nécessaire d'aller jeter un œil &lt;a href=&quot;http://code.google.com/p/uutuc/source/browse/trunk/uutuc/src/main/java/org/uutuc/factory/&quot;&gt;au code source&lt;/a&gt; qui heureusement est très bien écrit.&lt;/p&gt;


&lt;h2&gt;Intégration avec Maven&lt;/h2&gt;


&lt;p&gt;Maven modélisant toutes les étapes du cycle de développement, il intègre une étape &lt;em&gt;test&lt;/em&gt; entre le &lt;em&gt;compile&lt;/em&gt; et le &lt;em&gt;package&lt;/em&gt;. La gestion des tests unitaires se faisant quant à eux au travers du plugin &lt;a href=&quot;http://maven.apache.org/plugins/maven-surefire-plugin/&quot; hreflang=&quot;en&quot;&gt;maven-surefire-plugin&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Il faut tout d'abord rajouter dans le &lt;em&gt;pom.xml&lt;/em&gt; les informations de dépendance sur UUTUC et JUnit&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;repository&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;snapshots&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;enabled&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;false&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/enabled&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/snapshots&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;id&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;uutuc-googlecode&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/id&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;uutuc Google Code repository&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;url&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;http://uutuc.googlecode.com/svn/repo/&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/url&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/repository&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- UUTUC for testing --&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.uutuc&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;uutuc&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;0.9.10&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;optional&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;false&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/optional&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- JUnit 4 for testing --&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;junit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;junit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;4.3.1&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Il suffit ensuite de faire appel au plugin &lt;em&gt;maven-surefire-plugin&lt;/em&gt; qui prend en charge tout ce qui concerne les tests, sous réserve que ces derniers soient bien présents dans &lt;em&gt;src/test/java&lt;/em&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Testing --&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;plugin&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.apache.maven.plugins&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;maven-surefire-plugin&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;configuration&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;reportFormat&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;brief&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/reportFormat&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;useFile&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;false&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/useFile&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/configuration&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/plugin&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Il est alors possible de lancer l'exécution des tests avec Maven&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
$ mvn test
...
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running tddts.uima.shingling.ShingleTest
Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.992 sec

Results :

Tests run: 16, Failures: 0, Errors: 0, Skipped: 0
...
&lt;/pre&gt;


&lt;p&gt;Plus d'excuse pour ne pas tester votre code maintenant&amp;nbsp;! L'excuse de faire du prototypage pour la recherche n'en est pas une bonne dès que les résultats que vous publiez dépendent de la qualité dudit code. C'est votre intégrité et honnêteté scientifique qui est en jeux ;)&lt;/p&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>