Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

Commit

Permalink
Updated coding standards after running pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
keiffster committed Dec 14, 2016
1 parent 374db4f commit 016869f
Show file tree
Hide file tree
Showing 46 changed files with 1,324 additions and 928 deletions.
13 changes: 3 additions & 10 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<h1 class="project-name">Program-y</h1>
<h2 class="project-tagline">AIML 2.0 Interpreter and related programs and knowledge files</h2>
<a href="https://github.com/keiffster/program-y" class="btn">View on GitHub</a>
<a href="/tutorial/main.html" class="btn">Tutorial</a>
<a href="/userguide/main.html" class="btn">User Guide</a>
<a href="https://github.com/keiffster/program-y/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/keiffster/program-y/tarball/master" class="btn">Download .tar.gz</a>
</section>
Expand All @@ -36,11 +38,7 @@ <h3>Background and History</h3>
Python interpreter, hence this project.
</p>
<p>
Right now it implements about 99% of the AIML spec, only leaving our learn, learnf and eval, but I decided to release this version so that people can
start using it, while I add the remaining grammars.
</p>
<p>
This version also supports one additional grammar &lt extension &gt, which allows you to call native Python classes, similar in a way that the sraix tag
Right now it implements about 100% of the AIML spec. This version also supports one additional grammar &lt extension &gt, which allows you to call native Python classes, similar in a way that the sraix tag
works.
</p>
<p>
Expand All @@ -49,11 +47,6 @@ <h3>Background and History</h3>
<p>
Enjoy and please leave any feedback for me and I'll get back to you. Keiff
</p>
<h3>
<a id="authors-and-contributors" class="anchor" href="#authors-and-contributors" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Authors and Contributors</h3>

<p>You can @mention a GitHub username to generate a link to their profile. The resulting <code>&lt;a&gt;</code> element will link to the contributor’s GitHub Profile. For example: In 2007, Chris Wanstrath (<a href="https://github.com/defunkt" class="user-mention">@defunkt</a>), PJ Hyett (<a href="https://github.com/pjhyett" class="user-mention">@pjhyett</a>), and Tom Preston-Werner (<a href="https://github.com/mojombo" class="user-mention">@mojombo</a>) founded GitHub.</p>

<h3>
<a id="support-or-contact" class="anchor" href="#support-or-contact" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Support or Contact</h3>

Expand Down
51 changes: 51 additions & 0 deletions docs/tutorial/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Program-y by keiffster</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/stylesheets/normalize.css" media="screen">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
</head>
<body>
<section class="page-header">
<h1 class="project-name">Program-y</h1>
<h2 class="project-tagline">AIML 2.0 Interpreter and related programs and knowledge files</h2>
<a href="https://github.com/keiffster/program-y" class="btn">View on GitHub</a>
<a href="https://keiffster.github.io/program-y/tutorial/main.html" class="btn">Tutorial</a>
<a href="https://keiffster.github.io/program-y/userguide/main.html" class="btn">User Guide</a>
<a href="https://github.com/keiffster/program-y/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/keiffster/program-y/tarball/master" class="btn">Download .tar.gz</a>
</section>

<section class="main-content">
<h3>Tutorial</h3>
<p>
<ol>
<li>Download</li>
<li>Installation</li>
<li>Running a console app</li>
<li>Basic Grammar</li>
<li>Extensing the Grammar</li>
<li>Testing the conversation</li>
<li>Core Grammar Features</li>
<li>Advanced Grammar Features</li>
<li>External Services</li>
<li>Building your own extensions</li>
</ol>
</p>


<footer class="site-footer">
<span class="site-footer-owner"><a href="https://github.com/keiffster/program-y">Program-y</a> is maintained by <a href="https://github.com/keiffster">keiffster</a>.</span>

<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span>
</footer>

</section>


</body>
</html>
59 changes: 59 additions & 0 deletions docs/userguide/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Program-y by keiffster</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
</head>
<body>
<section class="page-header">
<h1 class="project-name">Program-y</h1>
<h2 class="project-tagline">AIML 2.0 Interpreter and related programs and knowledge files</h2>
<a href="https://github.com/keiffster/program-y" class="btn">View on GitHub</a>
<a href="https://keiffster.github.io/program-y/tutorial/main.html" class="btn">Tutorial</a>
<a href="https://keiffster.github.io/program-y/userguide/main.html" class="btn">User Guide</a>
<a href="https://github.com/keiffster/program-y/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/keiffster/program-y/tarball/master" class="btn">Download .tar.gz</a>
</section>

<section class="main-content">
<h3>User Guide</h3>
<p>
User Guide goes here
<ul>
<li>Download</li>
<li>Installation</li>
<li>Running a bot
<ul>
<li>Console</li>
<li>Rest Client</li>
</ul>
</li>
<li>Configuration
<ul>
<li>Bot</li>
<li>Brain</li>
<li>Logging</li>
</ul>
</li>
<li>Creating your own Grammar</li>
<li>External Services</li>
<li>Extensions</li>
</ul>
</p>

<footer class="site-footer">
<span class="site-footer-owner"><a href="https://github.com/keiffster/program-y">Program-y</a> is maintained by <a href="https://github.com/keiffster">keiffster</a>.</span>

<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span>
</footer>

</section>


</body>
</html>
7 changes: 3 additions & 4 deletions pylint.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ comment=no
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=C0111

disable=C0111, broad-except, no-self-use, too-few-public-methods, unused-argument

[BASIC]

Expand Down Expand Up @@ -171,7 +170,7 @@ const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=120
max-line-length=140

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
Expand Down Expand Up @@ -302,7 +301,7 @@ max-statements=50
max-parents=7

# Maximum number of attributes for a class (see R0902).
max-attributes=7
max-attributes=20

# Minimum number of public methods for a class (see R0903).
min-public-methods=2
Expand Down
22 changes: 10 additions & 12 deletions src/programy/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def conversations(self):
return self._conversations

@property
def prompt (self):
def prompt(self):
if self._configuration is not None:
return self._configuration.prompt
else:
Expand Down Expand Up @@ -74,30 +74,27 @@ def get_version_string(self):
return ""

def has_conversation(self, clientid):
if clientid in self._conversations:
return True
else:
return False
return bool(clientid in self._conversations)

def conversation(self, clientid: str):
return self.get_conversation(clientid)

def get_conversation(self, clientid: str):
if clientid in self._conversations:
logging.info ("Retrieving conversation for client %s"%(clientid))
logging.info("Retrieving conversation for client %s", clientid)
return self._conversations[clientid]
else:
logging.info ("Creating new conversation for client %s"%(clientid))
logging.info("Creating new conversation for client %s", clientid)
conversation = Conversation(clientid, self)
self._conversations[clientid] = conversation
return conversation

def ask_question(self, clientid: str, text: str, srai=False):

logging.debug("Question (%s): %s"%(clientid, text))
logging.debug("Question (%s): %s", clientid, text)

pre_processed = self.brain.pre_process_question(self, clientid, text)
logging.debug("Pre Processed (%s): %s"%(clientid, pre_processed))
logging.debug("Pre Processed (%s): %s", clientid, pre_processed)

conversation = self.get_conversation(clientid)

Expand All @@ -109,17 +106,18 @@ def ask_question(self, clientid: str, text: str, srai=False):
parent_question = conversation.current_question()

answers = []
for each_sentence in question._sentences:
for each_sentence in question.sentences:

response = self.brain.ask_question(self, clientid, each_sentence, parent_question)

if response is not None:
logging.debug("Raw Response (%s): %s"%(clientid, response))
logging.debug("Raw Response (%s): %s", clientid, response)
each_sentence.response = response
answer = self.brain.post_process_response(self, clientid, response).strip()
answers.append(answer)
logging.debug("Processed Response (%s): %s"%(clientid, answer))
logging.debug("Processed Response (%s): %s", clientid, answer)
else:
each_sentence.response = self.default_response
answers.append(self.default_response)

return ". ".join([sentence for sentence in answers if sentence is not None])
Loading

0 comments on commit 016869f

Please sign in to comment.