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
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os; os.chdir('..')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils.get_sentence_status import complete_sentence_analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-7.7618,  7.7867]])\n",
      "P(Human):  1.7674812e-07\n",
      "P(AI):  0.9999999\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [18, 32, 30, 22, 15, 28]\n",
      "variance: 39.47222222222222\n",
      "std: 6.2826922749902545\n",
      "average length: 24.166666666666668\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 1.7674812e-07,\n",
       " 'p_ai': 0.9999999,\n",
       " 'label': 'AI written',\n",
       " 'variance': 39.47222222222222,\n",
       " 'avg_length': 24.166666666666668}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# AI\n",
    "complete_sentence_analysis('''The Flash (or simply Flash) is the name of several superheroes in the DC Comics universe. Each iteration of the character possesses superhuman speed, allowing them to move at incredible velocities, run on water, phase through solid objects, and even time travel. The most iconic Flash is Barry Allen, who first appeared in 1956 and became the Scarlet Speedster known for his distinctive red costume with a lightning bolt emblem.\n",
    "\n",
    "Barry Allen's origin story involves a lightning strike combined with a chemical accident, granting him his incredible speed powers. He adopts the superhero persona of The Flash to fight crime in Central City. His adventures often revolve around thwarting supervillains and metahuman threats, while also serving as a founding member of the Justice League.\n",
    "\n",
    "''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 7.9124, -7.3888]])\n",
      "P(Human):  0.99999976\n",
      "P(AI):  2.2633e-07\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [10, 63, 32, 30, 17, 31, 18, 31, 26, 23, 19, 41, 23, 46]\n",
      "variance: 172.3469387755102\n",
      "std: 13.128097302180167\n",
      "average length: 29.285714285714285\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.99999976,\n",
       " 'p_ai': 2.2633e-07,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 172.3469387755102,\n",
       " 'avg_length': 29.285714285714285}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human\n",
    "complete_sentence_analysis(\n",
    "    '''Virat Kohli (Hindi pronunciation: [ʋɪˈɾɑːʈ ˈkoːɦli] ⓘ; born 5 November 1988) is an Indian international cricketer and the former captain of the Indian national cricket team who plays for Royal Challengers Bangalore in the IPL and Delhi in domestic cricket. Considered to be one of the best cricketers in the world, he is widely regarded as one of the greatest batsmen in the history of the sport.[4] Nicknamed \"The King\", due to his dominant style of play and popularity, Kohli holds numerous records in his career across all formats. In 2020, the International Cricket Council named him the male cricketer of the decade. Kohli has also contributed to India's successes, captaining the team from 2014 to 2022, and winning the 2011 World Cup and the 2013 Champions trophy. He is among the only four Indian cricketers who have played over 500 matches for India.[5]\n",
    "\n",
    "Born and raised in New Delhi, Kohli trained at the West Delhi Cricket Academy and started his youth career with the Delhi Under-15 team. He made his international debut in 2008 and quickly became a key player in the ODI team and later made his Test debut in 2011. In 2013, Kohli reached the number one spot in the ICC rankings for ODI batsmen for the first time. During 2014 T20 World Cup, he set a record for the most runs scored in the tournament. In 2018, he achieved yet another milestone, becoming the world's top-ranked Test batsman, making him the only Indian cricketer to hold the number one spot in all three formats of the game. His form continued in 2019, when he became the first player to score 20,000 international runs in a single decade. In 2021, Kohli made the decision to step down as the captain of the Indian national team for T20Is, following the T20 World Cup and in early 2022 he stepped down as the captain of the Test team as well.'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-5.0352,  5.3024]])\n",
      "P(Human):  3.2390926e-05\n",
      "P(AI):  0.9999676\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [3, 18, 21, 28, 22, 21, 29, 15]\n",
      "variance: 58.484375\n",
      "std: 7.647507763971214\n",
      "average length: 19.625\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 3.2390926e-05,\n",
       " 'p_ai': 0.9999676,\n",
       " 'label': 'AI written',\n",
       " 'variance': 58.484375,\n",
       " 'avg_length': 19.625}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# AI\n",
    "\n",
    "complete_sentence_analysis('''Ah, spring. It's our season of hope, a time when nature stirs from its winter slumber. The days lengthen, the frost surrenders its grip, and a world once dormant reawakens. The air, once frigid and crisp, transforms, carrying the gentle fragrance of blooming flowers and fresh grass that invigorates the senses. Spring, a time of magic, sees nature's dormant forces burst forth in a vivid spectacle of colors and life.\n",
    "\n",
    "The trees, once bare, now bud, and delicate green leaves unfurl, creating a lush canopy overhead. Cherry blossoms, daffodils, and tulips paint gardens and parks with their vibrant palettes, infusing the landscape with joy. Birds, returning from their long migrations, fill the air with their''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 2.4676, -2.4876]])\n",
      "P(Human):  0.9930031\n",
      "P(AI):  0.0069969506\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [19, 20, 21, 22, 12, 19, 13, 11, 1]\n",
      "variance: 40.666666666666664\n",
      "std: 6.377042156569663\n",
      "average length: 15.333333333333334\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.9930031,\n",
       " 'p_ai': 0.0069969506,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 40.666666666666664,\n",
       " 'avg_length': 15.333333333333334}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human\n",
    "\n",
    "complete_sentence_analysis('''“She held out for hours and didn’t move until terrorists killed her execution style.”\n",
    "\n",
    "Mapal was with her boyfriend, Roey, who sustained back injuries but survived the attack. Ma’ayan revealed that Mapal and Roey had recently moved in together and were deeply in love. Witnesses recounted the horrifying assault, where Hamas gunmen stormed the concert area, firing into the crowd and taking hostages.\n",
    "\n",
    "Mapal also has a record of serving in the Israeli military. In a heartfelt Instagram post, she expressed her gratitude for the opportunity to serve her country, saying: \"One army, 72 years, 23,816 martyrs. Thank you for granting me the honor of serving my nation.\"''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-6.6072,  6.7358]])\n",
      "P(Human):  1.6040802e-06\n",
      "P(AI):  0.99999845\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [15, 8, 30, 20, 23, 18, 18, 18, 22, 17, 10, 1]\n",
      "variance: 52.55555555555555\n",
      "std: 7.249521056977182\n",
      "average length: 16.666666666666668\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 1.6040802e-06,\n",
       " 'p_ai': 0.99999845,\n",
       " 'label': 'AI written',\n",
       " 'variance': 52.55555555555555,\n",
       " 'avg_length': 16.666666666666668}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# AI\n",
    "complete_sentence_analysis('''\"She held out for hours and didn't move until terrorists stormed the building. Sarah had never experienced fear like this before. She found herself in the middle of a hostage situation, trapped in her office on the 12th floor of a skyscraper in the heart of the city. The atmosphere was thick with tension, and the sound of sirens and distant gunshots echoed through the building.\n",
    "\n",
    "Sarah had been working late, trying to meet an important deadline, when she heard the first explosion from the street below. Panic swept through the office as her colleagues rushed to the windows to see what was happening. Smoke and chaos filled the streets, and it became evident that the city was under attack.\n",
    "\n",
    "Without hesitation, Sarah locked the office door and turned off the lights, hoping to remain unnoticed. She knew she needed to stay calm and keep her wits about her if she was going to survive this ordeal. Her phone buzzed with frantic messages from friends and family, all concerned about her safety. She silenced it to avoid drawing attention to her location.\"''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-7.7786,  7.7853]])\n",
      "P(Human):  1.7406266e-07\n",
      "P(AI):  0.9999999\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [15, 8, 30, 20, 23, 18, 18, 18, 22, 17, 10, 9, 22, 20]\n",
      "variance: 33.122448979591844\n",
      "std: 5.755210593852483\n",
      "average length: 17.857142857142858\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 1.7406266e-07,\n",
       " 'p_ai': 0.9999999,\n",
       " 'label': 'AI written',\n",
       " 'variance': 33.122448979591844,\n",
       " 'avg_length': 17.857142857142858}"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# AI\n",
    "complete_sentence_analysis(\n",
    "    '''\"She held out for hours and didn't move until terrorists stormed the building. Sarah had never experienced fear like this before. She found herself in the middle of a hostage situation, trapped in her office on the 12th floor of a skyscraper in the heart of the city. The atmosphere was thick with tension, and the sound of sirens and distant gunshots echoed through the building.\n",
    "\n",
    "Sarah had been working late, trying to meet an important deadline, when she heard the first explosion from the street below. Panic swept through the office as her colleagues rushed to the windows to see what was happening. Smoke and chaos filled the streets, and it became evident that the city was under attack.\n",
    "\n",
    "Without hesitation, Sarah locked the office door and turned off the lights, hoping to remain unnoticed. She knew she needed to stay calm and keep her wits about her if she was going to survive this ordeal. Her phone buzzed with frantic messages from friends and family, all concerned about her safety. She silenced it to avoid drawing attention to her location.\n",
    "\n",
    "Hours passed, but it felt like an eternity. The terrorists had taken control of the building, and Sarah could hear their shouts and orders echoing in the stairwell. She knew she had to stay hidden until help arrived, or she could find a way to escape safely.\n",
    "\n",
    "''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-1.7889,  2.0316]])\n",
      "P(Human):  0.021448229\n",
      "P(AI):  0.9785518\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [9, 47, 18, 27, 30]\n",
      "variance: 162.16000000000003\n",
      "std: 12.734205903785286\n",
      "average length: 26.2\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.021448229,\n",
       " 'p_ai': 0.9785518,\n",
       " 'label': 'AI written',\n",
       " 'variance': 162.16000000000003,\n",
       " 'avg_length': 26.2}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human\n",
    "complete_sentence_analysis(\n",
    "    '''The buzz around artificial intelligence never seems to end. Whether these supposedly intellectual robots are playing chess, creating paintings, or threatening to steal our jobs, their proponents seem convinced that one day AI machines will be able to do everything the human mind can do, and do it even better at that. Sometimes that future seems closer than ever, but other times AI can make itself look pretty dumb. With this in mind, we asked an AI image generator to create depictions of everyday life, from the simplest objects to the biggest philosophical ideas. Hopefully no one is really relying on AI for ideas about the world, because the results that came from this AI are more than just a little off base...'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 6.7435, -6.3300]])\n",
      "P(Human):  0.99999785\n",
      "P(AI):  2.100322e-06\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [9, 47, 18, 27, 30, 23]\n",
      "variance: 136.55555555555557\n",
      "std: 11.68569876197207\n",
      "average length: 25.666666666666668\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.99999785,\n",
       " 'p_ai': 2.100322e-06,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 136.55555555555557,\n",
       " 'avg_length': 25.666666666666668}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human Written \n",
    "complete_sentence_analysis(\n",
    "    '''The buzz around artificial intelligence never seems to end. Whether these supposedly intellectual robots are playing chess, creating paintings, or threatening to steal our jobs, their proponents seem convinced that one day AI machines will be able to do everything the human mind can do, and do it even better at that. Sometimes that future seems closer than ever, but other times AI can make itself look pretty dumb. With this in mind, we asked an AI image generator to create depictions of everyday life, from the simplest objects to the biggest philosophical ideas. Hopefully no one is really relying on AI for ideas about the world, because the results that came from this AI are more than just a little off base...\n",
    "\n",
    "Curious? Click on to see the crazy ideas an AI generator has about life, from the hilarious to the harrowing.'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-7.5293,  7.5525]])\n",
      "P(Human):  2.8189612e-07\n",
      "P(AI):  0.99999976\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [25, 35, 19, 33]\n",
      "variance: 41.0\n",
      "std: 6.4031242374328485\n",
      "average length: 28.0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 2.8189612e-07,\n",
       " 'p_ai': 0.99999976,\n",
       " 'label': 'AI written',\n",
       " 'variance': 41.0,\n",
       " 'avg_length': 28.0}"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human Written \n",
    "complete_sentence_analysis(\n",
    "    '''In a world where the pressures of daily life can sometimes overwhelm us, World Mental Health Day invites us to engage in open conversations. It encourages us to break the silence surrounding mental health concerns, debunk myths, and dismantle the stigma that has, for far too long, prevented individuals from seeking the support they deserve.\n",
    "\n",
    "The theme of World Mental Health Day 2023 is 'Mental health is a universal human right.' The purpose of this theme is to improve knowledge, raise awareness, and drive actions that promote and protect everyone's mental health as a universal human right, says WHO.'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-4.2804,  4.6454]])\n",
      "P(Human):  0.00013289612\n",
      "P(AI):  0.9998671\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [41, 38, 47]\n",
      "variance: 14.0\n",
      "std: 3.7416573867739413\n",
      "average length: 42.0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.00013289612,\n",
       " 'p_ai': 0.9998671,\n",
       " 'label': 'AI written',\n",
       " 'variance': 14.0,\n",
       " 'avg_length': 42.0}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human\n",
    "complete_sentence_analysis(\n",
    "    '''Araku Valley the “Queen of Hills” is a picturesque hill station located in Andhra Pradesh, better known for its natural beauty, lush green landscapes, coffee plantations, and pleasant climate. It is situated in the Eastern Ghats mountain range and is popular with tourists, especially people seeking a peaceful getaway from nearby coastal cities like Visakhapatnam which is hot and humid.\n",
    "\n",
    "Scenic Paradise in the Eastern Ghats\n",
    "The picturesque hill station, renowned for its lush greenery, tribal heritage, and coffee plantations, beckons travelers to experience a rejuvenating escape from the hustle and bustle of urban life.'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 2.8461, -2.8003]])\n",
      "P(Human):  0.99648213\n",
      "P(AI):  0.0035178645\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [24, 39, 28, 28, 19]\n",
      "variance: 43.44\n",
      "std: 6.590902821313632\n",
      "average length: 27.6\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.99648213,\n",
       " 'p_ai': 0.0035178645,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 43.44,\n",
       " 'avg_length': 27.6}"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Human\n",
    "complete_sentence_analysis(\n",
    "    '''Ranbir Kapoor is all set to bring to your screen an action thriller film titled ‘Animal’. It has been making news for quite some time now for its stellar cast which includes names like Anil Kapoor, Rashmika Mandana, Bobby Deol, and Tripti Dimri. It is set to be directed by Sandeep Reddy Vanga who is known for films like Arjun Reddy and Kabir Singh. The makers of the film recently dropped the teaser of the film where we saw Ranbir in a very ferocious avatar, ready to draw blood. The makers are now releasing a new song from the film tomorrow, check out the poster below…'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-5.2793,  5.4920]])\n",
      "P(Human):  2.0992544e-05\n",
      "P(AI):  0.999979\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [24, 9, 5, 23]\n",
      "variance: 70.1875\n",
      "std: 8.37779804005802\n",
      "average length: 15.25\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 2.0992544e-05,\n",
       " 'p_ai': 0.999979,\n",
       " 'label': 'AI written',\n",
       " 'variance': 70.1875,\n",
       " 'avg_length': 15.25}"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "complete_sentence_analysis(\n",
    "    '''Overall, it is a wonderful destination for nature lovers, adventurers, and anyone looking to experience a serene and tranquil environment.\n",
    "\n",
    "Araku Valley attractions catering to diverse interests:\n",
    "Borra Caves: These ancient limestone caves, adorned with stunning stalactites and stalagmites, provide an enchanting underground experience.'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[-4.6586,  4.9331]])\n",
      "P(Human):  6.828416e-05\n",
      "P(AI):  0.9999317\n",
      "Label:  AI written\n",
      "POSITIVE\n",
      "arr= [27, 11, 1, 8, 23, 10, 28]\n",
      "variance: 94.53061224489797\n",
      "std: 9.722685444099175\n",
      "average length: 15.428571428571429\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 6.828416e-05,\n",
       " 'p_ai': 0.9999317,\n",
       " 'label': 'AI written',\n",
       " 'variance': 94.53061224489797,\n",
       " 'avg_length': 15.428571428571429}"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "complete_sentence_analysis(\n",
    "    '''Hinton's career in AI began as an attempt to simulate a neural network on a computer, inspired by his fascination with the human brain. However, his early endeavors faced skepticism, and his Ph.D. advisor advised him to abandon the pursuit. Nevertheless, Hinton persisted in his quest to understand the human mind, ultimately leading to the development of artificial neural networks.\n",
    "\n",
    "\"It took much, much longer than I expected. It took, like, 50 years before it worked well, but in the end, it did work well,\" Hinton reflected on the journey.'''\n",
    "\n",
    "# In 2019, Geoffrey Hinton, along with collaborators Yann Lecun and Yoshua Bengio, received the Turing Award, often described as the Nobel Prize of computing, for their pioneering work on artificial neural networks. Their innovations have played a pivotal role in enabling machines to \"learn to learn.\"\n",
    "\n",
    "# During the interview, CBS News took viewers inside Google's AI lab in London, where robots were showcased as an example of machine learning in action. Notably, these robots were not explicitly programmed to play soccer; they were instructed to score goals and had to learn the game on their own through trial and error, a testament to the power of AI.'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 8.0981, -7.5304]])\n",
      "P(Human):  0.9999999\n",
      "P(AI):  1.6315956e-07\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [14, 40, 30, 31, 15, 15, 16, 13]\n",
      "variance: 93.4375\n",
      "std: 9.666307464590602\n",
      "average length: 21.75\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.9999999,\n",
       " 'p_ai': 1.6315956e-07,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 93.4375,\n",
       " 'avg_length': 21.75}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "complete_sentence_analysis(\n",
    "    '''\n",
    "2015 was a year when I looked at this blog with some professional seriousness. All these years it has been a platform for my expression, for sharing the joys of traveling, connecting with fellow travelers and learning from them about new destinations or the new way to look at old destinations. It has been a place where I experienced magic like with the story of a Bihar boy or when unknown people wrote to me about how their lives were impacted.\n",
    "\n",
    "However, in the last couple of years, I saw a commercial interest in the blog and travel blogging emerging as a career option that many youngsters took up voluntarily. So this year, I decided to open IndiTales for commercial associations. I did a couple of small campaigns with some leading brands in the travel domain. I was invited by many tourism boards and hospitality brands to visit their destinations and properties. So, a decent beginning and hope to take it forward in 2016.\n",
    "\n",
    "''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 2.8461, -2.8003]])\n",
      "P(Human):  0.99648213\n",
      "P(AI):  0.0035178645\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [24, 39, 28, 28, 19]\n",
      "variance: 43.44\n",
      "std: 6.590902821313632\n",
      "average length: 27.6\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.99648213,\n",
       " 'p_ai': 0.0035178645,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 43.44,\n",
       " 'avg_length': 27.6}"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "complete_sentence_analysis(\n",
    "    '''Ranbir Kapoor is all set to bring to your screen an action thriller film titled ‘Animal’. It has been making news for quite some time now for its stellar cast which includes names like Anil Kapoor, Rashmika Mandana, Bobby Deol, and Tripti Dimri. It is set to be directed by Sandeep Reddy Vanga who is known for films like Arjun Reddy and Kabir Singh. The makers of the film recently dropped the teaser of the film where we saw Ranbir in a very ferocious avatar, ready to draw blood. The makers are now releasing a new song from the film tomorrow, check out the poster below…'''\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logits:  tensor([[ 8.1121, -7.5430]])\n",
      "P(Human):  0.9999999\n",
      "P(AI):  1.5887993e-07\n",
      "Label:  Human Written\n",
      "NEGATIVE\n",
      "arr= [13, 30, 37, 24, 26, 20, 24, 22]\n",
      "variance: 43.5\n",
      "std: 6.59545297913646\n",
      "average length: 24.5\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'p_human': 0.9999999,\n",
       " 'p_ai': 1.5887993e-07,\n",
       " 'label': 'Human Written',\n",
       " 'variance': 43.5,\n",
       " 'avg_length': 24.5}"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "complete_sentence_analysis(\n",
    "    # '''Data, documents, and processes may be stored across teams and tools. By linking relevant pieces of data, you can build systems that can recommend people to projects, connect related projects, or centralize access to avoid duplicate efforts. You can extract entities from text-heavy content such as emails, word documents, PDF, and spreadsheets or meta-data from video, audio, and photos to build a knowledge graph. You can augment this knowledge graph with structured data from CRM and ERP systems to get a comprehensive view about a product.'''\n",
    "'''Data, documents, and processes may be stored across teams and tools. By linking relevant pieces of data, you can build systems that can recommend people to projects, connect related projects, or centralize access to avoid duplicate efforts. You can extract entities from text-heavy content such as emails, word documents, PDF, and spreadsheets or meta-data from video, audio, and photos to build a knowledge graph. You can augment this knowledge graph with structured data from CRM and ERP systems to get a comprehensive view about a product.\n",
    "In manufacturing, you can track the different stages building and delivering a product from changes to inventory levels to store shipments using a knowledge graph. In life sciences, you can use a knowledge graph to track an experiment, trails and characteristics of drugs. In financial services, you can build a knowledge graph for the holding company of a security, the security and the beneficial holding. You can augment this graph with social media, industry events to record the relations to provide insights into dependencies between firms.'''\n",
    "\n",
    "\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/home/ubuntu'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1 \n",
    "# >3 \n",
    "\n",
    "\n",
    "import pandas as pd \n",
    "\n",
    "\n",
    "df= pd.read_csv(\n",
    "    '/home/ubuntu/SentenceStructureComparision/data/AI_checker_gpt3_remade.csv'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Syd Rapson (born Sydney Rapson, 28 April 193228 April 2017) was an English Labour Party politician who served as Member of Parliament (MP) for Portsmouth South from 1997 to 2010.',\n",
       " '',\n",
       " 'Rapson was born in Portsmouth and educated at Portsmouth Grammar School and the University of Southampton. He worked as a teacher and a lecturer before entering politics. He was a councillor on Portsmouth City Council from 1973 to 1997, and was leader of the council from 1983 to 1997.',\n",
       " '',\n",
       " 'Rapson was elected to the House of Commons at the 1997 general election, and held the seat until he stood down at the 2010 general election. He was a member of the Defence Select Committee from 1997 to 2010, and was a member of the Parliamentary Labour Party Defence Committee from 1997 to 2005. He was also a member of the Parliamentary Labour Party Home Affairs Committee from 2005 to 2010.']"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# df.head(5).values[0][0].split(\"\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Rick Mahler (born Richard Alan Mahler on April 18, 1957 in Atlanta, Georgia) was an American professional baseball pitcher who played for the Atlanta Braves, Cincinnati Reds, Montreal Expos, and Minnesota Twins of Major League Baseball (MLB) from 1978 to 1990. He was a two-time All-Star and won the National League (NL) ERA title in 1985.',\n",
       " '',\n",
       " \"Mahler was drafted by the Braves in the first round of the 1975 amateur draft. He made his major league debut with the Braves in 1978, and was a member of the team's starting rotation for the next five seasons. He was an All-Star in 1983 and 1985, and won the NL ERA title in 1985 with a 2.87 ERA. He was traded to the Reds in 1984, and then to the Expos in 1986. He was traded to the Twins in 1989, and finished his career with them in 1990.\",\n",
       " '',\n",
       " 'Mahler was known for his durability, as he pitched over 200 innings in six consecutive seasons from 1983 to 1988. He finished his career with a record of 119–121, a 3.90 ERA, and 1,07']"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# df.head(5).values[4][0].split(\"\\n\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils.get_category import  predict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Predicted Class:  Computers_and_Electronics \n",
      "probabilities_scores: 1.0\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'P(Hobbies_and_Leisure)': 0.205,\n",
       " 'P(News)': 0.003,\n",
       " 'P(Science)': 0.017,\n",
       " 'P(Autos_and_Vehicles)': 0.13,\n",
       " 'P(Health)': 0.006,\n",
       " 'P(Pets_and_Animals)': 0.005,\n",
       " 'P(Adult)': 0.063,\n",
       " 'P(Computers_and_Electronics)': 1.0,\n",
       " 'P(Online Communities)': 0.109,\n",
       " 'P(Beauty_and_Fitness)': 0.012,\n",
       " 'P(People_and_Society)': 0.0,\n",
       " 'P(Business_and_Industrial)': 0.003,\n",
       " 'P(Reference)': 0.024,\n",
       " 'P(Shopping)': 0.263,\n",
       " 'P(Travel_and_Transportation)': 0.004,\n",
       " 'P(Food_and_Drink)': 0.018,\n",
       " 'P(Law_and_Government)': 0.082,\n",
       " 'P(Books_and_Literature)': 0.006,\n",
       " 'P(Finance)': 0.039,\n",
       " 'P(Games)': 0.05,\n",
       " 'P(Home_and_Garden)': 0.024,\n",
       " 'P(Jobs_and_Education)': 0.003,\n",
       " 'P(Arts_and_Entertainment)': 0.008,\n",
       " 'P(Sensitive Subjects)': 0.002,\n",
       " 'P(Real Estate)': 0.027,\n",
       " 'P(Internet_and_Telecom)': 0.011,\n",
       " 'P(Sports)': 0.013,\n",
       " 'Predicted Label': 'Computers_and_Electronics'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "predict(\"best cat ear headphones\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}