|
|
@@ -1,10 +1,72 @@
|
|
|
-import fr_core_news_md
|
|
|
+import en_core_web_lg
|
|
|
+import fr_core_news_md # @UnusedImport
|
|
|
+from core import logging_
|
|
|
|
|
|
|
|
|
-nlp = fr_core_news_md.load()
|
|
|
+logger = logging_.getLogger("nlp")
|
|
|
|
|
|
+logger.info("Nestor se réveille...")
|
|
|
+# nlp = fr_core_news_md.load()
|
|
|
+nlp = en_core_web_lg.load()
|
|
|
+logger.info("> Ok")
|
|
|
|
|
|
-def repond(message):
|
|
|
+def submit(command):
|
|
|
+ logger.info("""Message reçu: "%s" """, command)
|
|
|
+ doc = nlp(command)
|
|
|
+
|
|
|
+ for token in doc:
|
|
|
+ logger.debug("\tJeton: %s", token.text)
|
|
|
+ logger.debug("\t\t* Lemma: %s", token.lemma_)
|
|
|
+ logger.debug("\t\t* Position: %s", token.pos_)
|
|
|
+ logger.debug("\t\t* Tag: %s", token.tag_)
|
|
|
+ logger.debug("\t\t* Dependance: %s", token.dep_)
|
|
|
+ logger.debug("\t\t* Forme: %s", token.shape_)
|
|
|
+ logger.debug("\t\t* Alphanum.: %s", token.is_alpha)
|
|
|
+ logger.debug("\t\t* Stop: %s", token.is_stop)
|
|
|
+
|
|
|
+ for ent in doc.ents:
|
|
|
+ logger.debug("\tEntité: %s", ent.text)
|
|
|
+ logger.debug("\t\t* Start: %s", ent.start_char)
|
|
|
+ logger.debug("\t\t* End: %s", ent.end_char)
|
|
|
+ logger.debug("\t\t* Label: %s", ent.label_)
|
|
|
+
|
|
|
+ unused = []
|
|
|
+ for i in range(len(doc)):
|
|
|
+ token = doc[i]
|
|
|
+ if token.lemma_ == "copy":
|
|
|
+ for j in range(i, len(doc)):
|
|
|
+ token = doc[j]
|
|
|
+ if token.lemma_ in ["from"]:
|
|
|
+ from_ = doc[j + 1].text
|
|
|
+ if token.lemma_ in ["to", "in"]:
|
|
|
+ to_ = doc[j + 1].text
|
|
|
+
|
|
|
+ logger.info("Vous voulez copier %s vers %s", from_, to_)
|
|
|
+ break
|
|
|
+
|
|
|
+ if token.lemma_ == "delete":
|
|
|
+ what = doc[i + 1]
|
|
|
+ logger.info("Vous voulez supprimer %s", what)
|
|
|
+ break
|
|
|
+
|
|
|
+ if token.lemma_ == "rename":
|
|
|
+ logger.info("Vous voulez renommer")
|
|
|
+
|
|
|
+ if token.lemma_ == "move":
|
|
|
+ logger.info("Vous voulez déplacer")
|
|
|
+
|
|
|
+ if token.lemma_ == "open":
|
|
|
+ logger.info("Vous voulez ouvrir")
|
|
|
+
|
|
|
+ if token.lemma_ == "new":
|
|
|
+ logger.info("Vous voulez créer")
|
|
|
+
|
|
|
+ logger.debug("Connais pas: %s", token.text)
|
|
|
+ unused.append(token)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+def analyse(message):
|
|
|
doc = nlp(message)
|
|
|
|
|
|
for token in doc:
|
|
|
@@ -12,4 +74,11 @@ def repond(message):
|
|
|
token.shape_, token.is_alpha, token.is_stop)
|
|
|
|
|
|
for ent in doc.ents:
|
|
|
- print(ent.text, ent.start_char, ent.end_char, ent.label_)
|
|
|
+ print(ent.text, ent.start_char, ent.end_char, ent.label_)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+
|
|
|
+ submit(r"Copy from .\test\work\a.txt to .\test\work\b.txt")
|
|
|
+ submit(r"Delete .\test\work\a.txt")
|
|
|
+ # submit(r"Rename .\test\work\a.txt in .\test\work\b.txt")
|