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
b5c46f5d
Commit
b5c46f5d
authored
Apr 20, 2023
by
Lelkada L L P S M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
word generation save mongo
parent
6807c444
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
6075 additions
and
8231 deletions
+6075
-8231
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/requirements.txt
App/Backend/requirements.txt
+2
-1
App/Backend/server.py
App/Backend/server.py
+1
-0
App/Backend/word_generation.py
App/Backend/word_generation.py
+13
-0
App/Frontend/package-lock.json
App/Frontend/package-lock.json
+245
-1514
App/Frontend/package.json
App/Frontend/package.json
+1
-1
App/Frontend/screens/FlipCardGameScreen.js
App/Frontend/screens/FlipCardGameScreen.js
+26
-2
App/Frontend/screens/SpeechTherapyScreen.js
App/Frontend/screens/SpeechTherapyScreen.js
+1
-0
App/Frontend/screens/WordGenerationScreen.js
App/Frontend/screens/WordGenerationScreen.js
+7
-3
App/Frontend/yarn.lock
App/Frontend/yarn.lock
+5779
-6710
No files found.
App/Backend/__pycache__/word_card_game.cpython-311.pyc
0 → 100644
View file @
b5c46f5d
File added
App/Backend/__pycache__/word_generation.cpython-311.pyc
0 → 100644
View file @
b5c46f5d
File added
App/Backend/requirements.txt
View file @
b5c46f5d
...
...
@@ -2,3 +2,4 @@ Flask==2.2.3
numpy==1.24.2
transformers
torch
pymongo
\ No newline at end of file
App/Backend/server.py
View file @
b5c46f5d
...
...
@@ -4,6 +4,7 @@ from flask import Flask, request, jsonify, request
from
word_card_game
import
wordGameData
from
word_generation
import
get_similar_words
from
flask_cors
import
CORS
import
pymongo
app
=
Flask
(
__name__
)
...
...
App/Backend/word_generation.py
View file @
b5c46f5d
import
torch
from
transformers
import
RobertaTokenizer
,
RobertaForMaskedLM
import
pymongo
# Load the pretrained RoBERTa model and tokenizer
tokenizer
=
RobertaTokenizer
.
from_pretrained
(
'roberta-base'
)
...
...
@@ -35,4 +36,16 @@ def get_similar_words(input_word, top_k=3):
'audio'
:
audio_url
})
print
(
result
)
#connect mongo
client
=
pymongo
.
MongoClient
(
"mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net"
)
db
=
client
[
'word_card'
]
collection
=
db
[
'card'
]
document
=
{
"card_0"
:
result
}
collection
.
delete_many
({})
collection
.
insert_one
(
document
)
return
result
App/Frontend/package-lock.json
View file @
b5c46f5d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
App/Frontend/package.json
View file @
b5c46f5d
...
...
@@ -17,7 +17,7 @@
"expo-screen-orientation"
:
"~5.1.1"
,
"expo-status-bar"
:
"~1.4.4"
,
"react"
:
"18.2.0"
,
"react-native"
:
"^0.71.
4
"
,
"react-native"
:
"^0.71.
6
"
,
"react-native-draggable"
:
"^3.3.0"
,
"react-native-draggable-flatlist"
:
"^4.0.1"
,
"react-native-gesture-handler"
:
"~2.9.0"
,
...
...
App/Frontend/screens/FlipCardGameScreen.js
View file @
b5c46f5d
...
...
@@ -45,8 +45,32 @@ const MessageBox = ({ visible, onClose }) => {
);
};
export
default
function
FlipCardGame
()
{
export
default
function
FlipCardGame
(
{
route
}
)
{
const
[
gameOver
,
setGameOver
]
=
useState
(
false
);
const
{
cards
}
=
route
.
params
;
console
.
log
(
route
.
params
);
const
handleScroll
=
async
(
event
)
=>
{
const
newIndex
=
Math
.
round
(
event
.
nativeEvent
.
contentOffset
.
x
/
screenWidth
);
if
(
newIndex
!==
activeIndex
)
{
setActiveIndex
(
newIndex
);
if
(
cards
.
length
>
0
)
{
await
soundRef
.
current
.
unloadAsync
();
await
soundRef
.
current
.
loadAsync
({
uri
:
cards
[
newIndex
].
audio
});
await
soundRef
.
current
.
playAsync
();
}
}
};
const
handleAudioPress
=
async
()
=>
{
if
(
cards
.
length
>
0
)
{
await
soundRef
.
current
.
unloadAsync
();
await
soundRef
.
current
.
loadAsync
({
uri
:
cards
[
activeIndex
].
audio
});
await
soundRef
.
current
.
playAsync
();
}
};
const
images
=
[
{
image
:
require
(
'
./assets/CG/content/vegetable.png
'
),
audio
:
require
(
'
./assets/CG/content/vegetable.m4a
'
)
},
...
...
App/Frontend/screens/SpeechTherapyScreen.js
View file @
b5c46f5d
...
...
@@ -66,6 +66,7 @@ const SpeechTherapyScreen = ({ navigation }) => {
};
},
[]);
const
updatePlaybackStatus
=
(
status
)
=>
{
if
(
status
.
isLoaded
)
{
setProgress
(
status
.
positionMillis
/
status
.
durationMillis
);
...
...
App/Frontend/screens/WordGenerationScreen.js
View file @
b5c46f5d
...
...
@@ -12,13 +12,13 @@ import {
import
{
Audio
}
from
"
expo-av
"
;
import
{
MaterialIcons
}
from
'
@expo/vector-icons
'
;
import
{
Ionicons
}
from
'
@expo/vector-icons
'
;
import
FlipCardGame
from
"
./FlipCardGameScreen
"
;
const
screenWidth
=
Dimensions
.
get
(
"
window
"
).
width
;
const
screenHeight
=
Dimensions
.
get
(
"
window
"
).
height
;
const
fetchCards
=
async
()
=>
{
try
{
console
.
log
(
"
fetch cards 1
"
)
const
response
=
await
fetch
(
'
http://192.168.216.111:5000/api/similar-words?word=school
'
);
const
data
=
await
response
.
json
();
console
.
log
(
data
)
...
...
@@ -28,11 +28,13 @@ const fetchCards = async () => {
}
};
export
default
function
ContentGenerationScreen
({
navigation
})
{
const
[
activeIndex
,
setActiveIndex
]
=
useState
(
0
);
const
[
cards
,
setCards
]
=
useState
([]);
const
scrollViewRef
=
useRef
(
null
);
const
soundRef
=
useRef
(
new
Audio
.
Sound
());
console
.
log
(
cards
);
useEffect
(()
=>
{
const
loadCards
=
async
()
=>
{
...
...
@@ -64,6 +66,7 @@ export default function ContentGenerationScreen({ navigation }) {
await
soundRef
.
current
.
unloadAsync
();
await
soundRef
.
current
.
loadAsync
({
uri
:
cards
[
newIndex
].
audio
});
await
soundRef
.
current
.
playAsync
();
//console.log('Cards before navigating:', cards);
}
};
...
...
@@ -71,6 +74,7 @@ export default function ContentGenerationScreen({ navigation }) {
await
soundRef
.
current
.
unloadAsync
();
await
soundRef
.
current
.
loadAsync
({
uri
:
cards
[
activeIndex
].
audio
});
await
soundRef
.
current
.
playAsync
();
//console.log('Cards before navigating:', cards);
};
return
(
...
...
@@ -108,7 +112,7 @@ export default function ContentGenerationScreen({ navigation }) {
{
index
===
cards
.
length
-
1
&&
(
<
TouchableOpacity
onPress
=
{()
=>
navigation
.
navigate
(
'
FlipCardGame
'
)}
onPress
=
{()
=>
navigation
.
navigate
(
'
FlipCardGame
'
,
cards
)}
style
=
{
styles
.
nextButton
}
>
<
MaterialIcons
name
=
"
keyboard-arrow-right
"
size
=
{
65
}
color
=
"
#FFCE6D
"
/>
...
...
App/Frontend/yarn.lock
View file @
b5c46f5d
This diff is collapsed.
Click to expand it.
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