Anonymous avatar Anonymous committed 89de35b

Code cleanup

Comments (0)

Files changed (2)

+syntax: glob
+*.pyc
+*.pyo
+*.db
+.DS_Store
+settings.py
+
+*~
     settings.OAUTH_TOKEN_SECRET,
     )
 
+stopwords = [
+    "alors", "au", "aucuns", "aussi", "autre", "avant", "avec", "avoir",
+    "bon",
+    "car", "ce", "cela", "ces", "ceux", "chaque", "ci", "comme",
+    "comment",
+    "dans", "des", "du", "de", "dedans", "dehors", "depuis", "deux",
+    "devrait",
+    "doit", "donc", "dos", "droite", "début", "elle", "elles", "en",
+    "encore",
+    "essai", "est", "et", "eu", "fait", "faites", "fois", "font",
+    "force", "haut",
+    "hors", "ici", "il", "ils", "je juste", "la", "le", "les",
+    "leur",
+    "là", "ma", "maintenant", "mais", "mes", "mine", "moins", "mon",
+    "mot",
+    "même", "ni", "nommés", "notre", "nous", "nouveaux", "ou", "où",
+    "par",
+    "parce", "parole", "pas", "personnes", "peut", "peu", "pièce",
+    "plupart",
+    "pour", "pourquoi", "quand", "que", "quel", "quelle", "quelles",
+    "quels",
+    "qui", "sa", "sans", "ses", "seulement", "si", "sien", "son",
+    "sont", "sous",
+    "soyez sujet", "sur", "ta", "tandis", "tellement", "tels", "tes",
+    "ton",
+    "tous", "tout", "trop", "très", "tu", "valeur", "voie", "voient",
+    "vont",
+    "votre", "vous", "vu", "ça", "étaient", "état", "étions", "été",
+    "être"]
+
 
 class IRCToTumblr(bot.SingleServerIRCBot):
 
         if settings.BOT_NAME in ev.arguments()[0]:
             if "photo" in ev.arguments()[0]:
                 pic = self.parse_ask("photo", ev.arguments()[0])
-                client.create_photo(
-                    settings.BLOG_NAME, source=pic)
                 serv.privmsg(settings.CHAN_NAME, "Et voila : " + pic)
 
             elif "vidéo" in ev.arguments()[0]:
                 if video.startswith("http"):
                     client.create_video(settings.BLOG_NAME, embed=video)
                 serv.privmsg(settings.CHAN_NAME, "Et voila : " + video)
-
             else:
-
                 serv.privmsg(
                     settings.CHAN_NAME,
                     unicode(ia_bot.responding(ev.arguments()[0])))
+
         response = self.parse(ev.arguments()[0])
         user = ev.source().split('!')[0]
         if response is not None:
 
     def parse_ask(self, arg, query):
         query = query.split(arg)[1]
-        if "de" in query:
-            query = query.split("de")[1]
-        if "?" in query:
-            query = query.split("?")[0]
-        print arg == "vidéo"
+        for a in query.split(" "):
+            if a in stopwords:
+                query = query.replace(a, " ")
+        query = query.strip()
+
         if arg == "photo":
             resp = photo_query.get_query(query)
             if len(resp) == 0:
                 return u"J'ai rien :("
             else:
-                return choice(resp)
+                pic = choice(resp)
+                resp = client.create_photo(
+                    settings.BLOG_NAME, source=pic)
+                return pic
         elif arg == "vidéo":
             resp = get_video(query)
             if len(resp) == 0:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.