class Summarizer:
def __init__(self):
model_name = sb_properties.SUMMARIZER_MODEL
api_token = sb_helper.get_hf_api()
logger.debug("Using {} as summarization model".format(model_name))
self.api_url = "https://api-inference.huggingface.co/models/" + model_name
self.model_id = model_name
self.headers = {"Authorization": "Bearer {}".format(api_token)}
def summarize_text(self, text_to_summarize):
payload = {"inputs" : text_to_summarize}
response = requests.post(self.api_url, headers=self.headers, json=payload)
return response.json()
import wikipedia
def retrieve_summary(self,topic):
try:
page = wikipedia.page(topic)
logger.debug("Found page with title {}".format(page.title))
logger.debug("Found page with url {}".format(page.url))
return page.summary
except wikipedia.exceptions.PageError:
logger.error("Page about topic {} not found ".format(topic))
except wikipedia.exceptions.DisambiguationError:
logger.error("Disambiguation error for topic {} ".format(topic))
except Exception as e:
logger.error("Error %s", e)
The Alcubierre drive, Alcubierre warp drive, or Alcubierre metric (referring to metric tensor) is a speculative warp drive idea based on a solution of Einstein's field equations in general relativity as proposed by theoretical physicist Miguel Alcubierre during his PhD study at the University of Wales, Cardiff, by which a spacecraft could achieve apparent faster-than-light travel if a configurable energy-density field lower than that of vacuum (that is, negative mass) could be created.
Rather than exceeding the speed of light within a local reference frame, a spacecraft would traverse distances by contracting space in front of it and expanding space behind it, resulting in effective faster-than-light travel.
The Alcubierre drive, Alcubierre warp drive, or Alcubierre metric (referring to metric tensor) is a speculative warp drive idea based on a solution of Einstein's field equations in general relativity as proposed by theoretical physicist Miguel Alcubierre during his PhD study at the University of Wales, Cardiff, by which a spacecraft could achieve apparent faster-than-light travel if a configurable energy-density field lower than that of vacuum (that is, negative mass) could be created.[1][2]
Rather than exceeding the speed of light within a local reference frame, a spacecraft would traverse distances by contracting space in front of it and expanding space behind it, resulting in effective faster-than-light travel. Objects cannot accelerate to the speed of light within normal spacetime; instead, the Alcubierre drive shifts space around an object so that the object would arrive at its destination more quickly than light would in normal space without breaking any physical laws.[3]
Although the metric proposed by Alcubierre is consistent with the Einstein field equations, construction of such a drive is not necessarily possible. The proposed mechanism of the Alcubierre drive implies a negative energy density and therefore requires exotic matter or manipulation of dark energy.[4] If exotic matter with the correct properties cannot exist, then the drive cannot be constructed. At the close of his original article,[5] however, Alcubierre argued (following an argument developed by physicists analyzing traversable wormholes[6][7]) that the Casimir vacuum between parallel plates could fulfill the negative-energy requirement for the Alcubierre drive.
Another possible issue is that, although the Alcubierre metric is consistent with Einstein's equations, general relativity does not incorporate quantum mechanics. Some physicists have presented arguments to suggest that a theory of quantum gravity (which would incorporate both theories) would eliminate those solutions in general relativity that allow for backwards time travel (see the chronology protection conjecture) and thus make the Alcubierre drive invalid.
from Questgen import main
def generate_questions(self, question_context):
payload = {
"input_text": question_context
}
output = main.QGen().predict_shortq(payload)
if output:
logger.debug(output)
return output['questions']
else:
return None
import string
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity
from nltk.corpus import stopwords
import pandas as pdimport re
from nltk.corpus import wordnet
import nltk
from nltk.stem import WordNetLemmatizer
def clean_string(text):
text = ''.join([word for word in text if word not in string.punctuation])
text = text.lower()
text = re.sub(r'[^\x00-\x7F]+', ' ', text)
text = re.sub(r'\s{2,}', ' ', text)
text = ' '.join([word for word in text.split() if word not in stop_words])
text = ' '.join([lemmatizer.lemmatize(w) for w in nltk.word_tokenize(text)])
return text
def compute_chunks_similarity(self, column):
cleaned_strings = list(map(clean_string, self.model[column].values))
vectorizer = CountVectorizer().fit_transform(cleaned_strings)
vectors = vectorizer.toarray()
return (cosine_similarity(vectors))