Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 18
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J 18
22_23-J 18
Commits
2a087a53
Commit
2a087a53
authored
Apr 20, 2023
by
Lelkada L L P S M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
content filtration screen
parent
f54b02c8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
20 deletions
+90
-20
App/Backend/__pycache__/content_filtration.cpython-311.pyc
App/Backend/__pycache__/content_filtration.cpython-311.pyc
+0
-0
App/Backend/__pycache__/flip_card_content.cpython-311.pyc
App/Backend/__pycache__/flip_card_content.cpython-311.pyc
+0
-0
App/Backend/__pycache__/word_card_game.cpython-311.pyc
App/Backend/__pycache__/word_card_game.cpython-311.pyc
+0
-0
App/Backend/__pycache__/word_generation.cpython-311.pyc
App/Backend/__pycache__/word_generation.cpython-311.pyc
+0
-0
App/Backend/content_filtration.py
App/Backend/content_filtration.py
+26
-0
App/Backend/server.py
App/Backend/server.py
+11
-20
App/Frontend/App.js
App/Frontend/App.js
+4
-0
App/Frontend/screens/ContentFiltrationScreen.js
App/Frontend/screens/ContentFiltrationScreen.js
+49
-0
No files found.
App/Backend/__pycache__/content_filtration.cpython-311.pyc
0 → 100644
View file @
2a087a53
File added
App/Backend/__pycache__/flip_card_content.cpython-311.pyc
0 → 100644
View file @
2a087a53
File added
App/Backend/__pycache__/word_card_game.cpython-311.pyc
0 → 100644
View file @
2a087a53
File added
App/Backend/__pycache__/word_generation.cpython-311.pyc
0 → 100644
View file @
2a087a53
File added
App/Backend/content_filtration.py
0 → 100644
View file @
2a087a53
from
flask
import
request
from
pymongo
import
MongoClient
def
check_word_safety
(
word
):
client
=
MongoClient
(
"mongodb+srv://xxxx:xxxx@cluster0.kddddr.mongodb.net"
)
db
=
client
[
'word_filtration'
]
blacklist_col
=
db
[
'blacklist'
]
whitelist_col
=
db
[
'whitelist'
]
moderate_col
=
db
[
'moderate'
]
# Check if the word exists in the blacklist
if
blacklist_col
.
find_one
({
"word"
:
word
}):
return
"unsafe"
# Check if the word exists in the whitelist
whitelist_entry
=
whitelist_col
.
find_one
({
"word"
:
word
})
if
whitelist_entry
:
sensitive_score
=
whitelist_entry
.
get
(
"sensitive_score"
)
if
sensitive_score
==
1
:
return
"safe"
else
:
return
"unsafe"
# If the word does not exist in the whitelist
moderate_col
.
insert_one
({
"word"
:
word
,
"status"
:
"not_verified"
})
return
"not_verified"
App/Backend/server.py
View file @
2a087a53
...
...
@@ -6,31 +6,12 @@ from flask_cors import CORS
from
word_card_game
import
wordGameData
from
word_generation
import
get_similar_words
from
flip_card_content
import
getFlipCardContent
from
content_filtration
import
check_word_safety
app
=
Flask
(
__name__
)
#### Load pretrained models here ####
#model1 = pickle.load(open('model1.pkl','rb'))
# send a json {'exp':1.8,} as a post request to make a prediction
'''
@app.route('/api/predict',methods=['POST'])
def predict():
data = request.get_json(force=True)
prediction = model1.predict([[np.array(data['exp'])]])
output = prediction[0]
return jsonify(output)
#path to check server status
@app.route("/")
def default_get():
return "<p>HereMe Backend !</p>"
'''
@
app
.
route
(
'/api/word-game'
,
methods
=
[
'GET'
])
def
word_game_api
():
w1
=
request
.
args
.
get
(
'w1'
)
...
...
@@ -63,6 +44,16 @@ def get_images_data():
images_data
=
wordGameData
()
return
jsonify
(
images_data
)
@
app
.
route
(
'/check_word'
,
methods
=
[
'POST'
])
def
check_word
():
data
=
request
.
get_json
()
word
=
data
.
get
(
'word'
)
if
not
word
:
return
jsonify
({
"error"
:
"No word provided"
}),
400
result
=
check_word_safety
(
word
)
return
jsonify
({
"word"
:
word
,
"status"
:
result
}),
200
if
__name__
==
'__main__'
:
CORS
(
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
))
#app.run(host='0.0.0.0', port=5000, debug=True)
\ No newline at end of file
App/Frontend/App.js
View file @
2a087a53
...
...
@@ -10,6 +10,7 @@ import ProgressMapScreen from './screens/ProgressMapScreen';
import
WordGameScreen
from
'
./screens/WordGameScreen
'
;
import
PhoneticWordScreen
from
'
./screens/PhoneticWordsScreen
'
;
import
FlipCardGameScreen
from
'
./screens/FlipCardGameScreen
'
;
import
ContentFiltration
from
'
./screens/ContentFiltrationScreen
'
;
const
MainStack
=
createStackNavigator
(
{
...
...
@@ -40,6 +41,9 @@ const MainStack = createStackNavigator(
FlipCardGame
:
{
screen
:
FlipCardGameScreen
,
},
ContentFiltration
:
{
screen
:
ContentFiltration
,
},
},
{
initialRouteName
:
'
Login
'
,
...
...
App/Frontend/screens/ContentFiltrationScreen.js
0 → 100644
View file @
2a087a53
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
(
''
);
const
[
response
,
setResponse
]
=
useState
(
''
);
const
checkWord
=
async
()
=>
{
try
{
const
result
=
await
axios
.
post
(
'
http://192.168.137.111:5000/check_word
'
,
{
word
:
word
,
});
setResponse
(
result
.
data
.
status
);
}
catch
(
error
)
{
Alert
.
alert
(
'
Error
'
,
'
An error occurred while checking the word.
'
);
}
};
return
(
<
View
style
=
{
styles
.
container
}
>
<
TextInput
style
=
{
styles
.
input
}
onChangeText
=
{
setWord
}
value
=
{
word
}
placeholder
=
"
Enter a word
"
/>
<
Button
title
=
"
Check
"
onPress
=
{
checkWord
}
/
>
{
response
?
<
Text
style
=
{
styles
.
response
}
>
Status
:
{
response
}
<
/Text> : null
}
<
/View
>
);
}
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
justifyContent
:
'
center
'
,
paddingHorizontal
:
16
,
},
input
:
{
height
:
40
,
borderColor
:
'
gray
'
,
borderWidth
:
1
,
marginBottom
:
16
,
},
response
:
{
marginTop
:
16
,
},
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment