Exemplo n.º 1
0
def test_output():
    post_URL = request.args.get("postURL")

    eg_subreddit = fu.subreddit(post_URL)

    postAtt = fu.rcommentLink(post_URL)

    eg_postTitle = postAtt.title

    eg_comment = [comment.body for comment in postAtt.comments][0]

    commentCreated = int([comment.created_utc for comment in postAtt.comments][0])
    postCreated = postAtt.created_utc

    timeDiffC = fu.timePresent(round(commentCreated - postCreated))
    timeDiffCur = fu.timePresent(round(time.time() - commentCreated))

    comLength = fu.cLength(fu.comLength(eg_comment))

    sentiment = ""
    sentiment = fu.sentiment(eg_comment)

    features = fu.features(eg_subreddit, post_URL, eg_comment, commentCreated)

    eg_prob = ""
    eg_prob = fu.probability(features)

    eg_score = [comment.score for comment in postAtt.comments][0]

    eg_commentForm = fu.commentSent(eg_comment)

    return render_template(
        "testOutput.html",
        eg_postTitle=eg_postTitle,
        eg_commentForm=eg_commentForm,
        eg_score=eg_score,
        eg_prob=eg_prob,
        sentiment=sentiment,
        comLength=comLength,
        timeDiffCur=timeDiffCur,
        timeDiffC=timeDiffC,
        eg_comment=eg_comment,
        post_URL=post_URL,
        eg_subreddit=eg_subreddit,
    )
Exemplo n.º 2
0
def output():
    post = request.args.get("post")
    comment = request.args.get("comment")

    postAtt = fu.rcommentLink(post)
    postTitle = postAtt.title

    the_subreddit = ""
    the_subreddit = fu.subreddit(post)

    the_post = ""
    the_post = post

    your_comment = ""
    your_comment = comment

    features = fu.features(the_subreddit, post, comment, time.time())

    timePost = ""
    timePost = fu.timePresent(features[4])

    comLength = ""
    comLength = fu.cLength(features[5])

    sentiment = ""
    sentiment = fu.sentiment(your_comment)

    prob = ""
    prob = fu.probability(features)

    commentForm = fu.commentSent(your_comment)

    return render_template(
        "output.html",
        postTitle=postTitle,
        commentForm=commentForm,
        prob=prob,
        timePost=timePost,
        comLength=comLength,
        sentiment=sentiment,
        the_subreddit=the_subreddit,
        the_post=the_post,
        your_comment=your_comment,
    )
Exemplo n.º 3
0
    # Set of actions U
    actions = [(1, 0), (-1, 0), (0, -1), (0, 1)]

    # Initial state
    init = (3, 0)

    # Discount factor
    gamma = 0.99

    # Number of steps
    N = 7

    # Deterministic: stocha = False; Stochastic: stocha = True
    stocha = True

    test = f.probability((0, 2), (0, 4), (0, 1), stocha, domain)

    # mu* the optimal policy
    opt_policy = f.compute_policy(gamma, N, stocha, domain)

    dyn_matrix = np.full((916, domain.shape[0], domain.shape[1]), np.inf)

    # J_{mu*}^N for every state
    J_values = np.zeros((5, 5))
    for i in range(5):
        for j in range(5):
            state = (i, j)

            J_values[i, j] = f.expected_return(state, domain, gamma, 916,
                                               stocha, dyn_matrix, opt_policy)
Exemplo n.º 4
0
def proba(T, L, cycles):
    state=True; proba = True; accept=False
    stead = int(1e4)
    cycles = cycles
    store = monteCarlo(T,L, cycles, False, state, accept, proba)
    probability(store, L, T, stead)