Upload 104 files
#1
by
zklmorales
- opened
- Final.ipynb +25 -13
- test.ipynb +5 -5
Final.ipynb
CHANGED
@@ -2,23 +2,35 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
-
{
|
9 |
-
"name": "stderr",
|
10 |
-
"output_type": "stream",
|
11 |
-
"text": [
|
12 |
-
"c:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
13 |
-
" from .autonotebook import tqdm as notebook_tqdm\n"
|
14 |
-
]
|
15 |
-
},
|
16 |
{
|
17 |
"name": "stdout",
|
18 |
"output_type": "stream",
|
19 |
"text": [
|
20 |
-
"
|
21 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
]
|
23 |
}
|
24 |
],
|
@@ -86,7 +98,7 @@
|
|
86 |
" 'prev2pos': prev2pos \n",
|
87 |
" }\n",
|
88 |
"\n",
|
89 |
-
"new_sentence = \"
|
90 |
"\n",
|
91 |
"tokens = nltk.word_tokenize(new_sentence)\n",
|
92 |
"\n",
|
@@ -114,7 +126,7 @@
|
|
114 |
"predicted_class = torch.argmax(outputs_cls.logits, dim=1).item()\n",
|
115 |
"\n",
|
116 |
"# Check if the sentence is grammatically correct\n",
|
117 |
-
"if predicted_class == 1
|
118 |
" print(\"The sentence is grammatically correct.\")\n",
|
119 |
"else:\n",
|
120 |
" # Proceed with grammar correction candidates\n",
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 14,
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
{
|
9 |
"name": "stdout",
|
10 |
"output_type": "stream",
|
11 |
"text": [
|
12 |
+
"Grammar correction candidates:\n",
|
13 |
+
"Candidate: Siya ay nagising kanina .\n",
|
14 |
+
"Probability: 0.9917004704475403\n",
|
15 |
+
"Cosine Similarity: 0.18928596377372742\n",
|
16 |
+
"\n",
|
17 |
+
"Candidate: Siya ay dumating kanina .\n",
|
18 |
+
"Probability: 0.9892023205757141\n",
|
19 |
+
"Cosine Similarity: 0.002990148961544037\n",
|
20 |
+
"\n",
|
21 |
+
"Candidate: Siya ay namatay kanina .\n",
|
22 |
+
"Probability: 0.9889046549797058\n",
|
23 |
+
"Cosine Similarity: -0.04294966533780098\n",
|
24 |
+
"\n",
|
25 |
+
"Candidate: Siya ay nagbitiw kanina .\n",
|
26 |
+
"Probability: 0.9842618703842163\n",
|
27 |
+
"Cosine Similarity: -0.029277324676513672\n",
|
28 |
+
"\n",
|
29 |
+
"Candidate: Siya ay nahuli kanina .\n",
|
30 |
+
"Probability: 0.9830281734466553\n",
|
31 |
+
"Cosine Similarity: -0.02716892771422863\n",
|
32 |
+
"\n",
|
33 |
+
"Original sentence POS Tags: ['PRS', 'LM', 'VBTF', 'RBW', 'PMP']\n"
|
34 |
]
|
35 |
}
|
36 |
],
|
|
|
98 |
" 'prev2pos': prev2pos \n",
|
99 |
" }\n",
|
100 |
"\n",
|
101 |
+
"new_sentence = \"Siya ay magigising kanina.\"\n",
|
102 |
"\n",
|
103 |
"tokens = nltk.word_tokenize(new_sentence)\n",
|
104 |
"\n",
|
|
|
126 |
"predicted_class = torch.argmax(outputs_cls.logits, dim=1).item()\n",
|
127 |
"\n",
|
128 |
"# Check if the sentence is grammatically correct\n",
|
129 |
+
"if predicted_class == 1: # Assuming class 0 represents grammatical correctness\n",
|
130 |
" print(\"The sentence is grammatically correct.\")\n",
|
131 |
"else:\n",
|
132 |
" # Proceed with grammar correction candidates\n",
|
test.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
{
|
@@ -96,7 +96,7 @@
|
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
-
"execution_count":
|
100 |
"metadata": {},
|
101 |
"outputs": [
|
102 |
{
|
@@ -104,7 +104,7 @@
|
|
104 |
"output_type": "stream",
|
105 |
"text": [
|
106 |
"Sentence is grammatically wrong.\n",
|
107 |
-
"Probabilities: [0.
|
108 |
]
|
109 |
}
|
110 |
],
|
@@ -115,7 +115,7 @@
|
|
115 |
"tokenizer = AutoTokenizer.from_pretrained(\"zklmorales/bert_finetuned\")\n",
|
116 |
"model = AutoModelForSequenceClassification.from_pretrained(\"zklmorales/bert_finetuned\")\n",
|
117 |
"\n",
|
118 |
-
"new_sentence = \"Siya ay
|
119 |
"\n",
|
120 |
"# Tokenize the input text\n",
|
121 |
"inputs = tokenizer(new_sentence, return_tensors=\"pt\")\n",
|
@@ -141,7 +141,7 @@
|
|
141 |
},
|
142 |
{
|
143 |
"cell_type": "code",
|
144 |
-
"execution_count":
|
145 |
"metadata": {},
|
146 |
"outputs": [
|
147 |
{
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
{
|
|
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": 11,
|
100 |
"metadata": {},
|
101 |
"outputs": [
|
102 |
{
|
|
|
104 |
"output_type": "stream",
|
105 |
"text": [
|
106 |
"Sentence is grammatically wrong.\n",
|
107 |
+
"Probabilities: [0.9901305437088013, 0.009869435802102089]\n"
|
108 |
]
|
109 |
}
|
110 |
],
|
|
|
115 |
"tokenizer = AutoTokenizer.from_pretrained(\"zklmorales/bert_finetuned\")\n",
|
116 |
"model = AutoModelForSequenceClassification.from_pretrained(\"zklmorales/bert_finetuned\")\n",
|
117 |
"\n",
|
118 |
+
"new_sentence = \"Siya ay magigising kanina.\"\n",
|
119 |
"\n",
|
120 |
"# Tokenize the input text\n",
|
121 |
"inputs = tokenizer(new_sentence, return_tensors=\"pt\")\n",
|
|
|
141 |
},
|
142 |
{
|
143 |
"cell_type": "code",
|
144 |
+
"execution_count": null,
|
145 |
"metadata": {},
|
146 |
"outputs": [
|
147 |
{
|