Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVamsi Krishna Davuluri <iwikiwi@huecomundo.themachineninja.org>2009-10-21 08:33:26 (GMT)
committer Vamsi Krishna Davuluri <iwikiwi@huecomundo.themachineninja.org>2009-10-21 08:33:26 (GMT)
commite5cffed6dae67bcf6108ada72a72a5ea6d731cfc (patch)
tree82e7ca864c20ffecd40a531a96582616c4de192a
parent30f1255f8b90f40ce295453e91820d7a8f33faa2 (diff)
Rewrote doMath function.The new function has a success rate of 80%
-rw-r--r--.esperas.py.swpbin0 -> 20480 bytes
-rw-r--r--.libRLP.py.swpbin0 -> 12288 bytes
-rw-r--r--.test.py.swpbin0 -> 12288 bytes
-rw-r--r--FAQ/sugar.txt16
-rw-r--r--FAQ/sugar.txt~51
-rw-r--r--esperas.py51
-rw-r--r--libGA.py16
-rw-r--r--libRLP.py48
-rw-r--r--libRLP.pycbin3839 -> 3709 bytes
-rw-r--r--libRLP.py~496
-rw-r--r--test.py2
11 files changed, 626 insertions, 54 deletions
diff --git a/.esperas.py.swp b/.esperas.py.swp
new file mode 100644
index 0000000..d5a94a1
--- /dev/null
+++ b/.esperas.py.swp
Binary files differ
diff --git a/.libRLP.py.swp b/.libRLP.py.swp
new file mode 100644
index 0000000..18d7f85
--- /dev/null
+++ b/.libRLP.py.swp
Binary files differ
diff --git a/.test.py.swp b/.test.py.swp
new file mode 100644
index 0000000..b0ab684
--- /dev/null
+++ b/.test.py.swp
Binary files differ
diff --git a/FAQ/sugar.txt b/FAQ/sugar.txt
index ecc0916..7a6e233 100644
--- a/FAQ/sugar.txt
+++ b/FAQ/sugar.txt
@@ -2,7 +2,7 @@ Q. What is Sugar?
A. Sugar is an educational software platform built with the Python programming language and based on the principles of cognitive and social constructivism.
-Q. Who is doing Sugar development?
+Q. Who is (doing, behind) Sugar development?
A. Sugar is a community project where all work is done by volunteers. You can get an idea of the people involved from the Development Team/Release/Modules page.
@@ -12,4 +12,16 @@ A. The Sugar interface, in its departure from the desktop metaphor for computing
Sugar also considers two aphorisms: (1) you learn through doing, so if you want more learning, you want more doing; and (2) love is a better master than duty—you want people to engage in things that are authentic to them, things that they love.
The presence of other people is inherent to the Sugar interface: collaboration is a first-order experience. Students and teachers engage in a dialog with each other, support each other, critique each other, and share ideas.
Sugar is also discoverable: it can accommodate a wide variety of users, with different levels of skill in terms of reading, language, and different levels of experience with computing. It is easy to approach, and yet it doesn't put an upper bound on personal expression; one can peel away layers and go deeper and deeper, with few restrictions.
- Sugar is based on Python, an interpreted language, allowing the direct appropriation of ideas: in whatever realm the learner is exploring—music, browsing, reading, writing, programming, graphics, etc.—they are able to drill deeper; they are not going to hit a wall, since they can, at every level, engage in debugging both their personal expression and the very tools that they use for that expression. \ No newline at end of file
+ Sugar is based on Python, an interpreted language, allowing the direct appropriation of ideas: in whatever realm the learner is exploring—music, browsing, reading, writing, programming, graphics, etc.—they are able to drill deeper; they are not going to hit a wall, since they can, at every level, engage in debugging both their personal expression and the very tools that they use for that expression.
+
+Q. Who (built, made, constructed) you?
+
+A. iwikiwi!
+
+Q. How do I (learn, know) more about Sugar Labs?
+
+A. Please add new questions to the discussion page or send email to press@sugarlabs.org.
+
+Q. How do I (get, join) involved with Sugar
+
+A. Please see the Getting Involved page in this wiki. \ No newline at end of file
diff --git a/FAQ/sugar.txt~ b/FAQ/sugar.txt~
index ecc0916..47997d2 100644
--- a/FAQ/sugar.txt~
+++ b/FAQ/sugar.txt~
@@ -1,15 +1,50 @@
Q. What is Sugar?
-A. Sugar is an educational software platform built with the Python programming language and based on the principles of cognitive and social constructivism.
+A. Sugar is an educational software platform built with the Python programming
+language and based on the principles of cognitive and social constructivism.
-Q. Who is doing Sugar development?
+Q. Who is (doing, behind) Sugar development?
-A. Sugar is a community project where all work is done by volunteers. You can get an idea of the people involved from the Development Team/Release/Modules page.
+A. Sugar is a community project where all work is done by volunteers. You can
+get an idea of the people involved from the Development Team/Release/Modules
+page.
Q. What makes Sugar different from other educational software platforms?
-A. The Sugar interface, in its departure from the desktop metaphor for computing, is the first serious attempt to create a user interface that is based on both cognitive and social constructivism: learners should engage in authentic exploration and collaboration. It is based on three very simple principles about what makes us human: (1) everyone is a teacher and a learner; (2) humans by their nature are social beings; and (3) humans by their nature are expressive. These are the pillars of a user experience for learning.
- Sugar also considers two aphorisms: (1) you learn through doing, so if you want more learning, you want more doing; and (2) love is a better master than duty—you want people to engage in things that are authentic to them, things that they love.
- The presence of other people is inherent to the Sugar interface: collaboration is a first-order experience. Students and teachers engage in a dialog with each other, support each other, critique each other, and share ideas.
- Sugar is also discoverable: it can accommodate a wide variety of users, with different levels of skill in terms of reading, language, and different levels of experience with computing. It is easy to approach, and yet it doesn't put an upper bound on personal expression; one can peel away layers and go deeper and deeper, with few restrictions.
- Sugar is based on Python, an interpreted language, allowing the direct appropriation of ideas: in whatever realm the learner is exploring—music, browsing, reading, writing, programming, graphics, etc.—they are able to drill deeper; they are not going to hit a wall, since they can, at every level, engage in debugging both their personal expression and the very tools that they use for that expression. \ No newline at end of file
+A. The Sugar interface, in its departure from the desktop metaphor for
+computing, is the first serious attempt to create a user interface that is based
+on both cognitive and social constructivism: learners should engage in authentic
+exploration and collaboration. It is based on three very simple principles about
+what makes us human: (1) everyone is a teacher and a learner; (2) humans by
+their nature are social beings; and (3) humans by their nature are expressive.
+These are the pillars of a user experience for learning.
+Sugar also considers two aphorisms: (1) you learn through doing, so if you
+want more learning, you want more doing; and (2) love is a better master than
+duty—you want people to engage in things that are authentic to them, things that
+they love. The presence of other people is inherent to the Sugar interface:
+collaboration is a first-order experience. Students and teachers engage in a
+dialog with each other, support each other, critique each other, and share
+ideas.
+Sugar is also discoverable: it can accommodate a wide variety of users, with
+different levels of skill in terms of reading, language, and different levels of
+experience with computing. It is easy to approach, and yet it doesn't put an
+upper bound on personal expression; one can peel away layers and go deeper and
+deeper, with few restrictions. Sugar is based on Python, an interpreted
+language, allowing the direct appropriation of ideas: in whatever realm the
+learner is exploring—music, browsing, reading, writing, programming, graphics,
+etc.—they are able to drill deeper; they are not going to hit a wall, since they
+can, at every level, engage in debugging both their personal expression and the
+very tools that they use for that expression.
+
+Q. Who (built, made, constructed) you?
+
+A. iwikiwi!
+
+Q. How do I (learn, know) more about Sugar Labs?
+
+A. Please add new questions to the discussion page or send email to
+press@sugarlabs.org.
+
+Q. How do I (get, join) involved with Sugar
+
+A. Please see the Getting Involved page in this wiki. \ No newline at end of file
diff --git a/esperas.py b/esperas.py
index 9e290e2..d8e69f1 100644
--- a/esperas.py
+++ b/esperas.py
@@ -14,19 +14,19 @@ from libRLP import *
HOST="irc.freenode.net"
PORT=6667
-NICK="nekomimi"
-IDENT="iloveiwikiwi:)"
+NICK="GeneralFAQ"
+IDENT="esperas"
REALNAME="esperas"
OWNER="iwikiwi"
-CHANNEL = "#testesperas"
+CHANNEL = "#sugar-autohelp"
buffer = ""
clientsock=socket.socket()
clientsock.connect((HOST, PORT))
clientsock.send("NICK %s\r\n" % NICK)
clientsock.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
clientsock.send("JOIN %s\r\n" % (CHANNEL))
-clientsock.send("PRIVMSG "+CHANNEL+" : *blush*.\r\n")
-kitallis='kitallis'
+#clientsock.send("PRIVMSG "+CHANNEL+" : *blush*.\r\n")
+kitallis='111111111111111111111111111'
kitallis1=''
counter = 0
kitallisconf=''
@@ -45,7 +45,7 @@ def parsemsg(msg):
global storage
global faqmode
storage = anydbm.open('ircuserinfo','c')
- kitallis='kitallis'
+ kitallis='111111111111111111111111111113333333333333'
complete=msg[1:].split(':',1) #Parse the message into useful data
print complete
info=complete[0].split(' ')
@@ -78,26 +78,37 @@ def parsemsg(msg):
- print sender
- if faqmode == 1:
- process = InputBreaker(cmd[1])
- matchobj = Match(process.qEntitySentences)
- answer = matchobj.reportAnswer()
- clientsock.send("PRIVMSG "+CHANNEL+' :' + answer)
-
- else:
- if cmd[1].find(' is') < 15 and cmd[1].find(' is') > 1 :
- clientsock.send("PRIVMSG "+CHANNEL+' :'+ random.choice(['understood :)','okie!','right'])+ '\r\n')
- lol=cmd[1]
- key = lol.split(' is')
- storage[key[0]]=cmd[1]
-
+ if cmd[0] == NICK+":":
+ if faqmode == 1:
+ process = InputBreaker(cmd[1])
+ matchobj = Match(process.qEntitySentences)
+ answer = matchobj.reportAnswer().split('A. ')[1]
+ answer = answer.replace("\n", "")
+ print answer
+ if len(answer) > 500:
+ answers = [answer[i:i+400] for i in range(0, len(answer), 400)]
+
+ clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0]+', '+ answer[0:400]+ '\r\n')
+ del answers[0]
+ for answer in answers:
+ clientsock.send("PRIVMSG "+CHANNEL+' :'+ answer+ '\r\n')
+ time.sleep(1)
+ else:
+ clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0]+', '+answer+ '\r\n')
+
+
elif cmd[1] == 'mode faq\r\n':
print 'lol'
faqmode = 1
+ elif cmd[1].find(' is') < 15 and cmd[1].find(' is') > 1 :
+ clientsock.send("PRIVMSG "+CHANNEL+' :'+ random.choice(['understood :)','okie!','right'])+ '\r\n')
+ lol=cmd[1]
+ key = lol.split(' is')
+ storage[key[0]]=cmd[1]
elif cmd[1] == 'say hello to all\r\n':
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice([' hello everyone!!! '])+ '\r\n')
+
elif cmd[1].find('say hello to')!=-1:
name=cmd[1].split(' to',1)
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice(['hello, '])+ name[1].rstrip()+'!!'+ '\r\n')
diff --git a/libGA.py b/libGA.py
new file mode 100644
index 0000000..61c154f
--- /dev/null
+++ b/libGA.py
@@ -0,0 +1,16 @@
+'''
+The GA library for Q-A system
+'''
+
+import math
+
+CHROMOSOMES = ['*','-','+','/','log','sin','cos','e']
+
+class OperatorTree:
+ __init__(self, datas):
+ for data in datas:
+ success = data[0]
+ noofqtags = data[1]
+ difference = data[2]
+
+ ConstrucTree(self,
diff --git a/libRLP.py b/libRLP.py
index 4d66954..9f238b1 100644
--- a/libRLP.py
+++ b/libRLP.py
@@ -13,9 +13,10 @@ class InputBreaker:
self.fSentences = []
self.qEntitySentences = []
self.analyzeText(text)
- #print self.qEntitySentences
+ print self.qEntitySentences
def analyzeText(self, text):
+ text = text.lower()
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
sents = tokenizer.tokenize(text)
for sentence in sents:
@@ -24,15 +25,18 @@ class InputBreaker:
def determineSentenceType(self, sentence):
words = nltk.word_tokenize(sentence)
tagit = nltk.pos_tag(words)
- #print tagit
- if (tagit[0][1] == 'NNP' and tagit[-1][1] == 'PRP') or (tagit[0][1] == 'WP' and tagit[-1][1] == 'NN'):
- self.qEntitySentences.append(tagit)
+ print tagit
+ #if (tagit[0][1] == 'NN*' and (tagit[-1][1] == 'PRP'or \
+ #tagit[-2][1] == 'PRP')) or ((tagit[0][1] == 'NN' or\
+ #tagit[0][1] == 'WP') and (tagit[-1][1] == 'NN' or \
+ #tagit[-2][1] == 'NN')):
+ self.qEntitySentences.append(tagit)
class Match:
def __init__(self, questions):
- #print questions
- self.file = open("./FAQ/sugar.txt","rb")
+ print questions
+ self.file = open("FAQ/sugar.txt","rb")
self.mostprobableQ = ""
self.tomatchwords = []
for question in questions:
@@ -64,22 +68,21 @@ class Match:
def doMath(self,metrics):
greatestmetric = []
- metricno = 10
+ metricno = -10
+ print 'lolcat'
for metric in metrics:
userqtags = metric[0]
+ print 'len of userqtags' + str(len(userqtags))
success = metric[1]
words = nltk.word_tokenize(metric[2].split('Q.')[1])
+ print 'success is' + str(success)
tagit = nltk.pos_tag(words)
databaseqtags = self.extractKeywords(tagit)
- diff = math.sqrt((len(databaseqtags) - len(userqtags))*(len(databaseqtags) - len(userqtags)))
- if diff > success:
- tocheck = diff - success
- else:
- tocheck = success - diff
- if tocheck < metricno or (success < diff and metricno != 0 and success > 0):
- metricno = tocheck
- greatestmetric = metric
- print metricno
+ tocheck = success - len(userqtags)
+ if tocheck > metricno:
+ metricno = tocheck
+ greatestmetric = metric
+ print metricno
print greatestmetric
return greatestmetric
@@ -87,16 +90,15 @@ class Match:
self.tomatchwords = []
print question
for tag in question:
- if tag[1] == "NN" or tag[1] == "JJ" or tag[1] == "NNP":
+ if tag[1] == "NN" or tag[1] == "JJ" \
+ or tag[1] == "NNP" :
self.tomatchwords.append(tag[0])
print self.tomatchwords
return self.tomatchwords
def reportAnswer(self,):
- self.file = open("./FAQ/sugar.txt","rb")
- content = self.file.read()
+ file = open("FAQ/sugar.txt","rb")
+ content = file.read()
tuple = content.split(self.mostprobableQ)
- self.file.close()
- return tuple[1].split('\n')[1]
-
-
+ file.close()
+ return tuple[1].split('Q.')[0]
diff --git a/libRLP.pyc b/libRLP.pyc
index ac465cd..675c991 100644
--- a/libRLP.pyc
+++ b/libRLP.pyc
Binary files differ
diff --git a/libRLP.py~ b/libRLP.py~
new file mode 100644
index 0000000..0dd8ca3
--- /dev/null
+++ b/libRLP.py~
@@ -0,0 +1,496 @@
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>libRLP.py - mainline in Interactive FAQ - Gitorious</title>
+ <meta name="author" content="Johan Sørensen">
+ <link href="/stylesheets/base.css?1237206699" media="screen" rel="stylesheet" type="text/css" /> <link href="/stylesheets/syntax_themes/idle.css?1228282440" media="screen" rel="stylesheet" type="text/css" /> <script src="/javascripts/all.js?1228342900" type="text/javascript"></script> </head>
+
+<body id="blobs">
+ <div id="header">
+ <h1 id="logo">
+ <a href="/"><img alt="Sugarlabs-logo" src="/images/sugarlabs-logo.png?1237206804" /></a> </h1>
+ <!-- BEGIN bernie -->
+ <div id="menu">
+ <ul id="linkbar">
+ <li><a href="http://wiki.sugarlabs.org/"> wiki </a></li>
+ <li><a href="http://dev.sugarlabs.org/"> bugs </a></li>
+ <li><a href="http://git.sugarlabs.org/"><strong>git</strong> </a></li>
+ <li><a href="http://planet.sugarlabs.org/"> blog </a></li>
+ <li><a href="http://lists.sugarlabs.org/"> lists </a></li>
+ <li><a href="http://schools.sugarlabs.org/"> schools </a></li>
+ <li><a href="http://activities.sugarlabs.org/">activities</a></li>
+ <li><a href="http://download.sugarlabs.org/"> download</a></li>
+ <li><a href="http://api.sugarlabs.org/"> api </a></li>
+ <li><a href="http://buildbot.sugarlabs.org/"> buildbot</a></li>
+ <li><a href="http://people.sugarlabs.org/"> people </a></li>
+ </ul>
+ <!-- END bernie -->
+ <ul id="menubar">
+ <li><a href="/dashboard">Dashboard</a></li>
+ <li><a href="/projects">Projects</a></li>
+ <li><a href="/search">Search</a></li>
+ <li><a href="/about/faq">FAQ</a></li>
+ <li class="secondary">( <a href="/account">My account</a></li>
+ <li class="secondary"><a href="/logout">Logout</a> )</li>
+ </ul>
+ <!-- BEGIN bernie -->
+ </div>
+ <!-- END bernie -->
+ <h2 id="project_title"><a href="/projects/interactive-faq">Interactive FAQ</a></h2>
+ <ul id="submenu" class="">
+ <li class="">
+ <a href="/projects/interactive-faq" class="round-top-5">Project Overview</a> </li>
+ <li class="selected">
+ <a href="/projects/interactive-faq/repos" class="round-top-5">Repositories</a> </li>
+ </ul>
+ </div>
+ <ul id="contextmenu">
+
+
+<li><a href="/projects/interactive-faq/repos/mainline">Overview</a></li>
+<li><a href="/projects/interactive-faq/repos/mainline/logs">Commits</a></li>
+<li><a href="/projects/interactive-faq/repos/mainline/trees">Source Tree</a></li>
+<li><a href="/projects/interactive-faq/repos/mainline/comments">Comments (0)</a></li>
+<li><a href="/projects/interactive-faq/repos/mainline/merge_requests">Merge requests(0)</a></li> </ul>
+ <div id="container" class="in-context-mode">
+ <div id="content" class="">
+
+
+
+
+
+<ul class="mode_selector">
+ <li class="list_header">
+ Softwrap mode:
+ </li>
+ <li>
+ <a href="#" onclick="Gitorious.Wordwrapper.toggle($$('table#codeblob td.code')); return false;">Toggle</a> </li>
+</ul>
+
+<h1>
+ Blob of <code>libRLP.py</code>
+ <small>(<a href="/projects/interactive-faq/repos/mainline/blobs/raw/30f1255f8b90f40ce295453e91820d7a8f33faa2/libRLP.py">raw blob data</a>)</small>
+</h1>
+<!-- text/plain -->
+
+<ul class="path_breadcrumbs">
+ <li>/ <a href="/projects/interactive-faq/repos/mainline/trees/30f1255f8b90f40ce295453e91820d7a8f33faa2">mainline</a></li>
+ <li>/ libRLP.py</li>
+</ul>
+ <table id="codeblob" class="highlighted">
+<tr id="line1">
+<td class="line-numbers"><a href="#line1" name="line1">1</a></td>
+<td class="code idle"><span class="String"><span class="String">'''</span> </span></td>
+</tr>
+<tr id="line2">
+<td class="line-numbers"><a href="#line2" name="line2">2</a></td>
+<td class="code idle"><span class="String">The library for natural language processing, and categorizing</span></td>
+</tr>
+<tr id="line3">
+<td class="line-numbers"><a href="#line3" name="line3">3</a></td>
+<td class="code idle"><span class="String">information using NLTK</span></td>
+</tr>
+<tr id="line4">
+<td class="line-numbers"><a href="#line4" name="line4">4</a></td>
+<td class="code idle"><span class="String"><span class="String">'''</span></span></td>
+</tr>
+<tr id="line5">
+<td class="line-numbers"><a href="#line5" name="line5">5</a></td>
+<td class="code idle"><span class="Keyword">import</span> nltk</td>
+</tr>
+<tr id="line6">
+<td class="line-numbers"><a href="#line6" name="line6">6</a></td>
+<td class="code idle"><span class="Keyword">from</span> nltk <span class="Keyword">import</span> tokenize</td>
+</tr>
+<tr id="line7">
+<td class="line-numbers"><a href="#line7" name="line7">7</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line8">
+<td class="line-numbers"><a href="#line8" name="line8">8</a></td>
+<td class="code idle"><span class="Keyword">import</span> math</td>
+</tr>
+<tr id="line9">
+<td class="line-numbers"><a href="#line9" name="line9">9</a></td>
+<td class="code idle"><span class="Keyword">import</span> os</td>
+</tr>
+<tr id="line10">
+<td class="line-numbers"><a href="#line10" name="line10">10</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line11">
+<td class="line-numbers"><a href="#line11" name="line11">11</a></td>
+<td class="code idle"><span class="Storage">class</span> <span class="TypeName">InputBreaker</span>:</td>
+</tr>
+<tr id="line12">
+<td class="line-numbers"><a href="#line12" name="line12">12</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName"><span class="LibraryFunction">__init__</span></span>(<span class="FunctionArgument">self</span>, <span class="FunctionArgument">text</span>):</td>
+</tr>
+<tr id="line13">
+<td class="line-numbers"><a href="#line13" name="line13">13</a></td>
+<td class="code idle"> <span class="Variable">self</span>.fSentences <span class="Keyword">=</span> []</td>
+</tr>
+<tr id="line14">
+<td class="line-numbers"><a href="#line14" name="line14">14</a></td>
+<td class="code idle"> <span class="Variable">self</span>.qEntitySentences <span class="Keyword">=</span> []</td>
+</tr>
+<tr id="line15">
+<td class="line-numbers"><a href="#line15" name="line15">15</a></td>
+<td class="code idle"> <span class="Variable">self</span>.analyzeText(text)</td>
+</tr>
+<tr id="line16">
+<td class="line-numbers"><a href="#line16" name="line16">16</a></td>
+<td class="code idle"> <span class="Comment"><span class="Comment">#</span>print self.qEntitySentences</span></td>
+</tr>
+<tr id="line17">
+<td class="line-numbers"><a href="#line17" name="line17">17</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line18">
+<td class="line-numbers"><a href="#line18" name="line18">18</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName">analyzeText</span>(<span class="FunctionArgument">self</span>, <span class="FunctionArgument">text</span>):</td>
+</tr>
+<tr id="line19">
+<td class="line-numbers"><a href="#line19" name="line19">19</a></td>
+<td class="code idle"> tokenizer <span class="Keyword">=</span> nltk.data.load(<span class="String"><span class="String">'</span>tokenizers/punkt/english.pickle<span class="String">'</span></span>)</td>
+</tr>
+<tr id="line20">
+<td class="line-numbers"><a href="#line20" name="line20">20</a></td>
+<td class="code idle"> sents <span class="Keyword">=</span> tokenizer.tokenize(text)</td>
+</tr>
+<tr id="line21">
+<td class="line-numbers"><a href="#line21" name="line21">21</a></td>
+<td class="code idle"> <span class="Keyword">for</span> sentence <span class="Keyword">in</span> sents:</td>
+</tr>
+<tr id="line22">
+<td class="line-numbers"><a href="#line22" name="line22">22</a></td>
+<td class="code idle"> <span class="Variable">self</span>.determineSentenceType(sentence)</td>
+</tr>
+<tr id="line23">
+<td class="line-numbers"><a href="#line23" name="line23">23</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line24">
+<td class="line-numbers"><a href="#line24" name="line24">24</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName">determineSentenceType</span>(<span class="FunctionArgument">self</span>, <span class="FunctionArgument">sentence</span>):</td>
+</tr>
+<tr id="line25">
+<td class="line-numbers"><a href="#line25" name="line25">25</a></td>
+<td class="code idle"> words <span class="Keyword">=</span> nltk.word_tokenize(sentence)</td>
+</tr>
+<tr id="line26">
+<td class="line-numbers"><a href="#line26" name="line26">26</a></td>
+<td class="code idle"> tagit <span class="Keyword">=</span> nltk.pos_tag(words)</td>
+</tr>
+<tr id="line27">
+<td class="line-numbers"><a href="#line27" name="line27">27</a></td>
+<td class="code idle"> <span class="Comment"><span class="Comment">#</span>print tagit</span></td>
+</tr>
+<tr id="line28">
+<td class="line-numbers"><a href="#line28" name="line28">28</a></td>
+<td class="code idle"> <span class="Keyword">if</span> (tagit[<span class="Number">0</span>][<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">'</span>NNP<span class="String">'</span></span> <span class="Keyword">and</span> tagit[<span class="Keyword">-</span><span class="Number">1</span>][<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">'</span>PRP<span class="String">'</span></span>) <span class="Keyword">or</span> (tagit[<span class="Number">0</span>][<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">'</span>WP<span class="String">'</span></span> <span class="Keyword">and</span> tagit[<span class="Keyword">-</span><span class="Number">1</span>][<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">'</span>NN<span class="String">'</span></span>):</td>
+</tr>
+<tr id="line29">
+<td class="line-numbers"><a href="#line29" name="line29">29</a></td>
+<td class="code idle"> <span class="Variable">self</span>.qEntitySentences.append(tagit)</td>
+</tr>
+<tr id="line30">
+<td class="line-numbers"><a href="#line30" name="line30">30</a></td>
+<td class="code idle"> </td>
+</tr>
+<tr id="line31">
+<td class="line-numbers"><a href="#line31" name="line31">31</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line32">
+<td class="line-numbers"><a href="#line32" name="line32">32</a></td>
+<td class="code idle"><span class="Storage">class</span> <span class="TypeName">Match</span>:</td>
+</tr>
+<tr id="line33">
+<td class="line-numbers"><a href="#line33" name="line33">33</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName"><span class="LibraryFunction">__init__</span></span>(<span class="FunctionArgument">self</span>, <span class="FunctionArgument">questions</span>):</td>
+</tr>
+<tr id="line34">
+<td class="line-numbers"><a href="#line34" name="line34">34</a></td>
+<td class="code idle"> <span class="Comment"><span class="Comment">#</span>print questions</span></td>
+</tr>
+<tr id="line35">
+<td class="line-numbers"><a href="#line35" name="line35">35</a></td>
+<td class="code idle"> <span class="Variable">self</span>.file <span class="Keyword">=</span> <span class="LibraryClassType">open</span>(<span class="String"><span class="String">&quot;</span>./FAQ/sugar.txt<span class="String">&quot;</span></span>,<span class="String"><span class="String">&quot;</span>rb<span class="String">&quot;</span></span>)</td>
+</tr>
+<tr id="line36">
+<td class="line-numbers"><a href="#line36" name="line36">36</a></td>
+<td class="code idle"> <span class="Variable">self</span>.mostprobableQ <span class="Keyword">=</span> <span class="String"><span class="String">&quot;</span><span class="String"><span class="String">&quot;</span></span></span></td>
+</tr>
+<tr id="line37">
+<td class="line-numbers"><a href="#line37" name="line37">37</a></td>
+<td class="code idle"> <span class="Variable">self</span>.tomatchwords <span class="Keyword">=</span> []</td>
+</tr>
+<tr id="line38">
+<td class="line-numbers"><a href="#line38" name="line38">38</a></td>
+<td class="code idle"> <span class="Keyword">for</span> question <span class="Keyword">in</span> questions:</td>
+</tr>
+<tr id="line39">
+<td class="line-numbers"><a href="#line39" name="line39">39</a></td>
+<td class="code idle"> <span class="Variable">self</span>.findOptimalQuestion(question)</td>
+</tr>
+<tr id="line40">
+<td class="line-numbers"><a href="#line40" name="line40">40</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName">findOptimalQuestion</span>(<span class="FunctionArgument">self</span>, <span class="FunctionArgument">question</span>):</td>
+</tr>
+<tr id="line41">
+<td class="line-numbers"><a href="#line41" name="line41">41</a></td>
+<td class="code idle"> i <span class="Keyword">=</span> <span class="Number">0</span></td>
+</tr>
+<tr id="line42">
+<td class="line-numbers"><a href="#line42" name="line42">42</a></td>
+<td class="code idle"> </td>
+</tr>
+<tr id="line43">
+<td class="line-numbers"><a href="#line43" name="line43">43</a></td>
+<td class="code idle"> listofmetricsforsentence <span class="Keyword">=</span> []</td>
+</tr>
+<tr id="line44">
+<td class="line-numbers"><a href="#line44" name="line44">44</a></td>
+<td class="code idle"> <span class="Variable">self</span>.tomatchwords <span class="Keyword">=</span> <span class="Variable">self</span>.extractKeywords(question)</td>
+</tr>
+<tr id="line45">
+<td class="line-numbers"><a href="#line45" name="line45">45</a></td>
+<td class="code idle"> <span class="Comment"><span class="Comment">#</span>print self.tomatchwords</span></td>
+</tr>
+<tr id="line46">
+<td class="line-numbers"><a href="#line46" name="line46">46</a></td>
+<td class="code idle"> <span class="Keyword">for</span> line <span class="Keyword">in</span> <span class="Variable">self</span>.file.readlines():</td>
+</tr>
+<tr id="line47">
+<td class="line-numbers"><a href="#line47" name="line47">47</a></td>
+<td class="code idle"> linetosave <span class="Keyword">=</span> line</td>
+</tr>
+<tr id="line48">
+<td class="line-numbers"><a href="#line48" name="line48">48</a></td>
+<td class="code idle"> line <span class="Keyword">=</span> line.lower()</td>
+</tr>
+<tr id="line49">
+<td class="line-numbers"><a href="#line49" name="line49">49</a></td>
+<td class="code idle"> </td>
+</tr>
+<tr id="line50">
+<td class="line-numbers"><a href="#line50" name="line50">50</a></td>
+<td class="code idle"> <span class="Keyword">if</span> line[<span class="Number">0</span>:<span class="Number">2</span>] <span class="Keyword">==</span> <span class="String"><span class="String">'</span>q.<span class="String">'</span></span>:</td>
+</tr>
+<tr id="line51">
+<td class="line-numbers"><a href="#line51" name="line51">51</a></td>
+<td class="code idle"> successmeter <span class="Keyword">=</span> <span class="Number">0</span></td>
+</tr>
+<tr id="line52">
+<td class="line-numbers"><a href="#line52" name="line52">52</a></td>
+<td class="code idle"> <span class="Keyword">for</span> word <span class="Keyword">in</span> <span class="Variable">self</span>.tomatchwords:</td>
+</tr>
+<tr id="line53">
+<td class="line-numbers"><a href="#line53" name="line53">53</a></td>
+<td class="code idle"> <span class="Keyword">if</span> line.find(word) <span class="Keyword">!=</span> <span class="Keyword">-</span><span class="Number">1</span>:</td>
+</tr>
+<tr id="line54">
+<td class="line-numbers"><a href="#line54" name="line54">54</a></td>
+<td class="code idle"> successmeter<span class="Keyword">+=</span><span class="Number">1</span></td>
+</tr>
+<tr id="line55">
+<td class="line-numbers"><a href="#line55" name="line55">55</a></td>
+<td class="code idle"> <span class="Keyword">else</span>:</td>
+</tr>
+<tr id="line56">
+<td class="line-numbers"><a href="#line56" name="line56">56</a></td>
+<td class="code idle"> <span class="Keyword">pass</span></td>
+</tr>
+<tr id="line57">
+<td class="line-numbers"><a href="#line57" name="line57">57</a></td>
+<td class="code idle"> <span class="Keyword">if</span> successmeter <span class="Keyword">&gt;</span> <span class="Number">0</span>: </td>
+</tr>
+<tr id="line58">
+<td class="line-numbers"><a href="#line58" name="line58">58</a></td>
+<td class="code idle"> listofmetricsforsentence.append([<span class="Variable">self</span>.tomatchwords, successmeter, linetosave, ])</td>
+</tr>
+<tr id="line59">
+<td class="line-numbers"><a href="#line59" name="line59">59</a></td>
+<td class="code idle"> </td>
+</tr>
+<tr id="line60">
+<td class="line-numbers"><a href="#line60" name="line60">60</a></td>
+<td class="code idle"> <span class="Comment"><span class="Comment">#</span>print listofmetricsforsentence</span></td>
+</tr>
+<tr id="line61">
+<td class="line-numbers"><a href="#line61" name="line61">61</a></td>
+<td class="code idle"> <span class="Variable">self</span>.mostprobableQ <span class="Keyword">=</span> <span class="Variable">self</span>.doMath(listofmetricsforsentence)[<span class="Number">2</span>]</td>
+</tr>
+<tr id="line62">
+<td class="line-numbers"><a href="#line62" name="line62">62</a></td>
+<td class="code idle"> <span class="Keyword">print</span> <span class="Variable">self</span>.mostprobableQ</td>
+</tr>
+<tr id="line63">
+<td class="line-numbers"><a href="#line63" name="line63">63</a></td>
+<td class="code idle"> <span class="Variable">self</span>.file.close()</td>
+</tr>
+<tr id="line64">
+<td class="line-numbers"><a href="#line64" name="line64">64</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line65">
+<td class="line-numbers"><a href="#line65" name="line65">65</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName">doMath</span>(<span class="FunctionArgument">self</span>,<span class="FunctionArgument">metrics</span>):</td>
+</tr>
+<tr id="line66">
+<td class="line-numbers"><a href="#line66" name="line66">66</a></td>
+<td class="code idle"> greatestmetric <span class="Keyword">=</span> []</td>
+</tr>
+<tr id="line67">
+<td class="line-numbers"><a href="#line67" name="line67">67</a></td>
+<td class="code idle"> metricno <span class="Keyword">=</span> <span class="Number">10</span></td>
+</tr>
+<tr id="line68">
+<td class="line-numbers"><a href="#line68" name="line68">68</a></td>
+<td class="code idle"> <span class="Keyword">for</span> metric <span class="Keyword">in</span> metrics:</td>
+</tr>
+<tr id="line69">
+<td class="line-numbers"><a href="#line69" name="line69">69</a></td>
+<td class="code idle"> userqtags <span class="Keyword">=</span> metric[<span class="Number">0</span>]</td>
+</tr>
+<tr id="line70">
+<td class="line-numbers"><a href="#line70" name="line70">70</a></td>
+<td class="code idle"> success <span class="Keyword">=</span> metric[<span class="Number">1</span>]</td>
+</tr>
+<tr id="line71">
+<td class="line-numbers"><a href="#line71" name="line71">71</a></td>
+<td class="code idle"> words <span class="Keyword">=</span> nltk.word_tokenize(metric[<span class="Number">2</span>].split(<span class="String"><span class="String">'</span>Q.<span class="String">'</span></span>)[<span class="Number">1</span>])</td>
+</tr>
+<tr id="line72">
+<td class="line-numbers"><a href="#line72" name="line72">72</a></td>
+<td class="code idle"> tagit <span class="Keyword">=</span> nltk.pos_tag(words)</td>
+</tr>
+<tr id="line73">
+<td class="line-numbers"><a href="#line73" name="line73">73</a></td>
+<td class="code idle"> databaseqtags <span class="Keyword">=</span> <span class="Variable">self</span>.extractKeywords(tagit)</td>
+</tr>
+<tr id="line74">
+<td class="line-numbers"><a href="#line74" name="line74">74</a></td>
+<td class="code idle"> diff <span class="Keyword">=</span> math.sqrt((<span class="LibraryFunction">len</span>(databaseqtags) <span class="Keyword">-</span> <span class="LibraryFunction">len</span>(userqtags))<span class="Keyword">*</span>(<span class="LibraryFunction">len</span>(databaseqtags) <span class="Keyword">-</span> <span class="LibraryFunction">len</span>(userqtags)))</td>
+</tr>
+<tr id="line75">
+<td class="line-numbers"><a href="#line75" name="line75">75</a></td>
+<td class="code idle"> <span class="Keyword">if</span> diff <span class="Keyword">&gt;</span> success:</td>
+</tr>
+<tr id="line76">
+<td class="line-numbers"><a href="#line76" name="line76">76</a></td>
+<td class="code idle"> tocheck <span class="Keyword">=</span> diff <span class="Keyword">-</span> success</td>
+</tr>
+<tr id="line77">
+<td class="line-numbers"><a href="#line77" name="line77">77</a></td>
+<td class="code idle"> <span class="Keyword">else</span>:</td>
+</tr>
+<tr id="line78">
+<td class="line-numbers"><a href="#line78" name="line78">78</a></td>
+<td class="code idle"> tocheck <span class="Keyword">=</span> success <span class="Keyword">-</span> diff</td>
+</tr>
+<tr id="line79">
+<td class="line-numbers"><a href="#line79" name="line79">79</a></td>
+<td class="code idle"> <span class="Keyword">if</span> tocheck <span class="Keyword">&lt;</span> metricno <span class="Keyword">or</span> (success <span class="Keyword">&lt;</span> diff <span class="Keyword">and</span> metricno <span class="Keyword">!=</span> <span class="Number">0</span> <span class="Keyword">and</span> success <span class="Keyword">&gt;</span> <span class="Number">0</span>):</td>
+</tr>
+<tr id="line80">
+<td class="line-numbers"><a href="#line80" name="line80">80</a></td>
+<td class="code idle"> metricno <span class="Keyword">=</span> tocheck</td>
+</tr>
+<tr id="line81">
+<td class="line-numbers"><a href="#line81" name="line81">81</a></td>
+<td class="code idle"> greatestmetric <span class="Keyword">=</span> metric</td>
+</tr>
+<tr id="line82">
+<td class="line-numbers"><a href="#line82" name="line82">82</a></td>
+<td class="code idle"> <span class="Keyword">print</span> metricno</td>
+</tr>
+<tr id="line83">
+<td class="line-numbers"><a href="#line83" name="line83">83</a></td>
+<td class="code idle"> <span class="Keyword">print</span> greatestmetric </td>
+</tr>
+<tr id="line84">
+<td class="line-numbers"><a href="#line84" name="line84">84</a></td>
+<td class="code idle"> <span class="Keyword">return</span> greatestmetric </td>
+</tr>
+<tr id="line85">
+<td class="line-numbers"><a href="#line85" name="line85">85</a></td>
+<td class="code idle"> </td>
+</tr>
+<tr id="line86">
+<td class="line-numbers"><a href="#line86" name="line86">86</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName">extractKeywords</span>(<span class="FunctionArgument">self</span>, <span class="FunctionArgument">question</span>):</td>
+</tr>
+<tr id="line87">
+<td class="line-numbers"><a href="#line87" name="line87">87</a></td>
+<td class="code idle"> <span class="Variable">self</span>.tomatchwords <span class="Keyword">=</span> []</td>
+</tr>
+<tr id="line88">
+<td class="line-numbers"><a href="#line88" name="line88">88</a></td>
+<td class="code idle"> <span class="Keyword">print</span> question</td>
+</tr>
+<tr id="line89">
+<td class="line-numbers"><a href="#line89" name="line89">89</a></td>
+<td class="code idle"> <span class="Keyword">for</span> tag <span class="Keyword">in</span> question:</td>
+</tr>
+<tr id="line90">
+<td class="line-numbers"><a href="#line90" name="line90">90</a></td>
+<td class="code idle"> <span class="Keyword">if</span> tag[<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>NN<span class="String">&quot;</span></span> <span class="Keyword">or</span> tag[<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>JJ<span class="String">&quot;</span></span> <span class="Keyword">or</span> tag[<span class="Number">1</span>] <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>NNP<span class="String">&quot;</span></span>:</td>
+</tr>
+<tr id="line91">
+<td class="line-numbers"><a href="#line91" name="line91">91</a></td>
+<td class="code idle"> <span class="Variable">self</span>.tomatchwords.append(tag[<span class="Number">0</span>])</td>
+</tr>
+<tr id="line92">
+<td class="line-numbers"><a href="#line92" name="line92">92</a></td>
+<td class="code idle"> <span class="Keyword">print</span> <span class="Variable">self</span>.tomatchwords </td>
+</tr>
+<tr id="line93">
+<td class="line-numbers"><a href="#line93" name="line93">93</a></td>
+<td class="code idle"> <span class="Keyword">return</span> <span class="Variable">self</span>.tomatchwords </td>
+</tr>
+<tr id="line94">
+<td class="line-numbers"><a href="#line94" name="line94">94</a></td>
+<td class="code idle"></td>
+</tr>
+<tr id="line95">
+<td class="line-numbers"><a href="#line95" name="line95">95</a></td>
+<td class="code idle"> <span class="Storage">def</span> <span class="FunctionName">reportAnswer</span>(<span class="FunctionArgument">self</span>,):</td>
+</tr>
+<tr id="line96">
+<td class="line-numbers"><a href="#line96" name="line96">96</a></td>
+<td class="code idle"> <span class="Variable">self</span>.file <span class="Keyword">=</span> <span class="LibraryClassType">open</span>(<span class="String"><span class="String">&quot;</span>./FAQ/sugar.txt<span class="String">&quot;</span></span>,<span class="String"><span class="String">&quot;</span>rb<span class="String">&quot;</span></span>)</td>
+</tr>
+<tr id="line97">
+<td class="line-numbers"><a href="#line97" name="line97">97</a></td>
+<td class="code idle"> content <span class="Keyword">=</span> <span class="Variable">self</span>.file.read()</td>
+</tr>
+<tr id="line98">
+<td class="line-numbers"><a href="#line98" name="line98">98</a></td>
+<td class="code idle"> <span class="LibraryClassType">tuple</span> <span class="Keyword">=</span> content.split(<span class="Variable">self</span>.mostprobableQ)</td>
+</tr>
+<tr id="line99">
+<td class="line-numbers"><a href="#line99" name="line99">99</a></td>
+<td class="code idle"> <span class="Variable">self</span>.file.close()</td>
+</tr>
+<tr id="line100">
+<td class="line-numbers"><a href="#line100" name="line100">100</a></td>
+<td class="code idle"> <span class="Keyword">return</span> <span class="LibraryClassType">tuple</span>[<span class="Number">1</span>].split(<span class="String"><span class="String">'</span><span class="UserDefinedConstant">\n</span><span class="String">'</span></span>)[<span class="Number">1</span>]</td>
+</tr>
+</table> </div>
+ <div id="footer">
+ <ul>
+ <li><a href="/">Home</a> | </li>
+ <li><a href="/about">About</a> | </li>
+ <li><a href="/about/faq">FAQ</a> | </li>
+ <li><a href="http://groups.google.com/group/gitorious">Discussion group</a></li>
+ </ul>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/test.py b/test.py
index 0ede2dd..3afc1b2 100644
--- a/test.py
+++ b/test.py
@@ -1,5 +1,5 @@
from libRLP import *
-process = InputBreaker('what is different in sugar and not in other software?')
+process = InputBreaker('tell me about sugar development')
matchobj = Match(process.qEntitySentences)
answer = matchobj.reportAnswer()
print '\n\n'