Beispiel #1
0
stream = tweetstream.SampleStream(username,password)
lc = LossyCounter(args.s)

N=0
while True:
    try:
        t = stream.next()
    except Exception, e:
        print e
        break
    if t.has_key("text"):
        tags = re.findall("#[A-Za-z0-9]+", t["text"])
        if len(tags) > 0:
            for tag in tags:
                print tag
                N+=1
                lc.count_element(tag)

            if N > 0 and N % 500 == 0:
                counts = lc.get_counts()
                print
                print " N = %i" % N
                print "=============================="
                print "%s\t%s\t%s" % ("tag".ljust(30), "f".ljust(6), "delta".ljust(6))
                print "-"*30 + "\t" + "-"*6 + "\t" + "-"*6
                for e in counts:
                    print "%s\t%6i\t%6i" % (e.e.ljust(30), e.f, e.delta)
                print "=============================="
                print

Beispiel #2
0
        description=description,
        epilog=epilog)

    parser.add_argument('datafile', metavar='FILE',
                       help='Text file with one integer per line')
    parser.add_argument('-s', '--s', dest='s', action='store', type=float, required=True,
                       help='Minimum frequency')

    args = parser.parse_args()
    
    return args

args = parse_command_line_arguments()

f = open(args.datafile)
s = args.s

lc = LossyCounter(s)

for l in f:
    n = int(l)
    lc.count_element(n)

counts = lc.get_counts()

print "n\tf\tdelta"
for e in counts:
    print "%i\t%i\t%i" % (e.e, e.f, e.delta)
    

Beispiel #3
0
                        help='Text file with one integer per line')
    parser.add_argument('-s',
                        '--s',
                        dest='s',
                        action='store',
                        type=float,
                        required=True,
                        help='Minimum frequency')

    args = parser.parse_args()

    return args


args = parse_command_line_arguments()

f = open(args.datafile)
s = args.s

lc = LossyCounter(s)

for l in f:
    n = int(l)
    lc.count_element(n)

counts = lc.get_counts()

print "n\tf\tdelta"
for e in counts:
    print "%i\t%i\t%i" % (e.e, e.f, e.delta)