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
ba4b4997
Commit
ba4b4997
authored
Apr 20, 2023
by
Lelkada L L P S M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor app changes
parent
2a087a53
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
59 additions
and
15 deletions
+59
-15
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_generation.cpython-311.pyc
App/Backend/__pycache__/word_generation.cpython-311.pyc
+0
-0
App/Backend/content_filtration.py
App/Backend/content_filtration.py
+2
-1
App/Backend/flip_card_content.py
App/Backend/flip_card_content.py
+1
-0
App/Backend/word_generation.py
App/Backend/word_generation.py
+20
-6
App/Frontend/ReadME.md
App/Frontend/ReadME.md
+1
-0
App/Frontend/screens/ContentFiltrationScreen.js
App/Frontend/screens/ContentFiltrationScreen.js
+14
-6
App/Frontend/screens/FlipCardGameScreen.js
App/Frontend/screens/FlipCardGameScreen.js
+1
-1
App/Frontend/screens/HomeScreen.js
App/Frontend/screens/HomeScreen.js
+19
-0
App/Frontend/screens/WordGenerationScreen.js
App/Frontend/screens/WordGenerationScreen.js
+1
-1
No files found.
App/Backend/__pycache__/content_filtration.cpython-311.pyc
View file @
ba4b4997
No preview for this file type
App/Backend/__pycache__/flip_card_content.cpython-311.pyc
View file @
ba4b4997
No preview for this file type
App/Backend/__pycache__/word_generation.cpython-311.pyc
View file @
ba4b4997
No preview for this file type
App/Backend/content_filtration.py
View file @
ba4b4997
...
...
@@ -2,7 +2,7 @@ from flask import request
from
pymongo
import
MongoClient
def
check_word_safety
(
word
):
client
=
MongoClient
(
"mongodb+srv://
xxxx:xxxx@cluster0.kddd
dr.mongodb.net"
)
client
=
MongoClient
(
"mongodb+srv://
hearme:hearme678@cluster0.kz66v
dr.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
:
...
...
App/Backend/flip_card_content.py
View file @
ba4b4997
import
pymongo
def
getFlipCardContent
():
client
=
pymongo
.
MongoClient
(
"mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net"
)
db
=
client
[
'word_card'
]
collection
=
db
[
'card'
]
...
...
App/Backend/word_generation.py
View file @
ba4b4997
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
App/Frontend/ReadME.md
View file @
ba4b4997
...
...
@@ -10,5 +10,6 @@ expo install react-native-svg
### Start app
expo start
\ No newline at end of file
App/Frontend/screens/ContentFiltrationScreen.js
View file @
ba4b4997
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
...
...
App/Frontend/screens/FlipCardGameScreen.js
View file @
ba4b4997
...
...
@@ -112,7 +112,7 @@ export default function FlipCardGame() {
const
fetchImagesData
=
async
()
=>
{
try
{
const
response
=
await
fetch
(
'
http://192.168.1
37.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);
...
...
App/Frontend/screens/HomeScreen.js
View file @
ba4b4997
...
...
@@ -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
;
App/Frontend/screens/WordGenerationScreen.js
View file @
ba4b4997
...
...
@@ -20,7 +20,7 @@ const screenHeight = Dimensions.get("window").height;
const
fetchCards
=
async
()
=>
{
try
{
const
response
=
await
fetch
(
'
http://192.168.1
37.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
;
...
...
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