Commit ba4b4997 authored by Lelkada L L P S M's avatar Lelkada L L P S M

minor app changes

parent 2a087a53
......@@ -2,7 +2,7 @@ from flask import request
from pymongo import MongoClient
def check_word_safety(word):
client = MongoClient("mongodb+srv://xxxx:xxxx@cluster0.kddddr.mongodb.net")
client = MongoClient("mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net")
db = client['word_filtration']
blacklist_col = db['blacklist']
whitelist_col = db['whitelist']
......@@ -16,6 +16,7 @@ def check_word_safety(word):
whitelist_entry = whitelist_col.find_one({"word": word})
if whitelist_entry:
sensitive_score = whitelist_entry.get("sensitive_score")
print(sensitive_score)
if sensitive_score == 1:
return "safe"
else:
......
import pymongo
def getFlipCardContent():
client = pymongo.MongoClient("mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net")
db = client['word_card']
collection = db['card']
......
import torch
from transformers import RobertaTokenizer, RobertaForMaskedLM
import pymongo
import random
# Load the pretrained RoBERTa model and tokenizer
tokenizer = RobertaTokenizer.from_pretrained('roberta-base')
model = RobertaForMaskedLM.from_pretrained('roberta-base')
def get_similar_words(input_word, top_k=3):
print(input_word)
#connect to mongoDB
client = pymongo.MongoClient("mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net")
db_0 = client['vocabulary']
collection_0 = db_0['object_expore']
cursor = collection_0.find()
# Print out each document
for document in cursor:
print(document)
random_word = collection_0.aggregate([{'$sample': {'size': 1}}]).next()['object']
input_word = random_word.strip()
print(input_word)
# Create a masked sentence with the input word
masked_sentence = f"The {input_word} is related to the {tokenizer.mask_token}."
......@@ -39,14 +53,14 @@ def get_similar_words(input_word, top_k=3):
#connect mongo
client = pymongo.MongoClient("mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net")
db = client['word_card']
collection = db['card']
db_1 = client['word_card']
collection_1 = db_1['card']
document = {"card_0": result}
print('---------------')
print(document)
#print('---------------')
#print(document)
collection.delete_many({})
collection.insert_one(document)
collection_1.delete_many({})
collection_1.insert_one(document)
return result
......@@ -10,5 +10,6 @@ expo install react-native-svg
### Start app
expo start
\ No newline at end of file
import React, { useState } from 'react';
import { StyleSheet, Text, View, TextInput, Button, Alert } from 'react-native';
import axios from 'axios';
export default function ContentFiltration() {
const [word, setWord] = useState('');
......@@ -8,15 +7,24 @@ export default function ContentFiltration() {
const checkWord = async () => {
try {
const result = await axios.post('http://192.168.137.111:5000/check_word', {
word: word,
const response = await fetch('http://192.168.1.83:5000/check_word', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ word: word }),
});
setResponse(result.data.status);
if (!response.ok) {
throw new Error('An error occurred while checking the word.');
}
const result = await response.json();
setResponse(result.status);
} catch (error) {
Alert.alert('Error', 'An error occurred while checking the word.');
Alert.alert('Error', error.message);
}
};
return (
<View style={styles.container}>
<TextInput
......
......@@ -112,7 +112,7 @@ export default function FlipCardGame() {
const fetchImagesData = async () => {
try {
const response = await fetch('http://192.168.137.111:5000/api/images_data');
const response = await fetch('http://192.168.1.86:5000/api/images_data');
const data = await response.json();
//console.log(data);
......
......@@ -27,6 +27,11 @@ const HomeScreen = ({ navigation }) => {
<Image source={require('./assets/home/balloon.png')} style={styles.buttonImage} resizeMode="cover" />
<Text style={styles.buttonText}>Learn</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.buttonsettings} onPress={() => navigation.navigate('ContentFiltration')}>
<Image source={require('./assets/settings_icon.png')} style={styles.buttonImage} resizeMode="cover" />
<Text style={styles.buttonTextCensor}>Censor</Text>
</TouchableOpacity>
</View>
);
};
......@@ -108,6 +113,20 @@ const styles = StyleSheet.create({
textShadowOffset: { width: -1, height: 1 },
textShadowRadius: 10,
},
buttonsettings:{
top:-280,
right:-150,
size:1
},
buttonTextCensor: {
fontSize: 22,
fontWeight: 'bold',
color: 'black',
marginTop: -120,
textShadowOffset: { width: -1, height: 1 },
textShadowRadius: 10,
},
});
export default HomeScreen;
......@@ -20,7 +20,7 @@ const screenHeight = Dimensions.get("window").height;
const fetchCards = async () => {
try {
const response = await fetch('http://192.168.137.111:5000/api/similar-words?word=cat');
const response = await fetch('http://192.168.1.86:5000/api/similar-words?word=cat');
const data = await response.json();
//console.log(data)
return data.similar_words;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment