#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

import dissociated_press as dp
from time import sleep
from sys import argv

if len(argv) == 1:
    infile = "PLOMDATA"
else:
    infile = argv[1]

DEBUG = False
N = 2

d = dp.dictionary(debug=DEBUG)

f = open(infile,"r")
input = [x[:-1] for x in f.readlines() if x.endswith("\n")]
f.close()

for i, l in enumerate(input):
    if DEBUG:
        print l
    d.dissociate(l, N=N)
    if i%100 == 0:
        print i

try:
    while 1:
        sentence = d.associate()
#!/usr/bin/python
# -*- coding: utf-8 -*-

import dissociated_press as d

s = d.sentence("Der behandschuhte Mann haut ein Kind.")
t = d.sentence("Der Mann kotzt.")
u = d.sentence("Ein Kind kotzt.")
v = d.sentence("")

dict = d.dictionary()

s.dissociate(dict)
t.dissociate(dict)
u.dissociate(dict)
v.dissociate(dict)

for i in range(0,20):
    print dict.associate()
Esempio n. 3
0
# Date: Sat Apr 25 09:54:24 +0000 2009
def parsedate(line):
    try:
        return datetime.strptime(re.sub(r"(st|nd|rd|th),", ",", line),"Date: %I:%M %p %b %d, %Y\n")
    except ValueError:
        return datetime.strptime(line,"Date: %a %b %d %H:%M:%S +0000 %Y\n")
 


infile = config.local.tweetdata
f = open(infile,"r")

# initialize
distr = {} # the distribution of the time of day of the tweets
distrN = 0 # for probability distribution normalization
d = diss.dictionary(debug=DEBUG) # THE dictionary
input = [] # for comparison to avoid simple reposts

for line in f:
    if line[:6] == "Date: ":
        t = parsedate(line).time()
        try: distr[(t.minute + t.hour*60)/(BINWIDTH)] += 1
        except KeyError: distr[(t.minute + t.hour*60)/(BINWIDTH)] = 1
        distrN += 1
    elif line[:6] == "Text: ":
        d.dissociate(line[6:],N=N)
        input.append(line[6:])
f.close()

# the real main loop
while not TEST:
Esempio n. 4
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import dissociated_press as dp
from sys import argv
import cProfile as profile

if len(argv) == 1:
    infile = "PLOMDATA"
else:
    infile = argv[1]

N = 2

d = dp.dictionary(debug=False)
f = open(infile,"r")
input = f.readlines()
f.close()

profile_runs = [ 'for i, l in enumerate(input): d.dissociate(l, N=N)', 'for i in xrange(1000): d.associate()' ]

for p in profile_runs:
    print p
    profile.run(p)
    print "========================"