This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_content_gaps(content_formats): | |
content_gaps = dict() | |
SERP_features = content_formats["serp_features"] | |
content_gaps["url"] = content_formats["url"] | |
#Check if an image feature is necessary and the page doesn't have it | |
content_gaps["image"] = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from jsonpath_ng import jsonpath, parse | |
def get_content_formats(filename): | |
content_formats = dict() | |
image = parse("$..image") | |
video = parse("$..embedUrl") | |
local_business = parse("$..address") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_feature_names(indices): | |
serp_index=["Instant answer", "Knowledge panel", "Carousel", "Local pack", "Top stories", "Image pack", "Site links", "Reviews", "Tweet", "Video", "Featured video", "Featured Snippet", "AMP", "Image", "AdWords top", "AdWords bottom", "Shopping ads", "Hotels Pack", "Jobs search", "Featured images", "Video Carousel", "People also ask"] | |
index_list = indices.split(",") | |
feature_names = list() | |
for i in index_list: | |
if len(i) > 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from urllib.parse import urlencode, urlparse, urlunparse, quote | |
import pandas as pd | |
#def get_seo_branded_data(brand, domain, database="us", export_columns="Ph,Po,Nq,Ur,Tg,Td,Ts", display_limit=10000, display_filter="+|Ph|Co|{brand}"): | |
#Found that SERP features is -> Fl in https://www.semrush.com/api-analytics/#columns | |
def get_serp_features(domain, database="us", export_columns="Ph,Fk", display_limit=100): | |
global key | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template=""" | |
input_features: | |
- | |
name: tokens | |
type: text | |
encoder: bert | |
config_path: uncased_L-12_H-768_A-12/bert_config.json | |
checkpoint_path: uncased_L-12_H-768_A-12/bert_model.ckpt | |
reduce_output: null | |
preprocessing: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fetchPrediction(TEXT = "give me a flight from baltimore to newark"){ | |
TEXT = encodeURI("tokens=BOS "+TEXT+" EOS"); | |
console.log(TEXT); | |
//You need to replace this temporary URL | |
var url = "https://e769db6e.ngrok.io/predict"; | |
var options = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template=""" | |
input_features: | |
- | |
name: tokens | |
type: text | |
level: word | |
encoder: rnn | |
cell_type: lstm | |
bidirectional: true | |
num_layers: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<script src="index.js"></script> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
TOP_N = 5 | |
BEST_ONLY = False | |
THRESHOLD_PROBABILITY = 0.65 | |
def get_similarity_suggestion(phrase, no_percentage=False): | |
graph = tf.Graph() | |
with tf.compat.v1.Session(graph = graph) as session: | |
embed = hub.Module(module_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here we combine both lists into a single set of unique phrases | |
messages = set(df_404s["phrase"].to_list() + df_canonicals["phrase"].to_list()) | |
messages = list(messages)[:-1] | |
similarity_input_placeholder = tf.placeholder(tf.string, shape=(None)) | |
similarity_message_encodings = embed(similarity_input_placeholder) | |
with tf.Session() as session: | |
session.run(tf.global_variables_initializer()) |