idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
36,900
protected < T extends Serializable > Map < String , Object > preSerializer ( T serializableObject ) { Map < String , Object > objReferences = new HashMap <> ( ) ; for ( Field field : ReflectionMethods . getAllFields ( new LinkedList <> ( ) , serializableObject . getClass ( ) ) ) { if ( field . isAnnotationPresent ( Big...
This method is called before serializing the objects . It extracts all the not - serializable BigMap references of the provided object and stores them in a Map . Then it replaces all the references of the provided object with nulls to avoid their serialization . The main idea is that we temporarily remove from the obje...
227
74
36,901
protected < T extends Serializable > void postSerializer ( T serializableObject , Map < String , Object > objReferences ) { for ( Field field : ReflectionMethods . getAllFields ( new LinkedList <> ( ) , serializableObject . getClass ( ) ) ) { String fieldName = field . getName ( ) ; Object ref = objReferences . remove ...
This method is called after the object serialization . It moves all the not - serializable BigMap references from the Map back to the provided object . The main idea is that once the serialization is completed we are allowed to restore back all the references which were removed by the preSerializer .
151
59
36,902
protected < T extends Serializable > void postDeserializer ( T serializableObject ) { Method method = null ; for ( Field field : ReflectionMethods . getAllFields ( new LinkedList <> ( ) , serializableObject . getClass ( ) ) ) { if ( field . isAnnotationPresent ( BigMap . class ) ) { //look only for BigMaps field . setA...
This method is called after the object deserialization . It initializes all BigMaps of the serializable object which have a null value . The main idea is that once an object is deserialized it will contain nulls in all the BigMap fields which were not serialized . For all of those fields we call their initialization me...
210
68
36,903
public static boolean isActive ( Enum obj ) { Enum value = ACTIVE_SWITCHES . get ( ( Class ) obj . getClass ( ) ) ; return value != null && value == obj ; }
Validates whether the feature is active .
45
8
36,904
public boolean isValid ( ) { int totalNumberOfColumns = 0 ; Set < Object > columns = new HashSet <> ( ) ; for ( Map . Entry < Object , AssociativeArray > entry : internalData . entrySet ( ) ) { AssociativeArray row = entry . getValue ( ) ; if ( columns . isEmpty ( ) ) { //this is executed only for the first row for ( O...
Returns if the DataTable2D is valid . This data structure is considered valid it all the DataTable cells are set and as a result the DataTable has a rectangular format .
213
36
36,905
protected Object getSelectedClassFromClassScores ( AssociativeArray predictionScores ) { Map . Entry < Object , Object > maxEntry = MapMethods . selectMaxKeyValue ( predictionScores ) ; return maxEntry . getKey ( ) ; }
Estimates the selected class from the prediction scores .
53
10
36,906
public static FlatDataCollection randomSampling ( FlatDataList idList , int n , boolean randomizeRecords ) { FlatDataList sampledIds = new FlatDataList ( ) ; int populationN = idList . size ( ) ; Object [ ] keys = idList . toArray ( ) ; if ( randomizeRecords ) { PHPMethods . < Object > shuffle ( keys ) ; } int k = popu...
Samples n ids by using Systematic Sampling
202
11
36,907
private CL getFromClusterMap ( int clusterId , Map < Integer , CL > clusterMap ) { CL c = clusterMap . get ( clusterId ) ; if ( c . getFeatureIds ( ) == null ) { c . setFeatureIds ( knowledgeBase . getModelParameters ( ) . getFeatureIds ( ) ) ; //fetch the featureIds from model parameters object } return c ; }
Always use this method to get the cluster from the clusterMap because it ensures that the featureIds are set . The featureIds can be unset if we use a data structure which stores stuff in file . Since the featureIds field of cluster is transient the information gets lost . This function ensures that it sets it back .
88
67
36,908
protected String getDirectory ( ) { //get the default filepath of the permanet storage file String directory = storageConfiguration . getDirectory ( ) ; if ( directory == null || directory . isEmpty ( ) ) { directory = System . getProperty ( "java.io.tmpdir" ) ; //write them to the tmp directory } return directory ; }
Returns the location of the directory from the configuration or the temporary directory if not defined .
73
17
36,909
protected Path getRootPath ( String storageName ) { return Paths . get ( getDirectory ( ) + File . separator + storageName ) ; }
Returns the root path of the storage .
32
8
36,910
protected boolean deleteIfExistsRecursively ( Path path ) throws IOException { try { return Files . deleteIfExists ( path ) ; } catch ( DirectoryNotEmptyException ex ) { //do recursive delete Files . walkFileTree ( path , new SimpleFileVisitor < Path > ( ) { @ Override public FileVisitResult visitFile ( Path file , Bas...
Deletes the file or directory recursively if it exists .
148
13
36,911
protected boolean deleteDirectory ( Path path , boolean cleanParent ) throws IOException { boolean pathExists = deleteIfExistsRecursively ( path ) ; if ( pathExists && cleanParent ) { cleanEmptyParentDirectory ( path . getParent ( ) ) ; return true ; } return false ; }
Deletes a directory and optionally removes the parent directory if it becomes empty .
63
15
36,912
private void cleanEmptyParentDirectory ( Path path ) throws IOException { Path normPath = path . normalize ( ) ; if ( normPath . equals ( Paths . get ( getDirectory ( ) ) . normalize ( ) ) || normPath . equals ( Paths . get ( System . getProperty ( "java.io.tmpdir" ) ) . normalize ( ) ) ) { //stop if we reach the outpu...
Removes recursively all empty parent directories up to and excluding the storage directory .
153
17
36,913
protected boolean moveDirectory ( Path src , Path target ) throws IOException { if ( Files . exists ( src ) ) { createDirectoryIfNotExists ( target . getParent ( ) ) ; deleteDirectory ( target , false ) ; Files . move ( src , target ) ; cleanEmptyParentDirectory ( src . getParent ( ) ) ; return true ; } else { return f...
Moves a directory in the target location .
81
9
36,914
protected boolean createDirectoryIfNotExists ( Path path ) throws IOException { if ( ! Files . exists ( path ) ) { Files . createDirectories ( path ) ; return true ; } else { return false ; } }
Creates the directory in the target location if it does not exist .
47
14
36,915
public static double simpleMovingAverage ( FlatDataList flatDataList , int N ) { double SMA = 0 ; int counter = 0 ; for ( int i = flatDataList . size ( ) - 1 ; i >= 0 ; -- i ) { double Yti = flatDataList . getDouble ( i ) ; if ( counter >= N ) { break ; } SMA += Yti ; //possible numeric overflow ++ counter ; } SMA /= c...
Simple Moving Average
102
3
36,916
public static double weightedMovingAverage ( FlatDataList flatDataList , int N ) { double WMA = 0 ; double denominator = 0.0 ; int counter = 0 ; for ( int i = flatDataList . size ( ) - 1 ; i >= 0 ; -- i ) { double Yti = flatDataList . getDouble ( i ) ; if ( counter >= N ) { break ; } double weight = ( N - counter ) ; W...
Weighted Moving Average
127
4
36,917
public static double simpleExponentialSmoothing ( FlatDataList flatDataList , double a ) { double EMA = 0 ; int count = 0 ; for ( int i = flatDataList . size ( ) - 1 ; i >= 0 ; -- i ) { double Yti = flatDataList . getDouble ( i ) ; EMA += a * Math . pow ( 1 - a , count ) * Yti ; ++ count ; } return EMA ; }
Simple Explonential Smoothing
97
6
36,918
public static Double largest ( Iterator < Double > elements , int k ) { Iterator < Double > oppositeElements = new Iterator < Double > ( ) { /** {@inheritDoc} */ @ Override public boolean hasNext ( ) { return elements . hasNext ( ) ; } /** {@inheritDoc} */ @ Override public Double next ( ) { return - elements . next ( ...
Selects the kth largest element from an iterable object .
118
13
36,919
public static double nBar ( TransposeDataList clusterIdList ) { int populationM = clusterIdList . size ( ) ; double nBar = 0.0 ; for ( Map . Entry < Object , FlatDataList > entry : clusterIdList . entrySet ( ) ) { nBar += ( double ) entry . getValue ( ) . size ( ) / populationM ; } return nBar ; }
Returns the mean cluster size .
85
6
36,920
public static TransposeDataCollection randomSampling ( TransposeDataList clusterIdList , int sampleM ) { TransposeDataCollection sampledIds = new TransposeDataCollection ( ) ; Object [ ] selectedClusters = clusterIdList . keySet ( ) . toArray ( ) ; PHPMethods . < Object > shuffle ( selectedClusters ) ; for ( int i = 0 ...
Samples m clusters by using Cluster Sampling
135
9
36,921
public static String tokenizeSmileys ( String text ) { for ( Map . Entry < String , String > smiley : SMILEYS_MAPPING . entrySet ( ) ) { text = text . replaceAll ( smiley . getKey ( ) , smiley . getValue ( ) ) ; } return text ; }
Replaces all the SMILEYS_MAPPING within the text with their tokens .
70
19
36,922
public static String unifyTerminators ( String text ) { text = text . replaceAll ( "[\",:;()\\-]+" , " " ) ; // Replace commas, hyphens, quotes etc (count them as spaces) text = text . replaceAll ( "[\\.!?]" , "." ) ; // Unify terminators text = text . replaceAll ( "\\.[\\. ]+" , "." ) ; // Check for duplicated termina...
Replaces all terminators with space or dots . The final string will contain only alphanumerics and dots .
133
23
36,923
public static String removeAccents ( String text ) { text = Normalizer . normalize ( text , Normalizer . Form . NFD ) ; text = text . replaceAll ( "[\\p{InCombiningDiacriticalMarks}]" , "" ) ; return text ; }
Removes all accepts from the text .
59
8
36,924
public static String clear ( String text ) { text = StringCleaner . tokenizeURLs ( text ) ; text = StringCleaner . tokenizeSmileys ( text ) ; text = StringCleaner . removeAccents ( text ) ; text = StringCleaner . removeSymbols ( text ) ; text = StringCleaner . removeExtraSpaces ( text ) ; return text . toLowerCase ( Lo...
Convenience method which tokenizes the URLs and the SMILEYS_MAPPING removes accents and symbols and eliminates the extra spaces from the provided text .
95
33
36,925
public static double getScoreValue ( DataTable2D dataTable ) { AssociativeArray result = getScore ( dataTable ) ; double score = result . getDouble ( "score" ) ; return score ; }
Convenience method to get the score of Chisquare .
44
14
36,926
public static LPResult solve ( double [ ] linearObjectiveFunction , List < LPSolver . LPConstraint > linearConstraintsList , boolean nonNegative , boolean maximize ) { int m = linearConstraintsList . size ( ) ; List < LinearConstraint > constraints = new ArrayList <> ( m ) ; for ( LPSolver . LPConstraint constraint : l...
Solves the LP problem and returns the result .
345
10
36,927
public final Object get2d ( Object key1 , Object key2 ) { AssociativeArray tmp = internalData . get ( key1 ) ; if ( tmp == null ) { return null ; } return tmp . internalData . get ( key2 ) ; }
Convenience function to get the value by using both keys .
54
13
36,928
public final Object put2d ( Object key1 , Object key2 , Object value ) { AssociativeArray tmp = internalData . get ( key1 ) ; if ( tmp == null ) { internalData . put ( key1 , new AssociativeArray ( ) ) ; } return internalData . get ( key1 ) . internalData . put ( key2 , value ) ; }
Convenience function used to put a value in a particular key positions .
79
15
36,929
public static String joinURL ( Map < URLParts , String > urlParts ) { try { URI uri = new URI ( urlParts . get ( URLParts . PROTOCOL ) , urlParts . get ( URLParts . AUTHORITY ) , urlParts . get ( URLParts . PATH ) , urlParts . get ( URLParts . QUERY ) , urlParts . get ( URLParts . REF ) ) ; return uri . toString ( ) ; ...
This method can be used to build a URL from its parts .
117
13
36,930
public static Map < DomainParts , String > splitDomain ( String domain ) { Map < DomainParts , String > domainParts = null ; String [ ] dottedParts = domain . trim ( ) . toLowerCase ( Locale . ENGLISH ) . split ( "\\." ) ; if ( dottedParts . length == 2 ) { domainParts = new HashMap <> ( ) ; domainParts . put ( DomainP...
Splits a domain name to parts and returns them in a map .
545
14
36,931
public static double fleschKincaidReadingEase ( String strText ) { strText = cleanText ( strText ) ; return PHPMethods . round ( ( 206.835 - ( 1.015 * averageWordsPerSentence ( strText ) ) - ( 84.6 * averageSyllablesPerWord ( strText ) ) ) , 1 ) ; }
Returns the Flesch - Kincaid Reading Ease of text entered rounded to one digit .
81
20
36,932
public static double fleschKincaidGradeLevel ( String strText ) { strText = cleanText ( strText ) ; return PHPMethods . round ( ( ( 0.39 * averageWordsPerSentence ( strText ) ) + ( 11.8 * averageSyllablesPerWord ( strText ) ) - 15.59 ) , 1 ) ; }
Returns the Flesch - Kincaid Grade level of text entered rounded to one digit .
79
19
36,933
public static double gunningFogScore ( String strText ) { strText = cleanText ( strText ) ; return PHPMethods . round ( ( ( averageWordsPerSentence ( strText ) + percentageWordsWithThreeSyllables ( strText ) ) * 0.4 ) , 1 ) ; }
Returns the Gunning - Fog score of text entered rounded to one digit .
67
15
36,934
public static double colemanLiauIndex ( String strText ) { strText = cleanText ( strText ) ; int intWordCount = wordCount ( strText ) ; return PHPMethods . round ( ( ( 5.89 * ( letterCount ( strText ) / ( double ) intWordCount ) ) - ( 0.3 * ( sentenceCount ( strText ) / ( double ) intWordCount ) ) - 15.8 ) , 1 ) ; }
Returns the Coleman - Liau Index of text entered rounded to one digit .
101
15
36,935
public static double smogIndex ( String strText ) { strText = cleanText ( strText ) ; return PHPMethods . round ( 1.043 * Math . sqrt ( ( wordsWithThreeSyllables ( strText ) * ( 30.0 / sentenceCount ( strText ) ) ) + 3.1291 ) , 1 ) ; }
Returns the SMOG Index of text entered rounded to one digit .
76
13
36,936
public static double daleChallScore ( String strText ) { strText = cleanText ( strText ) ; int intDifficultWordCount = 0 ; List < String > arrWords = ( new WhitespaceTokenizer ( ) ) . tokenize ( strText ) ; int intWordCount = arrWords . size ( ) ; for ( int i = 0 ; i < intWordCount ; ++ i ) { if ( ! DALECHALL_WORDLIST ...
Returns the Dale Chall Score of the text .
213
9
36,937
public static double daleChallGrade ( String strText ) { //http://rfptemplates.technologyevaluation.com/dale-chall-list-of-3000-simple-words.html double score = daleChallScore ( strText ) ; if ( score < 5.0 ) { return 2.5 ; } else if ( score < 6.0 ) { return 5.5 ; } else if ( score < 7.0 ) { return 7.5 ; } else if ( sc...
Returns the Dale Chall Grade of the text .
158
9
36,938
public static double spacheScore ( String strText ) { //http://simple.wikipedia.org/wiki/Spache_Readability_Formula strText = cleanText ( strText ) ; int intUniqueUnfamiliarWordCount = 0 ; Set < String > arrWords = new HashSet <> ( ( new WhitespaceTokenizer ( ) ) . tokenize ( strText ) ) ; for ( String word : arrWords ...
Returns the Spache Score of the text .
180
9
36,939
private static int sentenceCount ( String strText ) { int numberOfDots = PHPMethods . substr_count ( strText , ' ' ) ; // Will be tripped up by "Mr." or "U.K.". Not a major concern at this point. if ( strText . charAt ( strText . length ( ) - 1 ) != ' ' ) { //missing the final dot, count it too ++ numberOfDots ; } retu...
Returns sentence count for text .
111
6
36,940
private static String cleanText ( String strText ) { strText = HTMLParser . unsafeRemoveAllTags ( strText ) ; strText = strText . toLowerCase ( Locale . ENGLISH ) ; strText = StringCleaner . unifyTerminators ( strText ) ; strText = strText . replaceAll ( " [0-9]+ " , " " ) ; // Remove "words" comprised only of numbers ...
Trims removes line breaks multiple spaces and generally cleans text before processing .
111
14
36,941
private static double averageWordsPerSentence ( String strText ) { int intSentenceCount = sentenceCount ( strText ) ; int intWordCount = wordCount ( strText ) ; return ( intWordCount / ( double ) intSentenceCount ) ; }
Returns average words per sentence for text .
55
8
36,942
private static int totalSyllables ( String strText ) { int intSyllableCount = 0 ; List < String > arrWords = ( new WhitespaceTokenizer ( ) ) . tokenize ( strText ) ; int intWordCount = arrWords . size ( ) ; for ( int i = 0 ; i < intWordCount ; ++ i ) { intSyllableCount += syllableCount ( arrWords . get ( i ) ) ; } retu...
Returns total syllable count for text .
103
8
36,943
private static double averageSyllablesPerWord ( String strText ) { int intSyllableCount = totalSyllables ( strText ) ; int intWordCount = wordCount ( strText ) ; return ( intSyllableCount / ( double ) intWordCount ) ; }
Returns average syllables per word for text .
60
9
36,944
private static int wordsWithThreeSyllables ( String strText ) { int intLongWordCount = 0 ; List < String > arrWords = ( new WhitespaceTokenizer ( ) ) . tokenize ( strText ) ; int intWordCount = arrWords . size ( ) ; for ( int i = 0 ; i < intWordCount ; ++ i ) { if ( syllableCount ( arrWords . get ( i ) ) > 2 ) { ++ int...
Returns the number of words with more than three syllables .
132
12
36,945
private static double percentageWordsWithThreeSyllables ( String strText ) { int intWordCount = wordCount ( strText ) ; int intLongWordCount = wordsWithThreeSyllables ( strText ) ; double percentage = ( ( intLongWordCount / ( double ) intWordCount ) * 100.0 ) ; return percentage ; }
Returns the percentage of words with more than three syllables .
72
12
36,946
public static int similarityChars ( String txt1 , String txt2 ) { int sim = similar_char ( txt1 , txt1 . length ( ) , txt2 , txt2 . length ( ) ) ; return sim ; }
Checks the similarity of two strings and returns the number of matching chars in both strings .
54
18
36,947
public static double similarityPercentage ( String txt1 , String txt2 ) { double sim = similarityChars ( txt1 , txt2 ) ; return sim * 200.0 / ( txt1 . length ( ) + txt2 . length ( ) ) ; }
Checks the similarity of two strings and returns their similarity percentage .
60
13
36,948
public String extract ( String html , CETR . Parameters parameters ) { html = clearText ( html ) ; //preprocess the Document by removing irrelevant HTML tags and empty lines and break the document to its lines List < String > rows = extractRows ( html ) ; // List < Integer > selectedRowIds = selectRows ( rows , paramet...
Extracts the main content for an HTML page .
186
11
36,949
public static byte [ ] serialize ( Object obj ) { try ( ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( bos ) ) { oos . writeObject ( obj ) ; return bos . toByteArray ( ) ; } catch ( IOException ex ) { throw new UncheckedIOException ( ex ) ; } }
Serialized the Object to byte array .
81
8
36,950
public static Object deserialize ( byte [ ] arr ) { try ( InputStream bis = new ByteArrayInputStream ( arr ) ; ObjectInputStream ois = new ObjectInputStream ( bis ) ) { return ois . readObject ( ) ; } catch ( IOException ex ) { throw new UncheckedIOException ( ex ) ; } catch ( ClassNotFoundException ex ) { throw new Ru...
Deserializes the byte array .
90
7
36,951
public static AssociativeArray copy2Unmodifiable ( AssociativeArray original ) { Map < Object , Object > internalData = new LinkedHashMap <> ( ) ; internalData . putAll ( original . internalData ) ; internalData = Collections . unmodifiableMap ( internalData ) ; return new AssociativeArray ( internalData ) ; }
Copies the provided AssociativeArray and builds a new which is unmodifiable .
73
17
36,952
public final void overwrite ( Map < Object , Object > data ) { internalData . clear ( ) ; internalData . putAll ( data ) ; }
Overwrites the contents of the internal data of this object with the ones of the provided map .
31
20
36,953
public final void multiplyValues ( double multiplier ) { for ( Map . Entry < Object , Object > entry : internalData . entrySet ( ) ) { Double previousValue = TypeInference . toDouble ( entry . getValue ( ) ) ; if ( previousValue == null ) { continue ; } internalData . put ( entry . getKey ( ) , previousValue * multipli...
Multiplies the values of the object with a particular multiplier . All the columns of this object should be numeric or boolean or else an exception is thrown .
81
31
36,954
@ SuppressWarnings ( "unchecked" ) public FlatDataList toFlatDataList ( ) { Collection < Object > values = internalData . values ( ) ; List < Object > list ; if ( values instanceof List < ? > ) { list = ( List < Object > ) values ; } else { list = new ArrayList ( values ) ; } return new FlatDataList ( list ) ; }
Returns a FlatDataList with the values of the internal map . The method might require to copy the data .
87
22
36,955
public void save ( String storageName ) { //store the objects on storage storageEngine . saveObject ( "data" , data ) ; //rename the storage storageEngine . rename ( storageName ) ; //reload the data of the object data = storageEngine . loadObject ( "data" , Data . class ) ; //mark it as stored stored = true ; }
Saves the Dataframe to disk .
77
8
36,956
@ Override public void clear ( ) { data . yDataType = null ; data . atomicNextAvailableRecordId . set ( 0 ) ; data . xDataTypes . clear ( ) ; data . records . clear ( ) ; }
Clears all the internal Records of the Dataframe . The Dataframe can be used after you clear it .
49
22
36,957
@ Override public boolean remove ( Object o ) { Integer id = indexOf ( ( Record ) o ) ; if ( id == null ) { return false ; } remove ( id ) ; return true ; }
Removes the first occurrence of the specified element from this Dataframe if it is present and it does not update the metadata .
43
25
36,958
@ Override public boolean retainAll ( Collection < ? > c ) { boolean modified = false ; for ( Map . Entry < Integer , Record > e : entries ( ) ) { Integer rId = e . getKey ( ) ; Record r = e . getValue ( ) ; if ( ! c . contains ( r ) ) { remove ( rId ) ; modified = true ; } } if ( modified ) { recalculateMeta ( ) ; } r...
Retains only the elements in this collection that are contained in the specified collection and updates the meta data .
98
21
36,959
public Integer addRecord ( Record r ) { Integer rId = _unsafe_add ( r ) ; updateMeta ( r ) ; return rId ; }
Adds a Record in the Dataframe and returns its id .
33
12
36,960
public Integer set ( Integer rId , Record r ) { _unsafe_set ( rId , r ) ; updateMeta ( r ) ; return rId ; }
Sets the record of a particular id in the dataset . If the record does not exist it will be added with the specific id and the next added record will have as id the next integer .
35
39
36,961
public FlatDataList getXColumn ( Object column ) { FlatDataList flatDataList = new FlatDataList ( ) ; for ( Record r : values ( ) ) { flatDataList . add ( r . getX ( ) . get ( column ) ) ; } return flatDataList ; }
It extracts the values of a particular column from all records and stores them into an FlatDataList .
62
20
36,962
public FlatDataList getYColumn ( ) { FlatDataList flatDataList = new FlatDataList ( ) ; for ( Record r : values ( ) ) { flatDataList . add ( r . getY ( ) ) ; } return flatDataList ; }
It extracts the values of the response variables from all observations and stores them into an FlatDataList .
55
20
36,963
public void dropXColumns ( Set < Object > columnSet ) { columnSet . retainAll ( data . xDataTypes . keySet ( ) ) ; //keep only those columns that are already known to the Meta data of the Dataframe if ( columnSet . isEmpty ( ) ) { return ; } //remove all the columns from the Meta data data . xDataTypes . keySet ( ) . r...
Removes completely a list of columns from the dataset . The meta - data of the Dataframe are updated . The method internally uses threads .
251
28
36,964
public Dataframe getSubset ( FlatDataList idsCollection ) { Dataframe d = new Dataframe ( configuration ) ; for ( Object id : idsCollection ) { d . add ( get ( ( Integer ) id ) ) ; } return d ; }
It generates and returns a new Dataframe which contains a subset of this Dataframe . All the Records of the returned Dataframe are copies of the original Records . The method is used for k - fold cross validation and sampling . Note that the Records in the new Dataframe have DIFFERENT ids from the original ones .
54
66
36,965
public void recalculateMeta ( ) { data . yDataType = null ; data . xDataTypes . clear ( ) ; for ( Record r : values ( ) ) { updateMeta ( r ) ; } }
It forces the recalculation of Meta data using the Records of the dataset .
45
15
36,966
public Iterable < Map . Entry < Integer , Record > > entries ( ) { return ( ) -> new Iterator < Map . Entry < Integer , Record > > ( ) { private final Iterator < Map . Entry < Integer , Record > > it = data . records . entrySet ( ) . iterator ( ) ; /** {@inheritDoc} */ @ Override public boolean hasNext ( ) { return it ...
Returns a read - only Iterable on the keys and Records of the Dataframe .
173
17
36,967
public Iterable < Integer > index ( ) { return ( ) -> new Iterator < Integer > ( ) { private final Iterator < Integer > it = data . records . keySet ( ) . iterator ( ) ; /** {@inheritDoc} */ @ Override public boolean hasNext ( ) { return it . hasNext ( ) ; } /** {@inheritDoc} */ @ Override public Integer next ( ) { ret...
Returns a read - only Iterable on the keys of the Dataframe .
145
15
36,968
public Iterable < Record > values ( ) { return ( ) -> new Iterator < Record > ( ) { private final Iterator < Record > it = data . records . values ( ) . iterator ( ) ; /** {@inheritDoc} */ @ Override public boolean hasNext ( ) { return it . hasNext ( ) ; } /** {@inheritDoc} */ @ Override public Record next ( ) { return...
Returns a read - only Iterable on the values of the Dataframe .
144
15
36,969
private Integer _unsafe_add ( Record r ) { Integer newId = data . atomicNextAvailableRecordId . getAndIncrement ( ) ; data . records . put ( newId , r ) ; return newId ; }
Adds the record in the dataset without updating the Meta . The add method returns the id of the new record .
48
22
36,970
private void updateMeta ( Record r ) { for ( Map . Entry < Object , Object > entry : r . getX ( ) . entrySet ( ) ) { Object column = entry . getKey ( ) ; Object value = entry . getValue ( ) ; if ( value != null ) { data . xDataTypes . putIfAbsent ( column , TypeInference . getDataType ( value ) ) ; } } if ( data . yDat...
Updates the meta data of the Dataframe using the provided Record . The Meta - data include the supported columns and their DataTypes .
141
27
36,971
public static AssociativeArray normalDistributionGetParams ( FlatDataCollection flatDataCollection ) { AssociativeArray params = new AssociativeArray ( ) ; params . put ( "mean" , Descriptives . mean ( flatDataCollection ) ) ; params . put ( "variance" , Descriptives . variance ( flatDataCollection , true ) ) ; return ...
Estimate Parameters of Normal based on Sample . This method is called via reflection .
79
16
36,972
public static < C extends Configurable > C getConfiguration ( Class < C > klass ) { String defaultPropertyFile = "datumbox." + klass . getSimpleName ( ) . toLowerCase ( Locale . ENGLISH ) + DEFAULT_POSTFIX + ".properties" ; Properties properties = new Properties ( ) ; ClassLoader cl = klass . getClassLoader ( ) ; //Loa...
Initializes the Configuration Object based on the configuration file .
280
11
36,973
public static < C extends Configurable > C getConfiguration ( Class < C > klass , Properties properties ) { //Initialize configuration object C configuration ; try { Constructor < C > constructor = klass . getDeclaredConstructor ( ) ; constructor . setAccessible ( true ) ; configuration = constructor . newInstance ( ) ...
Initializes the Configuration Object using a properties object .
120
10
36,974
public static double getPvalue ( TransposeDataList transposeDataList ) { Object [ ] keys = transposeDataList . keySet ( ) . toArray ( ) ; if ( keys . length != 2 ) { throw new IllegalArgumentException ( "The collection must contain observations from 2 groups." ) ; } Object keyX = keys [ 0 ] ; Object keyY = keys [ 1 ] ;...
Estimates the p - value of the sign test for the provided data .
274
15
36,975
public static double calculateCorrelation ( TransposeDataList transposeDataList ) { Object [ ] keys = transposeDataList . keySet ( ) . toArray ( ) ; if ( keys . length != 2 ) { throw new IllegalArgumentException ( "The collection must contain observations from 2 groups." ) ; } Object keyX = keys [ 0 ] ; Object keyY = k...
Estimates Spearman s Correlation for the provided data .
578
12
36,976
private static double scoreToPvalue ( double score , int n ) { double Zs = score * Math . sqrt ( n - 1.0 ) ; double Ts = score * Math . sqrt ( ( n - Zs ) / ( 1.0 - score * score ) ) ; return ContinuousDistributions . studentsCdf ( Ts , n - 2 ) ; }
Returns the Pvalue for a particular score .
79
9
36,977
public static P create ( String ... texts ) { P p = objectFactory . createP ( ) ; for ( String text : texts ) { R r = RunUtil . create ( text , p ) ; p . getContent ( ) . add ( r ) ; } return p ; }
Creates a new paragraph .
60
6
36,978
public Object resolveExpression ( String expressionString , Object contextRoot ) { if ( ( expressionString . startsWith ( "${" ) || expressionString . startsWith ( "#{" ) ) && expressionString . endsWith ( "}" ) ) { expressionString = expressionUtil . stripExpression ( expressionString ) ; } ExpressionParser parser = n...
Runs the given expression against the given context object and returns the result of the evaluated expression .
137
19
36,979
public < T > void runProcessors ( final WordprocessingMLPackage document , final ProxyBuilder < T > proxyBuilder ) { final Map < BigInteger , CommentWrapper > comments = CommentUtil . getComments ( document ) ; CoordinatesWalker walker = new BaseCoordinatesWalker ( document ) { @ Override protected void onParagraph ( P...
Lets each registered ICommentProcessor have a run on the specified docx document . At the end of the document the commit method is called for each ICommentProcessor . The ICommentProcessors are run in the order they were registered .
212
50
36,980
public ProxyBuilder < T > withInterface ( Class < ? > interfaceClass , Object interfaceImpl ) { this . interfacesToImplementations . put ( interfaceClass , interfaceImpl ) ; return this ; }
Specifies an interfaces and an implementation of an interface by which the root object shall be extended .
42
19
36,981
public T build ( ) throws ProxyException { if ( this . root == null ) { throw new IllegalArgumentException ( "root must not be null!" ) ; } if ( this . interfacesToImplementations . isEmpty ( ) ) { // nothing to proxy return this . root ; } try { ProxyMethodHandler methodHandler = new ProxyMethodHandler ( root , interf...
Creates a proxy object out of the specified root object and the specified interfaces and implementations .
181
18
36,982
public static Comments . Comment getCommentAround ( R run , WordprocessingMLPackage document ) { try { if ( run instanceof Child ) { Child child = ( Child ) run ; ContentAccessor parent = ( ContentAccessor ) child . getParent ( ) ; if ( parent == null ) return null ; CommentRangeStart possibleComment = null ; boolean f...
Returns the comment the given DOCX4J run is commented with .
400
14
36,983
public static Comments . Comment getCommentFor ( ContentAccessor object , WordprocessingMLPackage document ) { try { for ( Object contentObject : object . getContent ( ) ) { if ( contentObject instanceof CommentRangeStart ) { try { BigInteger id = ( ( CommentRangeStart ) contentObject ) . getId ( ) ; CommentsPart comme...
Returns the first comment found for the given docx object . Note that an object is only considered commented if the comment STARTS within the object . Comments spanning several objects are not supported by this method .
224
40
36,984
public static String getCommentString ( Comments . Comment comment ) { StringBuilder builder = new StringBuilder ( ) ; for ( Object commentChildObject : comment . getContent ( ) ) { if ( commentChildObject instanceof P ) { builder . append ( new ParagraphWrapper ( ( P ) commentChildObject ) . getText ( ) ) ; } } return...
Returns the string value of the specified comment object .
83
10
36,985
public static String getText ( R run ) { String result = "" ; for ( Object content : run . getContent ( ) ) { if ( content instanceof JAXBElement ) { JAXBElement element = ( JAXBElement ) content ; if ( element . getValue ( ) instanceof Text ) { Text textObj = ( Text ) element . getValue ( ) ; String text = textObj . g...
Returns the text string of a run .
212
8
36,986
public static void setText ( R run , String text ) { run . getContent ( ) . clear ( ) ; Text textObj = factory . createText ( ) ; textObj . setSpace ( "preserve" ) ; textObj . setValue ( text ) ; textObj . setSpace ( "preserve" ) ; // make the text preserve spaces run . getContent ( ) . add ( textObj ) ; }
Sets the text of the given run to the given value .
88
13
36,987
public static R create ( String text ) { R run = factory . createR ( ) ; setText ( run , text ) ; return run ; }
Creates a new run with the specified text .
31
10
36,988
public static R create ( Object content ) { R run = factory . createR ( ) ; run . getContent ( ) . add ( content ) ; return run ; }
Creates a new run with the given object as content .
35
12
36,989
public static R create ( String text , P parentParagraph ) { R run = create ( text ) ; applyParagraphStyle ( parentParagraph , run ) ; return run ; }
Creates a new run with the specified text and inherits the style of the parent paragraph .
38
19
36,990
public DocxStamperConfiguration addCommentProcessor ( Class < ? > interfaceClass , ICommentProcessor commentProcessor ) { this . commentProcessors . put ( interfaceClass , commentProcessor ) ; return this ; }
Registers the specified ICommentProcessor as an implementation of the specified interface .
48
16
36,991
public DocxStamperConfiguration exposeInterfaceToExpressionLanguage ( Class < ? > interfaceClass , Object implementation ) { this . expressionFunctions . put ( interfaceClass , implementation ) ; return this ; }
Exposes all methods of a given interface to the expression language .
43
13
36,992
public < T > ITypeResolver getResolverForType ( Class < T > type ) { ITypeResolver resolver = typeResolversByType . get ( type ) ; if ( resolver == null ) { return defaultResolver ; } else { return resolver ; } }
Gets the ITypeResolver that was registered for the specified type .
62
15
36,993
private void addRun ( R run , int index ) { int startIndex = currentPosition ; int endIndex = currentPosition + RunUtil . getText ( run ) . length ( ) - 1 ; runs . add ( new IndexedRun ( startIndex , endIndex , index , run ) ) ; currentPosition = endIndex + 1 ; }
Adds a run to the aggregation .
72
7
36,994
public List < R > getRuns ( ) { List < R > resultList = new ArrayList <> ( ) ; for ( IndexedRun run : runs ) { resultList . add ( run . getRun ( ) ) ; } return resultList ; }
Returns the list of runs that are aggregated . Depending on what modifications were done to the aggregated text this list may not return the same runs that were initially added to the aggregator .
55
38
36,995
public boolean isTouchedByRange ( int globalStartIndex , int globalEndIndex ) { return ( ( startIndex >= globalStartIndex ) && ( startIndex <= globalEndIndex ) ) || ( ( endIndex >= globalStartIndex ) && ( endIndex <= globalEndIndex ) ) || ( ( startIndex <= globalStartIndex ) && ( endIndex >= globalEndIndex ) ) ; }
Determines whether the specified range of start and end index touches this run .
81
16
36,996
public void replace ( int globalStartIndex , int globalEndIndex , String replacement ) { int localStartIndex = globalIndexToLocalIndex ( globalStartIndex ) ; int localEndIndex = globalIndexToLocalIndex ( globalEndIndex ) ; String text = RunUtil . getText ( run ) ; text = text . substring ( 0 , localStartIndex ) ; text ...
Replaces the substring starting at the given index with the given replacement string .
143
16
36,997
public void resolveExpressions ( final WordprocessingMLPackage document , ProxyBuilder < T > proxyBuilder ) { try { final T expressionContext = proxyBuilder . build ( ) ; CoordinatesWalker walker = new BaseCoordinatesWalker ( document ) { @ Override protected void onParagraph ( ParagraphCoordinates paragraphCoordinates...
Finds expressions in a document and resolves them against the specified context object . The expressions in the document are then replaced by the resolved values .
138
28
36,998
@ Override protected void onScrollChanged ( int l , int t , int oldl , int oldt ) { super . onScrollChanged ( l , t , oldl , oldt ) ; if ( mTrackedChild == null ) { if ( getChildCount ( ) > 0 ) { mTrackedChild = getChildInTheMiddle ( ) ; mTrackedChildPrevTop = mTrackedChild . getTop ( ) ; mTrackedChildPrevPosition = ge...
Calculate the scroll distance comparing the distance with the top of the list of the current child and the last one tracked
281
24
36,999
public static String of ( String [ ] headers , String [ ] [ ] data ) { if ( headers == null ) throw new NullPointerException ( "headers == null" ) ; if ( headers . length == 0 ) throw new IllegalArgumentException ( "Headers must not be empty." ) ; if ( data == null ) throw new NullPointerException ( "data == null" ) ; ...
Create a new table with the specified headers and row data .
99
12