From 2de403c6202893364d5b6458889b1bda7d06dd82 Mon Sep 17 00:00:00 2001
From: yangpengflag <38930516+yangpengflag@users.noreply.github.com>
Date: Fri, 11 Jan 2019 16:25:02 +0800
Subject: [PATCH] Initial commit

---
 __init__.py         |  0
 aiml_main.py        | 15 +++++++++++++++
 basic_chat.aiml     | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 inter_morse_code.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 std-startup.xml     | 12 ++++++++++++
 5 files changed, 140 insertions(+)
 create mode 100644 __init__.py
 create mode 100644 aiml_main.py
 create mode 100644 basic_chat.aiml
 create mode 100644 inter_morse_code.py
 create mode 100644 std-startup.xml

diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/__init__.py
diff --git a/aiml_main.py b/aiml_main.py
new file mode 100644
index 0000000..bf3d7c3
--- /dev/null
+++ b/aiml_main.py
@@ -0,0 +1,15 @@
+import aiml
+import re
+
+kernel = aiml.Kernel()
+kernel.learn("std-startup.xml")
+kernel.respond("load aiml b")
+
+while True:
+    a = kernel.respond(input("input>>"))
+    print(a)
+
+    reg2 = "13[0-9]\d{8}|14[5,7]\d{8}|15[0-3,5-9]\d{8}|17[0-3,5-8]\d{8}|18[0-9]\d{8}|166\d{8}|19[8-9]\d{8}"
+    numbers = re.findall(reg2,a)
+    #print(numbers)
+
diff --git a/basic_chat.aiml b/basic_chat.aiml
new file mode 100644
index 0000000..de9e0b4
--- /dev/null
+++ b/basic_chat.aiml
@@ -0,0 +1,48 @@
+<aiml version="1.0.1" encoding="utf-8">
+    <category>
+        <pattern>BYE</pattern>
+        <template>再见</template>
+    </category>
+    <category>
+        <pattern>拜拜</pattern>
+        <template><srai>BYE</srai></template>
+    </category>
+    <category>
+        <pattern>再见</pattern>
+        <template><srai>BYE</srai></template>
+    </category>
+    <category>
+        <pattern>* 强 *</pattern>
+        <template>贪心学院</template>
+    </category>
+    <category>
+        <pattern>* 手机号 *</pattern>
+        <template>numbers</template>
+    </category>
+    <category>
+        <pattern>* 优势 *</pattern>
+        <template>强大的服务体系,我们拥有每天跟学员沟通的良好服务机制。不放弃任何一个学员,只要来了,就一定要让你学会。</template>
+    </category>
+    <category>
+        <pattern>* 项目式 *</pattern>
+        <template>
+            贪心学院的项目式培训结合了西方项目式培训的优点和国内的现状,最终变化成以训练营的方式进行。
+            做项目为主,老师负责解决部分知识的问题,学生负责自学部分知识,和不停的做项目,把知识巩固。
+            在项目练习中,不仅仅学习到了知识,同时也培养起来良好的学习习惯和解决问题的能力。
+        </template>
+    </category>
+    <category>
+        <pattern>Python * 人群 * </pattern>
+        <template>
+            人群包含很广泛。
+            第一:非IT圈内人群,想通过学习转行到编程领域中
+            第二:已经是IT圈内的,其他语言的开发人员,想学习Python编程
+            第三:已经是IT圈内的,但是并不是开发人员,如产品、测试、运维、DBA等岗位
+            第四:学生,未来想从事编程的工作\r\n第五:未来想从事AI领域工作的,可先通过这门课程的学习,打下良好的基础
+        </template>
+    </category>
+
+
+
+
+</aiml>
\ No newline at end of file
diff --git a/inter_morse_code.py b/inter_morse_code.py
new file mode 100644
index 0000000..43bdbbb
--- /dev/null
+++ b/inter_morse_code.py
@@ -0,0 +1,65 @@
+def uniqueMorseRepresentations(self, words):
+    morsecode = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
+    charlist = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
+    morsemap = dict(zip(charlist,morsecode))
+    morselist=[]
+    for i in words:
+        s = ""
+        for j in i:
+            s += morsemap.get(j)
+            #print(s)
+
+        morselist.append(s)
+
+    print(morselist)
+    print(len(set(morselist)))
+
+uniqueMorseRepresentations(self=uniqueMorseRepresentations,words=["gin", "zen", "gig", "msg"])
+
+def uniqueMorseRepresentations1(self, words):
+    ref = {'a':".-",
+           "b":"-...",
+           "c":"-.-.",
+           "d":"-..",
+           "e":".",
+           "f":"..-.",
+           "g":"--.",
+           "h":"....",
+           "i":"..",
+           "j":".---",
+           "k":"-.-",
+           "l":".-..",
+           "m":"--",
+           "n":"-.",
+           "o":"---",
+           "p":".--.",
+           "q":"--.-",
+           "r":".-.",
+           "s":"...",
+           "t":"-",
+           "u":"..-",
+           "v":"...-",
+           "w":".--",
+           "x":"-..-",
+           "y":"-.--",
+           "z":"--.."}
+    res = []
+    for word in words:
+        s = ''
+        for i in word:
+            s += ref.get(i)
+        res.append(s)
+    #print(len(set(res)))
+
+uniqueMorseRepresentations(self=uniqueMorseRepresentations1,words=["gin", "zen", "gig", "msg"])
+
+
+# Approach #2   用ord()函数求出a的ASCII值, chr() 是将ASCII值变为字符.  ord('a') = 97 ,   ord("A") = 65
+def uniqueMorseRepresentations2(self, words):
+    morsecode = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.",
+                 "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."]
+    lenth = len(set("".join(morsecode[ord(s) - 97] for s in word) for word in words))
+   # print(lenth)
+
+
+uniqueMorseRepresentations2(self=uniqueMorseRepresentations2,words=["gin", "zen", "gig", "msg"])
\ No newline at end of file
diff --git a/std-startup.xml b/std-startup.xml
new file mode 100644
index 0000000..d3e4446
--- /dev/null
+++ b/std-startup.xml
@@ -0,0 +1,12 @@
+<aiml version="1.0.1" encoding = "utf-8">
+    <category>
+        <pattern>LOAD AIML B</pattern>
+        <template>
+            <learn>basic_chat.aiml</learn>
+        </template>
+    </category>
+
+
+
+
+</aiml>
\ No newline at end of file
--
libgit2 0.26.0