guxd / deep-code-search

DeepCS: Deep Code Search

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

High similarity, but results are irrelevant

isHuangXin opened this issue · comments

您好!
我使用的是Pytorch版本, 训练数据集使用的是您提供的 train.methname.h5 ;train.apiseq.h5;train.tokens.h5;train.desc.h5. 模型训练时将batch_size由64改为了256, 训练15个epoch, 这是第15个epoch的验证结果{'acc': 0.3899, 'mrr': 0.3899, 'map': 0.3899, 'ndcg': 0.3899}. 当我把训练好的模型在 use.rawcode.txt去做Benchmark Queries and Evaluation Results时, 第一列为code的id, 第二列为相似度, 第三列为rawcode. 由结果可以看到, 搜索到的代码相似度均为0.7~0.85 , 但人工去看代码的时候, 发现query与搜到的代码并不相关. 比较疑惑, 希望能得到解答, 谢谢.

Index: 0, Query id: 309424, Query: convert an inputstream to a string
Input query: convert an inputstream to a string
ACC: 0.0
(1137324, 0.7534389, 'public void visitAnyRefConstant ( Clazz clazz , RefConstant refConstant ) { Member referencedMember = refConstant . referencedMember ; if ( referencedMember != null ) { Clazz referencedClass = refConstant . referencedClass ; name = referencedMember . getName ( referencedClass ) ; type = referencedMember . getDescriptor ( referencedClass ) ; clazz . constantPoolEntryAccept ( refConstant . u2nameAndTypeIndex , this ) ; } } \n')
(562144, 0.72865224, 'public void validate ( ) throws ValidationException { final Map < String , Integer > foreignSourceCounts = new HashMap < String , Integer > ( ) ; final Set < String > errors = new HashSet < String > ( ) ; for ( final RequisitionNode node : m_nodes ) { final String foreignId = node . getForeignId ( ) ; Integer count = foreignSourceCounts . get ( foreignId ) ; foreignSourceCounts . put ( foreignId , count == null ? 1 : ++ count ) ; } for ( final Entry < String , Integer > entry : foreignSourceCounts . entrySet ( ) ) { final String foreignId = entry . getKey ( ) ; final Integer count = entry . getValue ( ) ; if ( count > 1 ) { errors . add ( foreignId + "-(" + count + "-found)" ) ; } } if ( errors . size ( ) > 0 ) { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Duplicate-nodes-found-on-foreign-source-" ) . append ( getForeignSource ( ) ) . append ( ":-" ) ; final Iterator < String > it = errors . iterator ( ) ; while ( it . hasNext ( ) ) { final String error = it . next ( ) ; sb . append ( error ) ; if ( it . hasNext ( ) ) { sb . append ( ",-" ) ; } } throw new ValidationException ( sb . toString ( ) ) ; } } \n')
(1075092, 0.7648308, 'public void translate ( double x , double y ) { _rect . setFrame ( _rect . getX ( ) + x , _rect . getY ( ) + y , _rect . getWidth ( ) , _rect . getHeight ( ) ) ; } \n')
(36258, 0.7908337, 'public void test ( TestHarness harness ) { Object o = new ClassCastException ( "ClassCastException" ) ; Class c = o . getClass ( ) ; int modifiers = c . getModifiers ( ) ; harness . check ( Modifier . isPublic ( modifiers ) ) ; harness . check ( ! Modifier . isPrivate ( modifiers ) ) ; harness . check ( ! Modifier . isProtected ( modifiers ) ) ; harness . check ( ! Modifier . isAbstract ( modifiers ) ) ; harness . check ( ! Modifier . isFinal ( modifiers ) ) ; harness . check ( ! Modifier . isInterface ( modifiers ) ) ; harness . check ( ! Modifier . isNative ( modifiers ) ) ; harness . check ( ! Modifier . isStatic ( modifiers ) ) ; harness . check ( ! Modifier . isStrict ( modifiers ) ) ; harness . check ( ! Modifier . isSynchronized ( modifiers ) ) ; harness . check ( ! Modifier . isTransient ( modifiers ) ) ; harness . check ( ! Modifier . isVolatile ( modifiers ) ) ; } \n')
(1962221, 0.7146248, 'public void setVerbosity ( int verbosity ) { this . verbosity = new Integer ( verbosity ) ; debug . setDebug ( verbosity ) ; } \n')
(1378124, 0.7146248, 'public void setPopupVisible ( JComboBox a , boolean b ) { for ( int i = 0 ; i < uis . size ( ) ; i ++ ) { ( ( ComboBoxUI ) ( uis . elementAt ( i ) ) ) . setPopupVisible ( a , b ) ; } } \n')
(1384466, 0.74686414, 'public void setIndex ( int index ) { if ( index > worms . size ( ) - 1 ) this . index = 0 ; else this . index = index ; } \n')
(44930, 0.74686414, 'public void recordSpans ( String field , int spanTotal , Span [ ] spans , Set terms ) { entries . put ( field , new Entry ( spanTotal , spans , terms ) ) ; } \n')
(129640, 0.72403747, 'public void preInvoke ( ) { if ( source != null && destination != null ) { if ( source . contains ( "*" ) ) { this . srcFiles = glob ( source ) ; } else if ( source . endsWith ( File . separator ) ) { this . srcFiles = expand ( new File ( source ) ) ; } else { this . srcFiles = new LinkedList < File > ( ) ; srcFiles . add ( new File ( source ) ) ; } } else { log . error ( "source-or-destination-not-set" ) ; } } \n')
(816109, 0.78389436, 'public void play ( ) { audioClip . play ( ) ; } \n')
================================================================================

Index: 1, Query id: 157944, Query: create arraylist from array
Input query: create arraylist from array
ACC: 0.0
(1927319, 0.8150367, 'public void testGradientPaintSerialization ( ) { final Paint p1 = new GradientPaint ( 0.0f , 0.0f , Color . blue , 100.0f , 200.0f , Color . red ) ; Paint p2 = null ; try { final ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; final ObjectOutputStream out = new ObjectOutputStream ( buffer ) ; SerialUtilities . writePaint ( p1 , out ) ; out . close ( ) ; final ByteArrayInputStream bias = new ByteArrayInputStream ( buffer . toByteArray ( ) ) ; final ObjectInputStream in = new ObjectInputStream ( bias ) ; p2 = SerialUtilities . readPaint ( in ) ; in . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } final GradientPaint gp1 = ( GradientPaint ) p1 ; final GradientPaint gp2 = ( GradientPaint ) p2 ; assertEquals ( gp1 . getColor1 ( ) , gp2 . getColor1 ( ) ) ; assertEquals ( gp1 . getPoint1 ( ) , gp2 . getPoint1 ( ) ) ; assertEquals ( gp1 . getColor2 ( ) , gp2 . getColor2 ( ) ) ; assertEquals ( gp1 . getPoint2 ( ) , gp2 . getPoint2 ( ) ) ; assertEquals ( gp1 . isCyclic ( ) , gp2 . isCyclic ( ) ) ; } \n')
(1191131, 0.7973476, 'public void setString ( String args ) { ArrayList list = new ArrayList ( ) ; StringTokenizer tok = new StringTokenizer ( args ) ; while ( tok . hasMoreTokens ( ) ) { list . add ( tok . nextToken ( ) ) ; } setStringArray ( ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) ) ; } \n')
(1172592, 0.79656774, 'public void setShowingPopups ( boolean pop ) { _checkbox . setSelected ( pop ) ; } \n')
(161313, 0.8150367, 'public void setRegion ( String region ) { synchronized ( objectSyncronized ) { this . region = region ; objectSyncronized . notifyAll ( ) ; } } \n')
(613968, 0.8157154, 'public void setRecurring ( boolean recurring ) { set ( TaskField . RECURRING , recurring ) ; } \n')
(757843, 0.79293704, 'public void setMobilePhone ( String mobilePhone ) { this . mobilePhone = mobilePhone == null ? null : mobilePhone . trim ( ) ; } \n')
(1906149, 0.8250349, 'public void setConnectTimeout ( int duration , TimeUnit unit ) { this . connectTimeout = unit . toMillis ( duration ) ; } \n')
(252256, 0.79360694, 'public void setAutoHideOrder ( String sTableID , String [ ] autoHideOrderColumnIDs ) { ArrayList autoHideOrderList = new ArrayList ( autoHideOrderColumnIDs . length ) ; for ( int i = 0 ; i < autoHideOrderColumnIDs . length ; i ++ ) { String sColumnID = autoHideOrderColumnIDs [ i ] ; TableColumnCore column = getTableColumnCore ( sTableID , sColumnID ) ; if ( column != null ) { autoHideOrderList . add ( column ) ; } } autoHideOrder . put ( sTableID , autoHideOrderList ) ; } \n')
(557199, 0.81849706, 'public void setAntialiasedgraphics ( boolean b ) { mAntiAliasedGraphics = new Boolean ( b ) ; } \n')
(642405, 0.79988897, 'public void reschedule ( long delay , TimeUnit unit ) { boolean needQueue = true ; SingletonTaskWorker stw = null ; synchronized ( context ) { if ( context . taskRunning || context . taskShouldRun ) { if ( context . taskRunning ) { if ( delay > 0 ) { long now = System . nanoTime ( ) ; long then = now + TimeUnit . NANOSECONDS . convert ( delay , unit ) ; context . waitingTask . nextschedule = then ; } else { context . waitingTask . nextschedule = 0 ; } needQueue = false ; } else { context . waitingTask . canceled = true ; context . waitingTask = null ; } } context . taskShouldRun = true ; if ( needQueue ) { stw = context . waitingTask = new SingletonTaskWorker ( this ) ; } } if ( needQueue ) { if ( delay <= 0 ) ses . execute ( stw ) ; else ses . schedule ( stw , delay , unit ) ; } } \n')
================================================================================

Index: 2, Query id: 1066589, Query: iterate through a hashmap
Input query: iterate through a hashmap
ACC: 0.0
(194552, 0.73917794, 'static void flush ( ) { s_instances . clear ( ) ; } \n')
(1651776, 0.7778784, 'public void setPauseWork ( boolean pauseWork ) { synchronized ( mPauseWorkLock ) { mPauseWork = pauseWork ; if ( ! mPauseWork ) { mPauseWorkLock . notifyAll ( ) ; } } } \n')
(1542333, 0.742901, 'public void setLockDir ( File lockDir ) throws IOException { this . lockDir = lockDir ; if ( lockDir != null ) { if ( ! lockDir . exists ( ) ) { if ( ! lockDir . mkdirs ( ) ) throw new IOException ( "Cannot-create-directory:-" + lockDir . getAbsolutePath ( ) ) ; } else if ( ! lockDir . isDirectory ( ) ) { throw new IOException ( "Found-regular-file-where-directory-expected:-" + lockDir . getAbsolutePath ( ) ) ; } acquireTestLock ( ) ; } } \n')
(203504, 0.7890821, 'public void setLineStyle ( int style ) { if ( lineAttributes . style != style ) { lineAttributes . style = style ; lineStyle = style ; lastLineStyle = style ; repaint ( ) ; } } \n')
(839915, 0.75269914, 'public void setClasspathList ( List < String > l ) { this . classpath = new LinkedList < String > ( l ) ; } \n')
(1529190, 0.7439212, 'public void putString ( String s , int len ) { byte [ ] b = s . getBytes ( ) ; dataBuffer . put ( b , 0 , Math . min ( len , b . length ) ) ; for ( int i = b . length ; i < len ; i ++ ) dataBuffer . put ( ( byte ) 0 ) ; } \n')
(150815, 0.72491604, 'public void put ( E e ) throws InterruptedException { putLast ( e ) ; } \n')
(60698, 0.75269914, 'public void print ( String value , boolean checkForEscape ) throws IOException { if ( ! checkForEscape ) { printSep ( ) ; out . write ( value ) ; return ; } if ( buf . length < value . length ( ) ) { buf = new char [ value . length ( ) ] ; } value . getChars ( 0 , value . length ( ) , buf , 0 ) ; print ( buf , 0 , value . length ( ) , checkForEscape ) ; } \n')
(1303158, 0.7510628, 'public void onLoadFinished ( Loader < Cursor > loader , Cursor data ) { if ( data . moveToFirst ( ) ) { final String name = data . getString ( data . getColumnIndex ( PlaceDetailsContentProvider . KEY_NAME ) ) ; final String phone = data . getString ( data . getColumnIndex ( PlaceDetailsContentProvider . KEY_PHONE ) ) ; final String address = data . getString ( data . getColumnIndex ( PlaceDetailsContentProvider . KEY_ADDRESS ) ) ; final String rating = data . getString ( data . getColumnIndex ( PlaceDetailsContentProvider . KEY_RATING ) ) ; final String url = data . getString ( data . getColumnIndex ( PlaceDetailsContentProvider . KEY_URL ) ) ; if ( placeReference == null ) { placeReference = data . getString ( data . getColumnIndex ( PlaceDetailsContentProvider . KEY_REFERENCE ) ) ; updatePlace ( placeReference , placeId , true ) ; } handler . post ( new Runnable ( ) { public void run ( ) { nameTextView . setText ( name ) ; phoneTextView . setText ( phone ) ; addressTextView . setText ( address ) ; ratingTextView . setText ( rating ) ; urlTextView . setText ( url ) ; } } ) ; } } \n')
(1550660, 0.7612386, 'public void moveTo ( int x , int y ) { if ( penDown ) { canvas . setForegroundColor ( color ) ; canvas . drawLine ( xPosition , yPosition , x , y ) ; } xPosition = x ; yPosition = y ; } \n')
================================================================================