idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
37,900 | public static void premain ( String agentArgs , Instrumentation inst ) { // How do agent args work? http://stackoverflow.com/questions/23287228/how-do-i-pass-arguments-to-a-java-instrumentation-agent // e.g. java -javaagent:/path/to/agent.jar=argumentstring MarkerType markerType = MarkerType . NONE ; boolean debugMode ... | Java agent premain . | 519 | 5 |
37,901 | public static StorageSizes computeSizes ( Frame < BasicValue > frame , int offset , int length ) { Validate . notNull ( frame ) ; Validate . isTrue ( offset >= 0 ) ; Validate . isTrue ( length >= 0 ) ; Validate . isTrue ( offset < frame . getStackSize ( ) ) ; Validate . isTrue ( offset + length <= frame . getStackSize ... | Compute sizes required for the storage arrays that will contain the operand stack at this frame . | 449 | 19 |
37,902 | public static InsnList jumpTo ( LabelNode labelNode ) { Validate . notNull ( labelNode ) ; InsnList ret = new InsnList ( ) ; ret . add ( new JumpInsnNode ( Opcodes . GOTO , labelNode ) ) ; return ret ; } | Generates instructions for an unconditional jump to a label . | 61 | 11 |
37,903 | public static InsnList addLabel ( LabelNode labelNode ) { Validate . notNull ( labelNode ) ; InsnList ret = new InsnList ( ) ; ret . add ( labelNode ) ; return ret ; } | Generates instructions for a label . | 48 | 7 |
37,904 | public static InsnList lineNumber ( int num ) { Validate . isTrue ( num >= 0 ) ; InsnList ret = new InsnList ( ) ; LabelNode labelNode = new LabelNode ( ) ; ret . add ( labelNode ) ; ret . add ( new LineNumberNode ( num , labelNode ) ) ; return ret ; } | Generates instructions for line numbers . This is useful for debugging . For example you can put a line number of 99999 or some other special number to denote that the code being executed is instrumented code . Then if a stacktrace happens you ll know that if instrumented code was immediately involved . | 74 | 59 |
37,905 | public static InsnList pop ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . POP ) ) ; return ret ; } | Generates instructions to pop an item off the stack . | 41 | 11 |
37,906 | public static InsnList monitorEnter ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . MONITORENTER ) ) ; return ret ; } | Generates a MONITORENTER instruction which consumes an Object from the top of the stack . | 46 | 20 |
37,907 | public static InsnList monitorExit ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . MONITOREXIT ) ) ; return ret ; } | Generates a MONITOREXIT instruction which consumes an Object from the top of the stack . | 46 | 20 |
37,908 | public static InsnList loadIntConst ( int i ) { InsnList ret = new InsnList ( ) ; ret . add ( new LdcInsnNode ( i ) ) ; return ret ; } | Generates instructions to push an integer constant on to the stack . | 44 | 13 |
37,909 | public static InsnList loadStringConst ( String s ) { Validate . notNull ( s ) ; InsnList ret = new InsnList ( ) ; ret . add ( new LdcInsnNode ( s ) ) ; return ret ; } | Generates instruction to push a string constant on to the stack . | 53 | 13 |
37,910 | public static InsnList loadNull ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . ACONST_NULL ) ) ; return ret ; } | Generates instruction to push a null on to the stack . | 46 | 12 |
37,911 | public static InsnList loadVar ( Variable variable ) { Validate . notNull ( variable ) ; InsnList ret = new InsnList ( ) ; switch ( variable . getType ( ) . getSort ( ) ) { case Type . BOOLEAN : case Type . BYTE : case Type . CHAR : case Type . SHORT : case Type . INT : ret . add ( new VarInsnNode ( Opcodes . ILOAD , v... | Copies a local variable on to the stack . | 318 | 10 |
37,912 | public static InsnList saveVar ( Variable variable ) { Validate . notNull ( variable ) ; InsnList ret = new InsnList ( ) ; switch ( variable . getType ( ) . getSort ( ) ) { case Type . BOOLEAN : case Type . BYTE : case Type . CHAR : case Type . SHORT : case Type . INT : ret . add ( new VarInsnNode ( Opcodes . ISTORE , ... | Pops the stack in to the the local variable table . You may run in to problems if the item on top of the stack isn t of the same type as the variable it s being put in to . | 284 | 42 |
37,913 | public static InsnList createNewObjectArray ( InsnList size ) { Validate . notNull ( size ) ; InsnList ret = new InsnList ( ) ; ret . add ( size ) ; ret . add ( new TypeInsnNode ( Opcodes . ANEWARRAY , "java/lang/Object" ) ) ; return ret ; } | Creates a new object array on the stack . | 76 | 10 |
37,914 | public static InsnList loadArrayLength ( InsnList arrayRef ) { Validate . notNull ( arrayRef ) ; InsnList ret = new InsnList ( ) ; ret . add ( arrayRef ) ; ret . add ( new InsnNode ( Opcodes . ARRAYLENGTH ) ) ; return ret ; } | Gets the size of an array and puts it on to the stack . | 69 | 15 |
37,915 | public static InsnList addIntegers ( InsnList lhs , InsnList rhs ) { Validate . notNull ( lhs ) ; Validate . notNull ( rhs ) ; InsnList ret = new InsnList ( ) ; ret . add ( lhs ) ; ret . add ( rhs ) ; ret . add ( new InsnNode ( Opcodes . IADD ) ) ; return ret ; } | Adds two integers together and puts the result on to the stack . | 91 | 13 |
37,916 | public static InsnList ifIntegersEqual ( InsnList lhs , InsnList rhs , InsnList action ) { Validate . notNull ( lhs ) ; Validate . notNull ( rhs ) ; Validate . notNull ( action ) ; InsnList ret = new InsnList ( ) ; LabelNode notEqualLabelNode = new LabelNode ( ) ; ret . add ( lhs ) ; ret . add ( rhs ) ; ret . add ( new... | Compares two integers and performs some action if the integers are equal . | 149 | 14 |
37,917 | public static InsnList forEach ( Variable counterVar , Variable arrayLenVar , InsnList array , InsnList action ) { Validate . notNull ( counterVar ) ; Validate . notNull ( arrayLenVar ) ; Validate . notNull ( array ) ; Validate . notNull ( action ) ; Validate . isTrue ( counterVar . getType ( ) . equals ( Type . INT_TY... | For each element in an object array performs an action . | 632 | 11 |
37,918 | public static InsnList combineObjectArrays ( Variable destArrayVar , Variable firstArrayVar , Variable secondArrayVar ) { Validate . notNull ( destArrayVar ) ; Validate . notNull ( firstArrayVar ) ; Validate . notNull ( secondArrayVar ) ; Validate . isTrue ( destArrayVar . getType ( ) . equals ( Type . getType ( Object... | Concatenates two object arrays together . | 435 | 9 |
37,919 | public static InsnList tryCatchBlock ( TryCatchBlockNode tryCatchBlockNode , Type exceptionType , InsnList tryInsnList , InsnList catchInsnList ) { Validate . notNull ( tryInsnList ) ; // exceptionType can be null Validate . notNull ( catchInsnList ) ; if ( exceptionType != null ) { Validate . isTrue ( exceptionType . ... | Generates instructions for a try - catch block . | 282 | 10 |
37,920 | public static InsnList returnValue ( Type returnType , InsnList returnValueInsnList ) { Validate . notNull ( returnType ) ; Validate . isTrue ( returnType . getSort ( ) != Type . METHOD ) ; InsnList ret = new InsnList ( ) ; ret . add ( returnValueInsnList ) ; switch ( returnType . getSort ( ) ) { case Type . VOID : ret... | Generates instructions that returns a value . | 287 | 8 |
37,921 | protected final void instrumentPath ( Log log , List < String > classpath , File path ) throws MojoExecutionException { try { Instrumenter instrumenter = getInstrumenter ( log , classpath ) ; InstrumentationSettings settings = new InstrumentationSettings ( markerType , debugMode , autoSerializable ) ; PluginHelper . in... | Instruments all classes in a path recursively . | 115 | 12 |
37,922 | private static byte [ ] dumpBytecode ( MethodNode methodNode ) { // Calculate label offsets -- required for hash calculation // we only care about where the labels are in relation to the opcode instructions -- we don't care about things like // LocalVariableNode or other ancillary data because these can change without ... | Takes into account the instructions and operands as well as the overall structure . | 348 | 16 |
37,923 | public static Type getReturnTypeOfInvocation ( AbstractInsnNode invokeNode ) { Validate . notNull ( invokeNode ) ; if ( invokeNode instanceof MethodInsnNode ) { MethodInsnNode methodInsnNode = ( MethodInsnNode ) invokeNode ; Type methodType = Type . getType ( methodInsnNode . desc ) ; return methodType . getReturnType ... | Get the return type of the method being invoked . | 166 | 10 |
37,924 | public void addIndividual ( String className , ClassInformation classInformation ) { Validate . notNull ( className ) ; Validate . notNull ( classInformation ) ; Validate . isTrue ( ! hierarchyMap . containsKey ( className ) ) ; hierarchyMap . put ( className , classInformation ) ; } | Add a custom class . | 66 | 5 |
37,925 | public void addClasspath ( List < File > classpath ) throws IOException { Validate . notNull ( classpath ) ; Validate . noNullElements ( classpath ) ; for ( File classpathElement : classpath ) { if ( classpathElement . isFile ( ) ) { addJar ( classpathElement ) ; } else if ( classpathElement . isDirectory ( ) ) { addDi... | Add classes contained within a list of JAR files and folders . Note that if a duplicate class is encountered the original is kept . | 106 | 26 |
37,926 | private static InsnList popMethodResult ( AbstractInsnNode invokeInsnNode ) { Validate . notNull ( invokeInsnNode ) ; Type returnType = getReturnTypeOfInvocation ( invokeInsnNode ) ; InsnList ret = new InsnList ( ) ; switch ( returnType . getSort ( ) ) { case Type . LONG : case Type . DOUBLE : ret . add ( new InsnNode ... | Generates instructions to pop the result of the method off the stack . This will only generate instructions if the method being invoked generates a return value . | 154 | 29 |
37,927 | public void detail ( MethodNode methodNode , MethodAttributes attrs , StringBuilder output ) { Validate . notNull ( methodNode ) ; Validate . notNull ( attrs ) ; Validate . notNull ( output ) ; int methodId = attrs . getSignature ( ) . getMethodId ( ) ; output . append ( "Class Name: " ) . append ( attrs . getSignature... | MUST BE CALLED PRIOR TO INSTRUMENTATION!!!! | 572 | 14 |
37,928 | @ Override protected String getCommonSuperClass ( final String type1 , final String type2 ) { Validate . notNull ( type1 ) ; Validate . notNull ( type2 ) ; infoRepo . getInformation ( type1 ) ; LinkedHashSet < String > type1Hierarchy = flattenHierarchy ( type1 ) ; LinkedHashSet < String > type2Hierarchy = flattenHierar... | Derives common super class from the super name mapping passed in to the constructor . | 176 | 16 |
37,929 | void validateState ( ) { if ( frames == null || coroutine == null ) { throw new IllegalStateException ( "Bad state" ) ; } for ( int i = 0 ; i < frames . length ; i ++ ) { if ( frames [ i ] == null ) { throw new IllegalStateException ( "Bad state" ) ; } frames [ i ] . validateState ( ) ; } } | method to do that . | 83 | 5 |
37,930 | public static InsnList debugMarker ( MarkerType markerType , String text ) { Validate . notNull ( markerType ) ; Validate . notNull ( text ) ; InsnList ret = new InsnList ( ) ; switch ( markerType ) { case NONE : break ; case CONSTANT : ret . add ( new LdcInsnNode ( text ) ) ; ret . add ( new InsnNode ( Opcodes . POP )... | Generates instructions for generating marker instructions . These marker instructions are meant to be is useful for debugging instrumented code . For example you can spot a specific portion of instrumented code by looking for specific markers in the assembly output . | 226 | 45 |
37,931 | public InstrumentationResult instrument ( byte [ ] input , InstrumentationSettings settings ) { Validate . notNull ( input ) ; Validate . notNull ( settings ) ; Validate . isTrue ( input . length > 0 ) ; // Read class as tree model -- because we're using SimpleClassNode, JSR blocks get inlined ClassReader cr = new Clas... | Instruments a class . | 575 | 6 |
37,932 | public static List < MethodNode > findMethodsWithName ( Collection < MethodNode > methodNodes , String name ) { Validate . notNull ( methodNodes ) ; Validate . notNull ( name ) ; Validate . noNullElements ( methodNodes ) ; List < MethodNode > ret = new ArrayList <> ( ) ; for ( MethodNode methodNode : methodNodes ) { if... | Find methods within a class with a specific name . | 112 | 10 |
37,933 | public static List < MethodNode > findStaticMethods ( Collection < MethodNode > methodNodes ) { Validate . notNull ( methodNodes ) ; Validate . noNullElements ( methodNodes ) ; List < MethodNode > ret = new ArrayList <> ( ) ; for ( MethodNode methodNode : methodNodes ) { if ( ( methodNode . access & Opcodes . ACC_STATI... | Find static methods within a class . | 112 | 7 |
37,934 | public static MethodNode findMethod ( Collection < MethodNode > methodNodes , boolean isStatic , Type returnType , String name , Type ... paramTypes ) { Validate . notNull ( methodNodes ) ; Validate . notNull ( returnType ) ; Validate . notNull ( name ) ; Validate . notNull ( paramTypes ) ; Validate . noNullElements ( ... | Find a method within a class . | 258 | 7 |
37,935 | public static List < AbstractInsnNode > findInvocationsOf ( InsnList insnList , Method expectedMethod ) { Validate . notNull ( insnList ) ; Validate . notNull ( expectedMethod ) ; List < AbstractInsnNode > ret = new ArrayList <> ( ) ; Type expectedMethodDesc = Type . getType ( expectedMethod ) ; Type expectedMethodOwne... | Find invocations of a certain method . | 293 | 8 |
37,936 | public static List < AbstractInsnNode > findInvocationsWithParameter ( InsnList insnList , Type expectedParamType ) { Validate . notNull ( insnList ) ; Validate . notNull ( expectedParamType ) ; Validate . isTrue ( expectedParamType . getSort ( ) != Type . METHOD && expectedParamType . getSort ( ) != Type . VOID ) ; Li... | Find invocations of any method where the parameter list contains a type . | 324 | 14 |
37,937 | public static List < AbstractInsnNode > searchForOpcodes ( InsnList insnList , int ... opcodes ) { Validate . notNull ( insnList ) ; Validate . notNull ( opcodes ) ; Validate . isTrue ( opcodes . length > 0 ) ; List < AbstractInsnNode > ret = new LinkedList <> ( ) ; Set < Integer > opcodeSet = new HashSet <> ( ) ; Arra... | Find instructions in a certain class that are of a certain set of opcodes . | 201 | 16 |
37,938 | public static LineNumberNode findLineNumberForInstruction ( InsnList insnList , AbstractInsnNode insnNode ) { Validate . notNull ( insnList ) ; Validate . notNull ( insnNode ) ; int idx = insnList . indexOf ( insnNode ) ; Validate . isTrue ( idx != - 1 ) ; // Get index of labels and insnNode within method ListIterator ... | Find line number associated with an instruction . | 162 | 8 |
37,939 | public static FieldNode findField ( ClassNode classNode , String name ) { Validate . notNull ( classNode ) ; Validate . notNull ( name ) ; Validate . notEmpty ( name ) ; return classNode . fields . stream ( ) . filter ( x -> name . equals ( x . name ) ) . findAny ( ) . orElse ( null ) ; } | Find field within a class by its name . | 80 | 9 |
37,940 | public static void validateXMLSchema ( String xsdPath , String xmlPath ) throws IOException , SAXException { InputStream xsdStream = null ; InputStream xmlStream = null ; try { xsdStream = XmlUtils . class . getResourceAsStream ( xsdPath ) ; //try loading from classpath first - fallback to disk if ( xsdStream == null )... | Validate XML matches XSD . Path - based method . Simple redirect to the overloaded version that accepts streams . | 260 | 22 |
37,941 | public static void validateXMLSchema ( InputStream xsdStream , InputStream xmlStream ) throws IOException , SAXException { SchemaFactory factory = SchemaFactory . newInstance ( XMLConstants . W3C_XML_SCHEMA_NS_URI ) ; Schema schema = factory . newSchema ( new StreamSource ( xsdStream ) ) ; Validator validator = schema ... | Validate XML matches XSD . Stream - based method . | 108 | 12 |
37,942 | public static String getElementQualifiedName ( XMLStreamReader xmlReader , Map < String , String > namespaces ) { String namespaceUri = null ; String localName = null ; switch ( xmlReader . getEventType ( ) ) { case XMLStreamConstants . START_ELEMENT : case XMLStreamConstants . END_ELEMENT : namespaceUri = xmlReader . ... | Helper method for getting qualified name from stax reader given a set of specified schema namespaces | 135 | 18 |
37,943 | public static DateTime fromString ( String rfc3339Timestamp ) { if ( rfc3339Timestamp == null ) { return null ; } DateTime dateTime = new DateTime ( rfc3339Timestamp , DateTimeZone . UTC ) ; return dateTime ; } | Helper for parsing rfc3339 compliant timestamp from string | 60 | 11 |
37,944 | private ServerConfiguration loadConfiguration ( ServerConfigurationReader configurationReader ) throws ConfigurationException { ServerConfiguration configuration = configurationReader . read ( ) ; return configuration ; } | Bootstrap mechanism that loads the configuration for the server object based on the specified configuration reading mechanism . | 31 | 19 |
37,945 | public Collection < String > getRelatedDetectionSystems ( DetectionSystem detectionSystem ) { Collection < String > relatedDetectionSystems = new HashSet < String > ( ) ; relatedDetectionSystems . add ( detectionSystem . getDetectionSystemId ( ) ) ; if ( correlationSets != null ) { for ( CorrelationSet correlationSet :... | Find related detection systems based on a given detection system . This simply means those systems that have been configured along with the specified system id as part of a correlation set . | 150 | 33 |
37,946 | private Collection < String > buildTopicNames ( Response response ) { Collection < String > topicNames = new HashSet <> ( ) ; Collection < String > detectionSystemNames = appSensorServer . getConfiguration ( ) . getRelatedDetectionSystems ( response . getDetectionSystem ( ) ) ; for ( String detectionSystemName : detect... | build the appropriate topic names to send this response to based on related detection systems | 100 | 15 |
37,947 | @ Override public void analyze ( Response response ) { if ( response != null ) { logger . info ( "NO-OP Response for user <" + response . getUser ( ) . getUsername ( ) + "> - should be executing response action " + response . getAction ( ) ) ; } } | This method simply logs responses . | 65 | 6 |
37,948 | public Collection < Response > findResponses ( SearchCriteria criteria , Collection < Response > responses ) { if ( criteria == null ) { throw new IllegalArgumentException ( "criteria must be non-null" ) ; } Collection < Response > matches = new ArrayList < Response > ( ) ; User user = criteria . getUser ( ) ; Collecti... | Finder for responses in the ResponseStore | 296 | 8 |
37,949 | private ClientConfiguration loadConfiguration ( ClientConfigurationReader configurationReader ) throws ConfigurationException { ClientConfiguration configuration = configurationReader . read ( ) ; return configuration ; } | Bootstrap mechanism that loads the configuration for the client object based on the specified configuration reading mechanism . | 31 | 19 |
37,950 | private Collection < String > buildQueueNames ( Response response ) { Collection < String > queueNames = new HashSet <> ( ) ; Collection < String > detectionSystemNames = appSensorServer . getConfiguration ( ) . getRelatedDetectionSystems ( response . getDetectionSystem ( ) ) ; for ( String detectionSystemName : detect... | build the appropriate queues to send this response to based on related detection systems | 102 | 14 |
37,951 | protected String encodeCEFHeader ( String text ) { String encoded = text ; // back-slash encode back-slashes (needs to be first) encoded = encoded . replace ( "\\" , "\\\\" ) ; // back-slash encode pipes encoded = encoded . replace ( "|" , "\\|" ) ; // strip carriage returns and newlines encoded = encoded . replace ( "... | header needs to encode | \ \ r \ n | 107 | 10 |
37,952 | protected String encodeCEFExtension ( String text ) { String encoded = text ; // back-slash encode back-slashes (needs to be first) encoded = encoded . replace ( "\\" , "\\\\" ) ; // back-slash encode equals signs encoded = encoded . replace ( "=" , "\\=" ) ; // strip carriage returns and newlines encoded = encoded . r... | extension needs to encode \ = \ r \ n | 107 | 11 |
37,953 | @ Override public void analyze ( Response response ) { if ( response == null ) { return ; } if ( ResponseHandler . LOG . equals ( response . getAction ( ) ) ) { logger . info ( "Handling <log> response for user <{}>" , response . getUser ( ) . getUsername ( ) ) ; } else { logger . info ( "Delegating response for user <... | This method simply logs or executes responses . | 135 | 8 |
37,954 | public long next ( ) { long currentTime = System . currentTimeMillis ( ) ; long counter ; synchronized ( this ) { if ( currentTime < referenceTime ) { throw new RuntimeException ( String . format ( "Last referenceTime %s is after reference time %s" , referenceTime , currentTime ) ) ; } else if ( currentTime > reference... | Generates a k - ordered unique 64 - bit integer . Subsequent invocations of this method will produce increasing integer values . | 170 | 25 |
37,955 | public void addTimexAnnotation ( String timexType , int begin , int end , Sentence sentence , String timexValue , String timexQuant , String timexFreq , String timexMod , String emptyValue , String timexId , String foundByRule , JCas jcas ) { Timex3 annotation = new Timex3 ( jcas ) ; annotation . setBegin ( begin ) ; a... | Add timex annotation to CAS object . | 683 | 8 |
37,956 | public void specifyAmbiguousValues ( JCas jcas ) { // build up a list with all found TIMEX expressions List < Timex3 > linearDates = new ArrayList < Timex3 > ( ) ; FSIterator iterTimex = jcas . getAnnotationIndex ( Timex3 . type ) . iterator ( ) ; // Create List of all Timexes of types "date" and "time" while ( iterTim... | Under - specified values are disambiguated here . Only Timexes of types date and time can be under - specified . | 602 | 25 |
37,957 | public boolean checkPosConstraint ( Sentence s , String posConstraint , MatchResult m , JCas jcas ) { Pattern paConstraint = Pattern . compile ( "group\\(([0-9]+)\\):(.*?):" ) ; for ( MatchResult mr : Toolbox . findMatches ( paConstraint , posConstraint ) ) { int groupNumber = Integer . parseInt ( mr . group ( 1 ) ) ; ... | Check whether the part of speech constraint defined in a rule is satisfied . | 237 | 14 |
37,958 | private Boolean isValidDCT ( JCas jcas ) { FSIterator dctIter = jcas . getAnnotationIndex ( Dct . type ) . iterator ( ) ; if ( ! dctIter . hasNext ( ) ) { return true ; } else { Dct dct = ( Dct ) dctIter . next ( ) ; String dctVal = dct . getValue ( ) ; if ( dctVal == null ) return false ; if ( dctVal . matches ( "\\d{... | Check whether or not a jcas object has a correct DCT value . If there is no DCT present we canonically return true since fallback calculation takes care of that scenario . | 168 | 37 |
37,959 | void startScanSFeaturesAt ( List seq , int pos ) { sFeatures . clear ( ) ; sFeatureIdx = 0 ; Observation obsr = ( Observation ) seq . get ( pos ) ; // scan over all context predicates for ( int i = 0 ; i < obsr . cps . length ; i ++ ) { Element elem = ( Element ) dict . dict . get ( new Integer ( obsr . cps [ i ] ) ) ;... | Start scan s features at . | 336 | 6 |
37,960 | Feature nextSFeature ( ) { Feature sF = ( Feature ) sFeatures . get ( sFeatureIdx ) ; sFeatureIdx ++ ; return sF ; } | Next s feature . | 36 | 4 |
37,961 | Feature nextEFeature ( ) { Feature eF = ( Feature ) eFeatures . get ( eFeatureIdx ) ; eFeatureIdx ++ ; return eF ; } | Next e feature . | 36 | 4 |
37,962 | public void updateFeatures ( ) { for ( int i = 0 ; i < feaGen . features . size ( ) ; i ++ ) { Feature f = ( Feature ) feaGen . features . get ( i ) ; f . wgt = lambda [ f . idx ] ; } } | Update features . | 62 | 3 |
37,963 | public void initInference ( ) { if ( lambda == null ) { System . out . println ( "numFetures: " + feaGen . numFeatures ( ) ) ; lambda = new double [ feaGen . numFeatures ( ) + 1 ] ; // reading feature weights from the feature list for ( int i = 0 ; i < feaGen . features . size ( ) ; i ++ ) { Feature f = ( Feature ) fea... | Inits the inference . | 120 | 5 |
37,964 | public void compMult ( DoubleVector dv ) { for ( int i = 0 ; i < len ; i ++ ) { vect [ i ] *= dv . vect [ i ] ; } } | Comp mult . | 44 | 3 |
37,965 | public static int findFirstOf ( String container , String chars , int begin ) { int minIdx = - 1 ; for ( int i = 0 ; i < chars . length ( ) && i >= 0 ; ++ i ) { int idx = container . indexOf ( chars . charAt ( i ) , begin ) ; if ( ( idx < minIdx && idx != - 1 ) || minIdx == - 1 ) { minIdx = idx ; } } return minIdx ; } | Find the first occurrence . | 108 | 5 |
37,966 | public static int findLastOf ( String container , String charSeq , int begin ) { //find the last occurrence of one of characters in charSeq from begin backward for ( int i = begin ; i < container . length ( ) && i >= 0 ; -- i ) { if ( charSeq . contains ( "" + container . charAt ( i ) ) ) return i ; } return - 1 ; } | Find the last occurrence . | 86 | 5 |
37,967 | public static int findFirstNotOf ( String container , String chars , int begin ) { //find the first occurrence of characters not in the charSeq from begin forward for ( int i = begin ; i < container . length ( ) && i >= 0 ; ++ i ) if ( ! chars . contains ( "" + container . charAt ( i ) ) ) return i ; return - 1 ; } | Find the first occurrence of characters not in the charSeq from begin | 82 | 14 |
37,968 | public static int findLastNotOf ( String container , String charSeq , int end ) { for ( int i = end ; i < container . length ( ) && i >= 0 ; -- i ) { if ( ! charSeq . contains ( "" + container . charAt ( i ) ) ) return i ; } return - 1 ; } | Find last not of . | 72 | 5 |
37,969 | public static boolean containNumber ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( Character . isDigit ( str . charAt ( i ) ) ) { return true ; } } return false ; } | Contain number . | 56 | 4 |
37,970 | public static boolean isAllNumber ( String str ) { boolean hasNumber = false ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( ! ( Character . isDigit ( str . charAt ( i ) ) || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) =... | Checks if is all number . | 155 | 7 |
37,971 | public static boolean isFirstCap ( String str ) { if ( isAllCap ( str ) ) return false ; if ( str . length ( ) > 0 && Character . isLetter ( str . charAt ( 0 ) ) && Character . isUpperCase ( str . charAt ( 0 ) ) ) { return true ; } return false ; } | Checks if is first cap . | 72 | 7 |
37,972 | public static boolean endsWithPunc ( String str ) { if ( str . endsWith ( "." ) || str . endsWith ( "?" ) || str . endsWith ( "!" ) || str . endsWith ( "," ) || str . endsWith ( ":" ) || str . endsWith ( "\"" ) || str . endsWith ( "'" ) || str . endsWith ( "''" ) || str . endsWith ( ";" ) ) { return true ; } return fal... | Ends with sign . | 106 | 5 |
37,973 | public static boolean endsWithStop ( String str ) { if ( str . endsWith ( "." ) || str . endsWith ( "?" ) || str . endsWith ( "!" ) ) { return true ; } return false ; } | Ends with stop . | 49 | 5 |
37,974 | public static int countStops ( String str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' ) { count ++ ; } } return count ; } | Count stops . | 80 | 3 |
37,975 | public static int countPuncs ( String str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' || str . charAt ( i ) == ' ' ) { count ++ ; } } return count ... | Count signs . | 114 | 3 |
37,976 | public static boolean isStop ( String str ) { if ( str . compareTo ( "." ) == 0 ) { return true ; } if ( str . compareTo ( "?" ) == 0 ) { return true ; } if ( str . compareTo ( "!" ) == 0 ) { return true ; } return false ; } | Checks if is stop . | 68 | 6 |
37,977 | public static boolean isPunc ( String str ) { if ( str == null ) return false ; str = str . trim ( ) ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { char c = str . charAt ( i ) ; if ( Character . isDigit ( c ) || Character . isLetter ( c ) ) { return false ; } } return true ; } | Checks if is punctuation . | 87 | 7 |
37,978 | public static String capitalizeWord ( String s ) { // validate if ( ( s == null ) || ( s . length ( ) == 0 ) ) { return s ; } return s . substring ( 0 , 1 ) . toUpperCase ( ) + s . substring ( 1 ) . toLowerCase ( ) ; } | Capitalises the first letter of a given string . | 68 | 10 |
37,979 | public static String sort ( String s ) { char [ ] chars = s . toCharArray ( ) ; Arrays . sort ( chars ) ; return new String ( chars ) ; } | Sorts the characters in the specified string . | 38 | 9 |
37,980 | public String convert ( String text ) { String ret = text ; if ( cpsUni2Uni == null ) return ret ; Iterator < String > it = cpsUni2Uni . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { String cpsChar = it . next ( ) ; ret = ret . replaceAll ( cpsChar , cpsUni2Uni . get ( cpsChar ) ) ; } return ret ; } | Convert a vietnamese string with composite unicode encoding to unicode encoding . | 105 | 17 |
37,981 | public static void printDetail ( Class < ? > c , String msg ) { if ( Logger . printDetails ) { String preamble ; if ( c != null ) preamble = "[" + c . getSimpleName ( ) + "]" ; else preamble = "" ; synchronized ( System . err ) { System . err . println ( preamble + " " + msg ) ; } } } | print DEBUG level information with package name | 88 | 7 |
37,982 | public static void printError ( Class < ? > c , String msg ) { String preamble ; if ( c != null ) preamble = "[" + c . getSimpleName ( ) + "]" ; else preamble = "" ; synchronized ( System . err ) { System . err . println ( preamble + " " + msg ) ; } } | print an ERROR - Level message with package name | 77 | 9 |
37,983 | protected boolean readFeatureParameters ( Element node ) { try { NodeList childrent = node . getChildNodes ( ) ; cpnames = new Vector < String > ( ) ; paras = new Vector < Vector < Integer > > ( ) ; for ( int i = 0 ; i < childrent . getLength ( ) ; i ++ ) if ( childrent . item ( i ) instanceof Element ) { Element child... | Read feature parameters . | 245 | 4 |
37,984 | public static Vector < Element > readFeatureNodes ( String templateFile ) { Vector < Element > feaTypes = new Vector < Element > ( ) ; try { // Read feature template file........ DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; Inpu... | Read feature nodes . | 224 | 4 |
37,985 | public void generateTrainData ( String inputPath , String outputPath ) { try { File file = new File ( inputPath ) ; ArrayList < Sentence > data = new ArrayList < Sentence > ( ) ; if ( file . isFile ( ) ) { System . out . println ( "Reading " + file . getName ( ) ) ; data = ( ArrayList < Sentence > ) reader . readFile (... | Generate train data . | 461 | 5 |
37,986 | public String getContextStr ( Sentence sent , int wordIdx ) { String cpStr = "" ; for ( int i = 0 ; i < cntxGenVector . size ( ) ; ++ i ) { String [ ] context = cntxGenVector . get ( i ) . getContext ( sent , wordIdx ) ; if ( context != null ) { for ( int j = 0 ; j < context . length ; ++ j ) { if ( context [ j ] . tri... | Gets the context str . | 136 | 6 |
37,987 | public void writeCpMaps ( Dictionary dict , PrintWriter fout ) throws IOException { Iterator it = null ; if ( cpStr2Int == null ) { return ; } int count = 0 ; for ( it = cpStr2Int . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { String cpStr = ( String ) it . next ( ) ; Integer cpInt = ( Integer ) cpStr2Int . get (... | Write cp maps . | 297 | 4 |
37,988 | public void writeLbMaps ( PrintWriter fout ) throws IOException { if ( lbStr2Int == null ) { return ; } // write the map size fout . println ( Integer . toString ( lbStr2Int . size ( ) ) ) ; for ( Iterator it = lbStr2Int . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { String lbStr = ( String ) it . next ( ) ; Inte... | Write lb maps . | 156 | 4 |
37,989 | public void readTstData ( String dataFile ) { if ( tstData != null ) { tstData . clear ( ) ; } else { tstData = new ArrayList ( ) ; } // open data file BufferedReader fin = null ; try { fin = new BufferedReader ( new InputStreamReader ( new FileInputStream ( dataFile ) , "UTF-8" ) ) ; System . out . println ( "Reading ... | Read tst data . | 536 | 5 |
37,990 | public void setFilename ( String v ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_filename == null ) jcasType . jcas . throwFeatMissing ( "filename" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_filenam... | setter for filename - sets | 116 | 6 |
37,991 | public int getTokId ( ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_tokId == null ) jcasType . jcas . throwFeatMissing ( "tokId" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; return jcasType . ll_cas . ll_getIntValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_tokId ) ; } | getter for tokId - gets | 120 | 8 |
37,992 | public void setTokId ( int v ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_tokId == null ) jcasType . jcas . throwFeatMissing ( "tokId" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; jcasType . ll_cas . ll_setIntValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_tokId , v ) ; } | setter for tokId - sets | 123 | 8 |
37,993 | public String getEventId ( ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_eventId == null ) jcasType . jcas . throwFeatMissing ( "eventId" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_eventId ) ... | getter for eventId - gets | 117 | 7 |
37,994 | public void setEventId ( String v ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_eventId == null ) jcasType . jcas . throwFeatMissing ( "eventId" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_eventId , ... | setter for eventId - sets | 120 | 7 |
37,995 | public int getEventInstanceId ( ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_eventInstanceId == null ) jcasType . jcas . throwFeatMissing ( "eventInstanceId" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; return jcasType . ll_cas . ll_getIntValue ( addr , ( ( Event_Type ) jcasType ) . casF... | getter for eventInstanceId - gets | 121 | 8 |
37,996 | public void setEventInstanceId ( int v ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_eventInstanceId == null ) jcasType . jcas . throwFeatMissing ( "eventInstanceId" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; jcasType . ll_cas . ll_setIntValue ( addr , ( ( Event_Type ) jcasType ) . casF... | setter for eventInstanceId - sets | 124 | 8 |
37,997 | public String getModality ( ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_modality == null ) jcasType . jcas . throwFeatMissing ( "modality" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_modalit... | getter for modality - gets | 117 | 7 |
37,998 | public void setModality ( String v ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_modality == null ) jcasType . jcas . throwFeatMissing ( "modality" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_modalit... | setter for modality - sets | 120 | 7 |
37,999 | public String getTense ( ) { if ( Event_Type . featOkTst && ( ( Event_Type ) jcasType ) . casFeat_tense == null ) jcasType . jcas . throwFeatMissing ( "tense" , "de.unihd.dbs.uima.types.heideltime.Event" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Event_Type ) jcasType ) . casFeatCode_tense ) ; } | getter for tense - gets | 117 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.