Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 27 additions & 102 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,34 @@
* @flow strict-local
*/

import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import React, {useState, useEffect} from 'react';
import {View, Text} from 'react-native';
import auth from '@react-native-firebase/auth';
import LoginScreen from './screens/Loginscreen';
import NavStack from './NavStack';

import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
export default function App() {
// Set an initializing state whilst Firebase connects
const [initializing, setInitializing] = useState(true);
const [user, setUser] = useState();

const App: () => React$Node = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
// Handle user state changes
function onAuthStateChanged(user) {
setUser(user);
console.log(user);
if (initializing) setInitializing(false);
}

const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
useEffect(() => {
const subscriber = auth().onAuthStateChanged(onAuthStateChanged);
return subscriber; // unsubscribe on unmount
}, []);

export default App;
if (initializing) return null;

if (!user) {
return <LoginScreen />;
}

return <NavStack />;
}
248 changes: 248 additions & 0 deletions BUGKILL.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "BUGKILL.ipynb",
"provenance": [],
"private_outputs": true,
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "Xp6R2O-y8Sen",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "code",
"metadata": {
"id": "kfGnaJpkVfSo",
"colab_type": "code",
"colab": {}
},
"source": [
"\n",
"#To use GPU FAISS use\n",
"!wget https://anaconda.org/pytorch/faiss-gpu/1.2.1/download/linux-64/faiss-gpu-1.2.1-py36_cuda9.0.176_1.tar.bz2\n",
"!tar xvjf /content/faiss-gpu-1.2.1-py36_cuda9.0.176_1.tar.bz2\n",
"!cp -r lib/python3.6/site-packages/* /usr/local/lib/python3.6/dist-packages/\n",
"!pip install mkl"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "LzhkYUPoVr2k",
"colab_type": "code",
"colab": {}
},
"source": [
"!python3 -c 'import tensorflow as tf; print(tf.__version__)'"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "nrT9ywnWVjx1",
"colab_type": "code",
"colab": {}
},
"source": [
"!pip uninstall tensorflow"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "BtjT3Td-bj_x",
"colab_type": "code",
"colab": {}
},
"source": [
"!pip install tensorflow==2.0.0-alpha0"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "fRKhQ1f5Vl4i",
"colab_type": "code",
"colab": {}
},
"source": [
"!pip install https://github.com/re-search/DocProduct/archive/v0.2.0_dev.zip\n",
"!pip install gpt2-estimator\n",
"!pip install pyarrow"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "2WSlwhdFC_0K",
"colab_type": "code",
"cellView": "both",
"colab": {}
},
"source": [
"\n",
"\n",
"def download_file_from_google_drive(id, destination):\n",
" URL = \"https://docs.google.com/uc?export=download\"\n",
"\n",
" session = requests.Session()\n",
"\n",
" response = session.get(URL, params = { 'id' : id }, stream = True)\n",
" token = get_confirm_token(response)\n",
"\n",
" if token:\n",
" params = { 'id' : id, 'confirm' : token }\n",
" response = session.get(URL, params = params, stream = True)\n",
"\n",
" save_response_content(response, destination) \n",
"\n",
"def get_confirm_token(response):\n",
" for key, value in response.cookies.items():\n",
" if key.startswith('download_warning'):\n",
" return value\n",
"\n",
" return None\n",
"\n",
"def save_response_content(response, destination):\n",
" CHUNK_SIZE = 32768\n",
"\n",
" with open(destination, \"wb\") as f:\n",
" for chunk in response.iter_content(CHUNK_SIZE):\n",
" if chunk: # filter out keep-alive new chunks\n",
" f.write(chunk)\n",
" \n",
"import os\n",
"import requests\n",
"\n",
"import urllib.request\n",
"\n",
"# Download the file from `url` and save it locally under `file_name`:\n",
"urllib.request.urlretrieve('https://github.com/naver/biobert-pretrained/releases/download/v1.0-pubmed-pmc/biobert_v1.0_pubmed_pmc.tar.gz', 'BioBert.tar.gz')\n",
"\n",
"if not os.path.exists('BioBertFolder'):\n",
" os.makedirs('BioBertFolder')\n",
" \n",
"import tarfile\n",
"tar = tarfile.open(\"BioBert.tar.gz\")\n",
"tar.extractall(path='BioBertFolder/')\n",
"tar.close()\n",
"\n",
"file_id = '1uCXv6mQkFfpw5txGnVCsl93Db7t5Z2mp'\n",
"\n",
"download_file_from_google_drive(file_id, 'Float16EmbeddingsExpanded5-27-19.pkl')\n",
"\n",
"file_id = 'https://onedrive.live.com/download?cid=9DEDF3C1E2D7E77F&resid=9DEDF3C1E2D7E77F%2132792&authkey=AEQ8GtkcDbe3K98'\n",
" \n",
"urllib.request.urlretrieve( file_id, 'DataAndCheckpoint.zip')\n",
"\n",
"if not os.path.exists('newFolder'):\n",
" os.makedirs('newFolder')\n",
"\n",
"import zipfile\n",
"zip_ref = zipfile.ZipFile('DataAndCheckpoint.zip', 'r')\n",
"zip_ref.extractall('newFolder')\n",
"zip_ref.close()"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ztuTHeW4jFiH",
"colab_type": "code",
"cellView": "both",
"colab": {}
},
"source": [
"# Load model weights and Q&A data. Double click to see code\n",
"\n",
"from docproduct.predictor import RetreiveQADoc\n",
"\n",
"pretrained_path = 'BioBertFolder/biobert_v1.0_pubmed_pmc/'\n",
"# ffn_weight_file = None\n",
"bert_ffn_weight_file = 'newFolder/models/bertffn_crossentropy/bertffn'\n",
"embedding_file = 'Float16EmbeddingsExpanded5-27-19.pkl'\n",
"\n",
"doc = RetreiveQADoc(pretrained_path=pretrained_path,\n",
"ffn_weight_file=None,\n",
"bert_ffn_weight_file=bert_ffn_weight_file,\n",
"embedding_file=embedding_file)"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "qZ110ZqNfBac",
"colab_type": "code",
"cellView": "both",
"colab": {}
},
"source": [
"#@title Type in your question (512 word limit) and search search parameters\n",
"\n",
"question_text = \"i am 18 and having frequent and painful urination, with a mild fever since 2-3 days\" #@param {type:\"string\"}\n",
"\n",
"search_similarity_by = 'answer' #@param ['answer', \"question\"]\n",
"\n",
"number_results_toReturn=10 #@param {type:\"number\"}\n",
"\n",
"answer_only=True #@param [\"False\", \"True\"] {type:\"raw\"}\n",
"\n",
"returned_results = doc.predict( question_text ,\n",
" search_by=search_similarity_by, topk=number_results_toReturn, answer_only=answer_only)\n",
"\n",
"print('')\n",
"anitr = 0\n",
"answer_array = []\n",
"for jk in range(len(returned_results)):\n",
" if (len(returned_results[jk])>300):\n",
" answer_array.append(returned_results[jk])\n",
"print(answer_array[anitr])\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "nU42uyTG_oZr",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
Loading