<<JLink`;
InstallJava[];
ReinstallJava[JVMArguments->"-Xmx32000m"]

Needs["DatabaseLink`"]

conn=OpenSQLConnection[]

SQLTables[conn]

SQLColumns[conn,"May2015"]

UnixTime[{2015,5,19,2,46,0}] (*Mercury Retrograde Starts*)

NMR=SQLSelect[ conn,"May2015",{"created_utc","body"},SQLColumn["created_utc"]<1432003560]

Export["NMR_reddit.dat",NMR]

Length[NMR]

selectionsNMR=RandomInteger[{1,Length[NMR]},1000000];

Length[selectionsNMR]

ClearAll[a,i,j,misspell];
(*timeNMR={};*)
text={};
fractionNMR={};
text={};
textwords={};
stringslist={};
For[a=1,a≤(*10*)Length[selectionsNMR],a++, (*a is the entry number*)
misspell=0;
text=NMR[[selectionsNMR[[a]]]][[2]];
(*CHECK FOR ENGLISH*)
If [LanguageIdentify[text]==Entity["Language","English"],
text=StringReplace[text,"1"->""];
text=StringReplace[text,"2"->""];
text=StringReplace[text,"3"->""];
text=StringReplace[text,"4"->""];
text=StringReplace[text,"5"->""];
text=StringReplace[text,"6"->""];
text=StringReplace[text,"7"->""];
text=StringReplace[text,"8"->""];
text=StringReplace[text,"9"->""];
text=StringReplace[text,"0"->""];
text=StringReplace[text,"'s"->""];
text=StringReplace[text,"\\n"->" "];
textwords=TextWords[text];
For [j=1,j<=Length[textwords],j++, (*j is the particular word*)
wordstring=ToString[textwords[[j]]];
If [Not[SubsetQ[Characters[wordstring],{"."}]],(*checks for link*)
If[DictionaryLookup[wordstring,IgnoreCase->True]≠{},
If [StringDrop[DictionaryLookup[wordstring,IgnoreCase->True],1][[1]]≠StringDrop[ToString[textwords[[j]]],1],misspell=misspell+1],misspell=misspell+1]
];(* gets rid of capitalization and checks for spelling*)
];
If [Length[textwords]≠0&&N[misspell/Length[textwords]]≠1,
AppendTo[fractionNMR,N[misspell/Length[textwords]]]];
(*AppendTo[timeNMR,NMR[[a]][[1]]];*)
];
];

Export["fractionNMR.csv",fractionNMR]

MR=SQLSelect[ conn,"May2015",{"created_utc","body"},SQLColumn["created_utc"]>=1432003560];

Export["MR_reddit.dat",MR]

Length[MR]

N[(1000000/Length[NMR])*Length[MR]]

selectionsMR=RandomInteger[{1,Length[MR]},Round[N[(1000000/Length[NMR])*Length[MR]]]];

Length[selectionsMR]

ClearAll[a,i,j,misspell];
(*timeNMR={};*)
text={};
fractionMR={};
text={};
textwords={};
stringslist={};
For[a=1,a≤(*10*)Length[selectionsMR],a++, (*a is the entry number*)
misspell=0;
text=MR[[selectionsMR[[a]]]][[2]];
(*CHECK FOR ENGLISH*)
If [LanguageIdentify[text]==Entity["Language","English"],
text=StringReplace[text,"1"->""];
text=StringReplace[text,"2"->""];
text=StringReplace[text,"3"->""];
text=StringReplace[text,"4"->""];
text=StringReplace[text,"5"->""];
text=StringReplace[text,"6"->""];
text=StringReplace[text,"7"->""];
text=StringReplace[text,"8"->""];
text=StringReplace[text,"9"->""];
text=StringReplace[text,"0"->""];
text=StringReplace[text,"'s"->""];
text=StringReplace[text,"\\n"->" "];
textwords=TextWords[text];
For [j=1,j<=Length[textwords],j++, (*j is the particular word*)
wordstring=ToString[textwords[[j]]];
If [Not[SubsetQ[Characters[wordstring],{"."}]],(*checks for link*)
If[DictionaryLookup[wordstring,IgnoreCase->True]≠{},
If [StringDrop[DictionaryLookup[wordstring,IgnoreCase->True],1][[1]]≠StringDrop[ToString[textwords[[j]]],1],misspell=misspell+1],misspell=misspell+1]
];(* gets rid of capitalization and checks for spelling*)
];
If [Length[textwords]≠0&&N[misspell/Length[textwords]]≠1,
AppendTo[fractionMR,N[misspell/Length[textwords]]]];
(*AppendTo[timeNMR,NMR[[a]][[1]]];*)
];
];

Export["fractionMR.csv",fractionMR]

BoxWhiskerChart[{fractionNMR,fractionMR},ChartLegends->{"Not Mercury Retrograde","Mercury Retrograde"},(*{"Basic",{"Whiskers",Dashed},{"MeanDiamond",0.5,Gray}},*)ChartStyle->14,ChartElementFunction->"GlassBoxWhisker"]

Needs["HypothesisTesting`"]

Mean[fractionNMR]

Variance[fractionNMR]

MeanCI[fractionNMR]

VarianceCI[fractionNMR]

Mean[fractionMR]

MeanCI[fractionMR]

VarianceCI[fractionMR]

MeanCI[fractionMR]/MeanCI[fractionNMR]

Length[fractionNMR]

Length[fractionMR]

Export["fractionMR.csv",fractionMR];

Export["reddit_MR.dat",MR];

Histogram[{fractionNMR,fractionMR},ChartLegends->{"Not Mercury Retrograde","Mercury Retrograde"}]

PairedHistogram[fractionNMR,fractionMR,ChartStyle->14, ChartLegends->{"Not Mercury Retrograde","Mercury Retrograde"}]

{QuantilePlot[fractionNMR,fractionMR],ProbabilityPlot[{fractionNMR,fractionMR}]}

DistributionChart[{fractionNMR,fractionMR}]

BoxWhiskerChart[fractionNMR,(*{"Basic",{"Whiskers",Dashed},{"MeanDiamond",0.5,Gray}},*)ChartStyle->14,ChartElementFunction->"GlassBoxWhisker"]

Length[fractionNMR]

Histogram[fractionNMR]

Mean[fractionMR]

Variance[fractionMR]

MeanCI[fractionMR]

VarianceCI[fractionMR]

N[Length[NMR]/18]

N[1000000/Length[NMR]]

a

Length[fractionMR]

Histogram[fractionMR]

Mean[fractionMR]/Mean[fractionNMR]

Variance[fractionMR]/Variance[fractionNMR]

MeanCI[fractionMR]

LocationEquivalenceTest[{fractionMR,fractionNMR},{"TestDataTable",All}]

VarianceEquivalenceTest[{fractionMR,fractionNMR},{"TestDataTable",All}]