From 625c7a044c3c944683762b7bb75dec9dd5b53fb9 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 28 Feb 2010 18:06:10 +0100 Subject: pyAggr3g470r can now detect the language of an article thanks to the module oice.langdet. --- pyAggr3g470r.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index c197033f..e1251664 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -131,6 +131,7 @@ class Root: def management(self): """ + Management of articles. """ self.articles, self.feeds = utils.load_feed() html = htmlheader @@ -174,7 +175,27 @@ class Root: html += "\n" utils.create_histogram(top_words) html += """""" - html += "
\n" + + nb_french = 0 + nb_english = 0 + nb_other = 0 + for rss_feed_id in self.articles.keys(): + for article in self.articles[rss_feed_id]: + if article[6] == 'french': + nb_french += 1 + elif article[6] == 'english': + nb_english += 1 + else: + nb_other +=1 + + html += "

Languages

\n" + html += "\n" + html += "
\n" html += htmlfooter return html @@ -274,7 +295,9 @@ class Root: html += description else: html += "No description available." - html += """
\nComplete story\n
\n""" % \ + html += "
\n" + html += """This article is written in %s.""" % (article[6],) + html += """
Complete story\n
\n""" % \ (article[3].encode('utf-8'),) # Share this article: # on delicious @@ -310,7 +333,7 @@ class Root: def all_articles(self, feed_id): """ - Display all articles of a feed ('feed_title'). + Display all articles of a feed. """ html = htmlheader html += htmlnav @@ -357,7 +380,7 @@ class Root: def unread(self, feed_id): """ - Display all unread articles of a feed ('feed_title'). + Display all unread articles of a feed. """ html = htmlheader html += htmlnav @@ -393,6 +416,30 @@ class Root: unread.exposed = True + def language(self, lang): + """ + """ + html = htmlheader + html += htmlnav + html += """
""" + + html += """

Article(s) written in %s

""" % (lang,) + + for rss_feed_id in self.articles.keys(): + for article in self.articles[rss_feed_id]: + if article[6] == lang: + html += article[1].encode('utf-8') + \ + """ - %s + from %s
\n""" % \ + (article[0].encode('utf-8'), article[2].encode('utf-8'), \ + self.feeds[rss_feed_id][5].encode('utf-8'), \ + self.feeds[rss_feed_id][3].encode('utf-8')) + + html += "
\n" + html += htmlfooter + return html + + language.exposed = True def mark_as_read(self, target): """ -- cgit