Package de.jetwick.snacktory

Examples of de.jetwick.snacktory.JResult


        initTweetCache();
        urlExtractor = new UrlExtractor() {

            @Override
            public JResult getInfo(String originalUrl, int timeout) throws Exception {
                JResult res = UrlEntry.createSimpleResult(originalUrl);
                return res;
            }
        };

        int counter = 0;
View Full Code Here


                    unresolvedCache.remove(resUrl);
                    doFetch = false;
                }
            }
            if (doFetch) {
                JResult res = fetcher.fetchAndExtract(url, resolveTimeout, false);

                // set resolved url
                if (tweet.getUrlEntries().size() > 0) {
                    UrlEntry ue = tweet.getUrlEntries().iterator().next();
                    ue.setResolvedUrl(res.getUrl());
                    ue.setResolvedTitle(res.getTitle());
                    ue.setResolvedSnippet(res.getText());
                    ue.setResolvedDomain(Helper.extractDomain(url));
                }

                if (urlTitleCleaner.contains(res.getTitle()))
                    tweet.setQuality(20);

                if (res.getTitle().isEmpty())
                    emptyTitleCounter.addAndGet(1);
                counter.addAndGet(1);
                if (thread < 3) {
                    float secs = (System.nanoTime() - start.get()) / 1e+9f;
                    logger.info(thread + "| " + counter.get() / secs + " entries/sec"//, secs:" + secs
View Full Code Here

    public String toString() {
        return "title:" + getResolvedTitle() + " url:" + getResolvedUrl();
    }

    public static JResult createSimpleResult(String url) {
        JResult res = new JResult();
        res.setOriginalUrl(url);
        res.setUrl(url);
        return res;
    }
View Full Code Here

            StringBuilder tmpSb = new StringBuilder();
            int lastIndex = onNewRawUrl(index, tmpSb);

            if (lastIndex > 0) {
                String url = tmpSb.toString();
                JResult res = null;
                try {
                    res = getInfo(url, index2);
                } catch (Exception ex) {
//                    logger.info("Error while resolving:" + url, ex);
                    res = new JResult();
                }
                if (res.getUrl().isEmpty())
                    res.setUrl(url);

                UrlEntry entry = new UrlEntry(index, lastIndex, res.getUrl());
                if (res.getTitle().isEmpty())
                    entry.setResolvedTitle(url);
                else
                    entry.setResolvedTitle(res.getTitle());

                entry.setResolvedDomain(Helper.extractDomain(url));
                urlEntries.add(entry);
            }
        }
View Full Code Here

                return urlAsString + "_r";
            }

            @Override
            public JResult fetchAndExtract(String url, int timeout, boolean resolve) throws Exception {
                JResult res = new JResult();
                return res.setUrl(url).setTitle(url + "_t");
            }
        };
        resolver.setHtmlFetcher(fetcher);
        JTweet tw = createTweet(1L, "http://hiho.de");
        resolver.putObject(tw);
View Full Code Here

                return urlAsString + "_r";
            }

            @Override
            public JResult fetchAndExtract(String url, int timeout, boolean resolve) throws Exception {
                JResult res = new JResult();
                return res.setUrl(url).setTitle(url + "_t");
            }
        };
        resolver.setHtmlFetcher(fetcher);
        // use persistent tweet otherwise elasticTweetSearch won't update the tweet (and the retweet count)
        resolver.putObject(createTweetWithUrlEntries(1L, "http://hiho.de", 10, "http://hiho.de").makePersistent());
View Full Code Here

*/
public class FakeUrlExtractor extends UrlExtractor {

    @Override
    public JResult getInfo(String url, int timeout) {
        return new JResult().setUrl(url + "_x").setTitle(url + "_t").setText(url + "_s");
    }
View Full Code Here

TOP

Related Classes of de.jetwick.snacktory.JResult

Copyright © 2018 www.massapicom. 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.