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
91b11052
Commit
91b11052
authored
Apr 12, 2023
by
Lelkada L L P S M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
word filtration script - retrieve word sensitivity score
parent
006ec3e0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
IT19001708/STG/script/word_filtration.ipynb
IT19001708/STG/script/word_filtration.ipynb
+59
-0
No files found.
IT19001708/STG/script/word_filtration.ipynb
View file @
91b11052
...
...
@@ -869,6 +869,65 @@
" document = {\"word\": row[\"word\"], \"score\": row[\"offensive_scale\"]}\n",
" result = collection.insert_one(document)"
]
},
{
"cell_type": "markdown",
"id": "aafbf51b-ff3b-49c7-952f-902ee628861c",
"metadata": {},
"source": [
"#### Retrieve score"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "3cd54b06-c132-45ba-9602-1a5ceee220fa",
"metadata": {},
"outputs": [],
"source": [
"def get_sensitivity_score(word):\n",
" client = pymongo.MongoClient(\"mongodb+srv://hearme:hearme678@cluster0.kz66vdr.mongodb.net/\")\n",
"\n",
" # select the database and collection\n",
" db = client[\"word_filtration\"]\n",
" collection = db[\"sensitivity_score\"]\n",
" \n",
" # find the word in the collection and return its sensitivity score\n",
" result = collection.find_one({\"word\": word})\n",
" if result:\n",
" return result[\"score\"]\n",
" else:\n",
" return -99"
]
},
{
"cell_type": "code",
"execution_count": 58,
"id": "6f05439f-5fc6-4de0-9420-7117a9608cde",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.65"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_sensitivity_score('play')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "636445cc-48c8-4b01-a3a7-920b4bec76b5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
...
...
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