{"id":76,"date":"2019-04-01T09:06:55","date_gmt":"2019-04-01T09:06:55","guid":{"rendered":"http:\/\/www.lexique.org\/?page_id=76"},"modified":"2019-12-10T09:18:55","modified_gmt":"2019-12-10T09:18:55","slug":"comment-interroger-lexique-avec-python","status":"publish","type":"page","link":"http:\/\/www.lexique.org\/?page_id=76","title":{"rendered":"Comment interroger Lexique avec Python"},"content":{"rendered":"\n<p>This example shows how to select four random sets of twenty nouns and\n verbs of low and high frequencies from Lexique382, using Python. (If \nyou have not already, install Python: Go to <a href=\"https:\/\/www.anaconda.com\/distribution\/\">https:\/\/www.anaconda.com\/distribution\/<\/a> ; Select your OS (Windows, MacOS or Linux) and download the Python 3.7 installer.)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\"\"\" Exemple de s\u00e9lection d'items dans la base Lexique382 \"\"\"\n\nimport pandas as pd\n\n\nlex = pandas.read_csv('http:\/\/www.lexique.org\/databases\/Lexique382\/Lexique382.tsv', sep='\\t')\n\n# alternatively, you can download the table locally:\n# lex = pd.read_csv(\"Lexique382.tsv\", sep='\\t')\n\nlex.head()\n\n# restreint la recherche \u00e0 des mots de longueur comprises entre 5 et 8 lettres\nsubset = lex.loc[(lex.nblettres >= 5) &amp; (lex.nblettres &lt;=8)]\n\n# separe les noms et les verbes dans deux dataframes:\nnoms = subset.loc[subset.cgram == 'NOM']\nverbs = subset.loc[subset.cgram == 'VER']\n\n# sectionne sur la bases de la fr\u00e9quence lexicale\nnoms_hi = noms.loc[noms.freqlivres > 50.0]\nnoms_low = noms.loc[(noms.freqlivres &lt; 10.0) &amp; (noms.freqlivres > 1.0)]\n\nverbs_hi = verbs.loc[verbs.freqlivres > 50.0]\nverbs_low = verbs.loc[(verbs.freqlivres &lt; 10.0) &amp; (verbs.freqlivres > 1.0)]\n\n# choisi des items tir\u00e9s au hasard dans chacun des 4 sous-ensembles:\nN = 20\nnoms_hi.sample(N).ortho.to_csv('nomhi.txt', index=False)\nnoms_low.sample(N).ortho.to_csv('nomlo.txt', index=False)\nverbs_hi.sample(N).ortho.to_csv('verhi.txt', index=False)\nverbs_hi.sample(N).ortho.to_csv('verlo.txt', index=False)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This example shows how to select four random sets of twenty nouns and verbs of low and high frequencies from Lexique382, using Python. (If you have not already, install Python: Go to https:\/\/www.anaconda.com\/distribution\/ ; Select your OS (Windows, MacOS or Linux) and download the Python 3.7 installer.)<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":294,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-76","page","type-page","status-publish","hentry","post-preview"],"_links":{"self":[{"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/pages\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.lexique.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":2,"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/pages\/76\/revisions"}],"predecessor-version":[{"id":81,"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/pages\/76\/revisions\/81"}],"up":[{"embeddable":true,"href":"http:\/\/www.lexique.org\/index.php?rest_route=\/wp\/v2\/pages\/294"}],"wp:attachment":[{"href":"http:\/\/www.lexique.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}