2015-FSE-Suggesting accurate method and class names(7)

2020-12-24 16:46

Figure3:A2Dnon-linearprojection,usingt-SNE[51],ofembeddingsofmethodnamesappearinginmethoddeclarationsintheelasticsearchproject.Similarmethodshavebeengroupedtogether,eventhoughthemodelhasnonotionofthetextualsimilarityofthemethodnames,forexample,theassert-likemethodsontheleftorthenewarraymethodsontheright.betweennearbypoints,orminimizingthedistancebetweeneachpointanditsimageinthe2Dspace.Classicaltechniquesfordimen-sionalityreductionincludeprincipalcomponentsanalysis(PCA)andmultidimensionalscaling.Wewillalsoemployamoremodernmethodcalledt-SNE[51].

Figure3displaysthevectorsassignedtoafewmethodnamesfromatypicalproject(elasticsearch).Eachpointrepresentstheqvectoroftheindicatedtoken.Tointerpretthis,recallthatthemodelusestheqtvectorstopredictwhethertokentwilloccurinparticularcontext.Therefore,tokenstandt withsimilarvectorsqandqtt aretokensthatthemodelexpectstooccurinsimilarcontexts.Theseembeddingsweregeneratedfromthelogbilinearcontextmodel—thatis,withoutusingsubtokens—sothemodelhasnoinformationaboutwhichtokensaretextuallysimilar.Rather,theonlyinformationthatthemodelcanexploitisthecontextsinwhichthetokensareused.Despitethis,wenoticethatmanyofthenameswhicharegroupedtogetherseemtohavesimilarfunctions.Forexample,thereisagroupofassertXXXXmethodsonthelefthandside.Especiallystrikingistheclumpofconstructionmethodsontheright-handsidenewDoubleArray,newIntArray,newLongArray,andsoon.Itisalsotellingthatnearthisclump,thenamesgrowandresizearealsoclosetogether.Analysisrevealsthatthesenamesdoindeedseemtonamemethodsofdifferentclassesthatseemtohavesimilarfunctionality.Ourpreviouswork[2]indicatesthatdevelopersoftenprefersuchentitiestohaveconsistentnames.AdditionallyweexaminethenearestneighborsoftokensintheD-dimensionalspace.Thistypeofanalysisavoidstherisk,inherentinanydimensionalityreductionmethod,thatimportantinformationislostintheprojectionfromDdimensionsto2D.Table2showssomeidenti ersonadifferentproject,clojure,foreachidenti ergivingalistofotheridenti ersthatarenearestinthecontinuousspace.Thenearestneighborsofatokentarethosetokensvsuchthattheinnerproductoftheembeddings,thatis,qt qv,ismaximized.Wechoosethismeasurebecauseitmostcloselymatchesthenotionofsimilarityinthemodel.Again,weareusingthelogbilinearcontextmodelwithoutsubtokeninformation.WeagainseethatthenearestneighborsinthecontinuousspaceseemtohavesimilarsemanticfunctionsuchasthetriplefieldName,methodName,andclassNameorthenamesreturnType,typ,andtype.

Table3takesthisanalysisabitfurtherforthesubtokenmodel.Thistableshowsthe“nearestnearestneighbors”:thosepairsoftokensorsubtokensthatareclosestintheembeddingspaceoutofallpossiblepairsoftokens.Ontheleftcolumn,weseepairsofcloseneighborsfromthefeature-basedbilinearcontextmodelwithoutsubtokens.Thesecontainmanysimilarpairs,suchaswidthandheight.Itisstrikinghowmanyofthesepairscontainsimi-larsubtokenseventhoughthismodeldoesnotcontainsubtokens.Movingtothesubtokenmodel,therightcolumnofTable3showspairsofsubtokensthatareclosestintheembeddingspace.Themodellearnsthatpairslikenumerals,MinandMax,andHeight

andWidthshouldbeplacedneartoeachotherinthecontinuousspace.Thisisfurtherevidencethatthemodelislearningsemanticsimilaritiesgivenonlystatisticalrelationshipsbetweentokens.Wecanalsoattempttobeabitmorespeci cinouranalysis.InthisweareinspiredbyMikolovetal.[35],whonoticedthataddingtogethertwooftheirembeddingsofnaturallanguagewordsoftenyieldedacompositionalsemantics—e.g.embedding(“Paris”)-em-bedding(“France”)+embedding(“Vietnam”)yieldedavectorwhosenearestneighborwastheembeddingof“Hanoi”.Toattemptsome-thingsimilarforsourcecode,weconsidersemanticrelationshipsthatpairsofidenti ershavewitheachother.

ForFigures4and5,weprojecttheD-dimensionalembeddingsto2DusingPCAratherthant-SNE.Althoughatechnicalpoint,thisisimportant.Unliket-SNE,PCAisalinearmethod,thatis,themappingbetweentheD-dimensionalpointsandthe2Dpointsislinear.Therefore,ifgroupsofpointsareseparatedbyaplaneinthe2Dspace,thenweknowthattheyareseparatedbyaplaneinthehigher-dimensionalspaceaswell.Figure4showstheembeddingsofallpairsofsetterandgettermethodsfortheprojectnetty.Thesubtokenmodeldidnotgeneratethesemodels,sothemodelcannotclusterthesetokensbasedontextualsimilarity.Nevertheless,we ndthatgetterandsettertokensarereasonablywellseparatedinthecontinuousspace,becausetheyareusedinsimilarcontexts.InFigure5,wematchpairsofvariablenamesinthelibgdxprojectinwhichonename(the“pluralname”)equalsanothername(the“singularname”)plusthecharacters.TheJavaconventionthatCollectionobjectsareoftennamedbypluralvariablenamesmotivatesthischoice.Althoughthismappingismorenoisythanthelast,westillseethatpluralnamestendtoappearontheleftsideofthe gure,andsingularnamesontheright.

Fromthisexplorationweconcludethatthecontinuouslocationsofeachnameseemtobecapturingsemanticregularities.Readerswhowishtoexplorefurthercanviewtheembeddingsathttp://groups.inf.ed.ac.uk/cup/naturalize/.

Eventhoughthecontinuousembeddingsarelearnedfromcon-textalone,thesevisualizationssuggestthattheseembeddingsalsocontain,tosomeextent,semanticinformationaboutwhichiden-ti ersaresimilar.Thissuggeststhatlocalandglobalcontextdoprovideinformationthatcanberepresentedandexploited,thatis,semanticallysimilarnamesareusedinsimilarcontexts.Thisisevidencepointingtowardsanaf rmativeanswertoRQ1.Itisespe-ciallystrikingthatwehaveconsistentlyfoundthatnearbytokensinthecontinuousspacetendtosharesubtokens,evenwhenthemodeldoesnotincludesubtokeninformation.TherightcolumnofTable3reinforcesthispointsinceitshowsthat,whenwedousethesubtokenmodel,nearbypairsofsubtokensinthecontinuousspaceseemtobemeaningfullyrelated.Thisprovidessomeevidenceforanaf rmativeanswertoRQ2.

Finally,itcanbeobjectedthatthistypeofanalysisisnecessarilysubjective.Whenbackedandvalidatedbyquantitativeanalysis,


2015-FSE-Suggesting accurate method and class names(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:我国四大商业银行企业文化建设的问题及对策分析

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: