Examples of TweetStoreConnection


Examples of net.fortytwo.twitlogic.persistence.TweetStoreConnection

                                               final Set<User> users,
                                               final Date startTime) throws TweetStoreException, TwitterClientException, HandlerException {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    TweetStoreConnection c = store.createConnection();
                    try {
                        // Note: don't run old tweets through the command listener, or
                        // TwitLogic will respond, annoyingly, to old commands.
                        client.processTimelineFrom(users, startTime, new Date(), createAnnotator(store, client));
                    } finally {
                        c.close();
                    }
                } catch (Throwable t) {
                    LOGGER.severe("historical tweets thread died with error: " + t);
                    t.printStackTrace();
                }
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.TweetStoreConnection

            // Create a persistent store.
            TweetStore store = new TweetStore();
            store.initialize();

            try {
                TweetStoreConnection c = store.createConnection();
                try {
                    URI iswc2009 = new URIImpl("http://twitlogic.fortytwo.net/hashtag/linkeddata");
                    RelatedHashtagsInferencer inf = new RelatedHashtagsInferencer(c.getSailConnection(), iswc2009);

                    int steps = 500;
                    int used = inf.compute(steps);

                    for (WeightedValue<Resource> wv : inf.currentResult().toSortedArray()) {
                        if (wv.value.toString().contains("hashtag")) {
//                            System.out.println("" + wv.weight + "\t" + wv.value);
                            System.out.println(((URI) wv.value).getLocalName());
                        }
                    }


//                    Collection<Resource> results = inf.currentResult();
                    Collection<Resource> results = inf.currentHashtagResults(20);

                    System.out.println("" + used + " of " + steps + " cycles used.  Results:");
                    for (Resource r : results) {
                        System.out.println("\t" + r);
                    }
                } finally {
                    c.close();
                }
            } finally {
                store.shutDown();
            }
        } catch (Throwable t) {
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.TweetStoreConnection

                                             final File outputFile) throws TweetStoreException, MalformedQueryException, SailException, QueryEvaluationException, IOException {
        OutputStream out = new FileOutputStream(outputFile);
        PrintStream ps = new PrintStream(out);

        try {
            TweetStoreConnection c = store.createConnection();
            try {
                ParsedQuery q = parseQuery(SELECT_DUMP_FIELDS);
                BindingSet bs = new MapBindingSet();
                SailConnection sc = c.getSailConnection();
                try {
                    sc.begin();
                    CloseableIteration<? extends BindingSet, QueryEvaluationException> results
                            = sc.evaluate(q.getTupleExpr(), q.getDataset(), bs, false);
                    try {
                        while (results.hasNext()) {
                            BindingSet r = results.next();
                            String timestamp = ((Literal) r.getBinding(TIMESTAMP).getValue()).getLabel().replaceAll("\t", " ");
                            String location = ((Literal) r.getBinding(LOCATION).getValue()).getLabel().replaceAll("\t", " ");
                            String text = ((Literal) r.getBinding(TEXT).getValue()).getLabel()
                                    .replaceAll("\t", " ")
                                    .replaceAll("\n", " ")
                                    .replaceAll("\r", " ");

                            ps.println(timestamp + "\t" + location + "\t" + text);
                        }
                    } finally {
                        results.close();
                    }
                } finally {
                    sc.rollback();
                    sc.close();
                }
            } finally {
                c.close();
            }
        } finally {
            out.close();
        }
    }
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.TweetStoreConnection

            // Create a persistent store.
            TweetStore store = new TweetStore();
            store.initialize();

            try {
                TweetStoreConnection c = store.createConnection();
                try {
                    URI iswc2009 = new URIImpl("http://data.semanticweb.org/conference/iswc/2009");
                    ConferenceInferencer inf = new ConferenceInferencer(c.getSailConnection(), iswc2009);

                    int steps = 50;
                    int used = inf.compute(steps);
//                    Collection<Resource> results = inf.currentResult();
                    Collection<Resource> results = inf.currentHashtagResults();

                    System.out.println("" + used + " of " + steps + " cycles used.  Results:");
                    for (Resource r : results) {
                        System.out.println("\t" + r);
                    }
                } finally {
                    c.close();
                }
            } finally {
                store.shutDown();
            }
        } catch (Throwable t) {
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.TweetStoreConnection

            // Create a persistent store.
            TweetStore store = new TweetStore();
            try {
                store.initialize();

                TweetStoreConnection c = store.createConnection();
                try {
                    SailConnection sc = c.getSailConnection();
                    try {
                        sc.begin();
                        SparqlTools.executeQuery(GOLD_TWEETS_QUERY, sc, System.out, 100, SparqlTools.SparqlResultFormat.JSON);
                    } finally {
                        sc.rollback();
                        sc.close();
                    }
                    //queryAndWriteJSON(ISWC_STATEMENTS_QUERY, sc, System.out);
                } finally {
                    c.close();
                }
            } finally {
                store.shutDown();
            }
        } catch (Throwable t) {
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.TweetStoreConnection

        TweetStore store = new TweetStore();
        store.initialize();

        try {
            TweetStoreConnection c = store.createConnection();

            try {
                PersistenceContext pc
                        = new PersistenceContext(c);

                PlacePersistenceHelper ph = new PlacePersistenceHelper(pc, client, false);
                for (String id : ids) {
                    Place p = new Place(id);
                    Feature f = pc.persist(p);
                    ph.submit(p, f);
                    c.commit();
                }
            } finally {
                c.rollback();
                c.close();
            }
        } finally {
            store.shutDown();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.