Jump to content

  • Log In with Google      Sign In   
  • Create Account

Tutorial Doctor

Member Since 19 Oct 2013
Offline Last Active Today, 02:33 AM

Posts I've Made

In Topic: A Python Program that can Interpret a sentence (help)

Yesterday, 01:29 AM

I've been working on several small systems dealing with interpreting (working on a fuzzy logic one now). I like your suggestion above. I do need one that can answer questions (mine is just trying to interpret statements.)

I like that setup too.

I could have a set of question words, and then somehow create a system on how to interpret a question.

I think I almost have a supposition system (it can suppose something based on a condition). But I need to add a bit of probability, so I am simulating set notation in python. Etc.

Cool stuff nevertheless.

Decided to check stack overflow for help:

# Sets#import dis

A = [1,2,3]
B = [4,5,6,3,2]
C = ['a','b',3]

### BORROWED CODE
def getIntersection(*S):
    sets = iter(map(set, S))
    result = sets.next()
    for s in sets:
        result = result.intersection(s)
    return list(set(result))
print getIntersection(A,B,C)
### END BORROWED CODE


def getUnion(*S):
	result = set().union(*S)
	return list(set(result))
print getUnionS(A,B,C)

In Topic: What are the apps which you use most ?

Yesterday, 01:24 AM

IOS:

Notes
Editorial (Python code able text editor)
Pythonista (mobile python IDE)
Documents By Readdle (Local document management)
Dropbox(cloud storage)
Flipboard (News)
Inkpad (Open Source Vector Drawing app)
Art Set (Traditional art set painting app)
Wiki Offline (offline Wikipedia)
Snapguide (DIY guides)
Speedtest.net (never trust Comcast)
Glassdoor (job search (jobless right now))
White Pages (reverse phone lookup)
iTriage (medical info)

Much more where that came from, but yeah.

In Topic: A Python Program that can Interpret a sentence (help)

17 December 2014 - 09:44 AM

Ahh, good ol Markov chains. Thanks Nypyren. I will look into all of this.

 

I do have some pretty interesting stuff going now. I can get phrases, but I can't get super phrases of a phrase in a sentence. I will post what I have when I am kn the laptop. 


In Topic: A Python Program that can Interpret a sentence (help)

17 December 2014 - 01:14 AM

I need to be able to do Phrases as well, not just words. Any tips?

In Topic: A Python Program that can Interpret a sentence (help)

16 December 2014 - 03:25 PM

Okay, the following code corrects a string based on some sample text. 

#http://norvig.com/spell-correct.html
# By Peter Norvig
 
import re, collections
 
 
sample_text = 'you are not fair'
misspelled = 'yu ar nt far'
 
def words(text): return re.findall('[a-z]+', text.lower()) 
 
def train(features):
    model = collections.defaultdict(lambda: 1)
    for f in features:
        model[f] += 1
    return model
 
NWORDS = train(words(sample_text))
 
alphabet = 'abcdefghijklmnopqrstuvwxyz'
 
def edits1(word):
   splits     = [(word[:i], word[i:]) for i in range(len(word) + 1)]
   deletes    = [a + b[1:] for a, b in splits if b]
   transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1]
   replaces   = [a + c + b[1:] for a, b in splits for c in alphabet if b]
   inserts    = [a + c + b     for a, b in splits for c in alphabet]
   return set(deletes + transposes + replaces + inserts)
 
def known_edits2(word):
    return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS)
 
def known(words): return set(w for w in words if w in NWORDS)
 
def correct(word):
    candidates = known([word]) or known(edits1(word)) or known_edits2(word) or [word]
    return max(candidates, key=NWORDS.get)
 
correction = correct(misspelled_word)
 
 
for word in misspelled.split(' '):
print correct(word),
 

Could I mix this in somehow?

 

>> You are not fair


PARTNERS