idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
20,200
void setWeight ( Token tok , double d ) { Double oldWeight = ( Double ) weightMap . get ( tok ) ; totalWeight += oldWeight == null ? d : ( d - oldWeight . doubleValue ( ) ) ; weightMap . put ( tok , new Double ( d ) ) ; }
Change the weight of a token in the bag
66
9
20,201
public StringArray getAcList ( ) { if ( DBInfo_Type . featOkTst && ( ( DBInfo_Type ) jcasType ) . casFeat_acList == null ) jcasType . jcas . throwFeatMissing ( "acList" , "de.julielab.jules.types.DBInfo" ) ; return ( StringArray ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DBInfo_Type ) jcasType ) . casFeatCode_acList ) ) ) ; }
getter for acList - gets A list of accession numbers for this DB C
138
17
20,202
public void setAcList ( StringArray v ) { if ( DBInfo_Type . featOkTst && ( ( DBInfo_Type ) jcasType ) . casFeat_acList == null ) jcasType . jcas . throwFeatMissing ( "acList" , "de.julielab.jules.types.DBInfo" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( DBInfo_Type ) jcasType ) . casFeatCode_acList , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for acList - sets A list of accession numbers for this DB C
134
17
20,203
public String getAcList ( int i ) { if ( DBInfo_Type . featOkTst && ( ( DBInfo_Type ) jcasType ) . casFeat_acList == null ) jcasType . jcas . throwFeatMissing ( "acList" , "de.julielab.jules.types.DBInfo" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DBInfo_Type ) jcasType ) . casFeatCode_acList ) , i ) ; return jcasType . ll_cas . ll_getStringArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DBInfo_Type ) jcasType ) . casFeatCode_acList ) , i ) ; }
indexed getter for acList - gets an indexed value - A list of accession numbers for this DB C
187
23
20,204
public void setAcList ( int i , String v ) { if ( DBInfo_Type . featOkTst && ( ( DBInfo_Type ) jcasType ) . casFeat_acList == null ) jcasType . jcas . throwFeatMissing ( "acList" , "de.julielab.jules.types.DBInfo" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DBInfo_Type ) jcasType ) . casFeatCode_acList ) , i ) ; jcasType . ll_cas . ll_setStringArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DBInfo_Type ) jcasType ) . casFeatCode_acList ) , i , v ) ; }
indexed setter for acList - sets an indexed value - A list of accession numbers for this DB C
191
23
20,205
public int getDay ( ) { if ( Date_Type . featOkTst && ( ( Date_Type ) jcasType ) . casFeat_day == null ) jcasType . jcas . throwFeatMissing ( "day" , "de.julielab.jules.types.Date" ) ; return jcasType . ll_cas . ll_getIntValue ( addr , ( ( Date_Type ) jcasType ) . casFeatCode_day ) ; }
getter for day - gets day of the month C
107
11
20,206
public void setDay ( int v ) { if ( Date_Type . featOkTst && ( ( Date_Type ) jcasType ) . casFeat_day == null ) jcasType . jcas . throwFeatMissing ( "day" , "de.julielab.jules.types.Date" ) ; jcasType . ll_cas . ll_setIntValue ( addr , ( ( Date_Type ) jcasType ) . casFeatCode_day , v ) ; }
setter for day - sets day of the month C
110
11
20,207
public int getMonth ( ) { if ( Date_Type . featOkTst && ( ( Date_Type ) jcasType ) . casFeat_month == null ) jcasType . jcas . throwFeatMissing ( "month" , "de.julielab.jules.types.Date" ) ; return jcasType . ll_cas . ll_getIntValue ( addr , ( ( Date_Type ) jcasType ) . casFeatCode_month ) ; }
getter for month - gets month of the year C
107
11
20,208
public void setMonth ( int v ) { if ( Date_Type . featOkTst && ( ( Date_Type ) jcasType ) . casFeat_month == null ) jcasType . jcas . throwFeatMissing ( "month" , "de.julielab.jules.types.Date" ) ; jcasType . ll_cas . ll_setIntValue ( addr , ( ( Date_Type ) jcasType ) . casFeatCode_month , v ) ; }
setter for month - sets month of the year C
110
11
20,209
public Double averagePrecision ( ) { double n = 0 ; double sumPrecision = 0 ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( correctPair ( i ) ) { n ++ ; double precisionAtRankI = n / ( i + 1.0 ) ; sumPrecision += precisionAtRankI ; } } return new Double ( sumPrecision / numCorrectPairs ) ; }
non - interpolated average precision
92
6
20,210
public Double maxF1 ( ) { double maxF1 = - Double . MAX_VALUE ; double n = 0 ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( correctPair ( i ) ) { n ++ ; double precisionAtRankI = n / ( i + 1.0 ) ; double recallAtRankI = n / numCorrectPairs ; if ( precisionAtRankI > 0 && recallAtRankI > 0 ) { double f1 = 2 * ( precisionAtRankI * recallAtRankI ) / ( precisionAtRankI + recallAtRankI ) ; maxF1 = Math . max ( f1 , maxF1 ) ; } } } return new Double ( maxF1 ) ; }
max F1 for any threshold
160
6
20,211
public Double blockerRecall ( ) { double n = 0 ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( correctPair ( i ) ) { n ++ ; } } return new Double ( n / numCorrectPairs ) ; }
performance of the blocker
58
4
20,212
public double [ ] interpolated11PointPrecision ( ) { double [ ] interpolatedPrecision = new double [ 11 ] ; int numCorrectAtRankI = 0 ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( correctPair ( i ) ) ++ numCorrectAtRankI ; double recall = numCorrectAtRankI / ( ( double ) numCorrectPairs ) ; double precision = numCorrectAtRankI / ( i + 1.0 ) ; for ( int j = 0 ; j < elevenPoints . length ; j ++ ) { if ( recall >= elevenPoints [ j ] ) { interpolatedPrecision [ j ] = Math . max ( interpolatedPrecision [ j ] , precision ) ; } } } return interpolatedPrecision ; }
Return an array of interpolated precision at various different recall levels .
167
13
20,213
public void graphPrecisionRecall ( PrintStream out ) throws IOException { /** find interpolated precision - max precision at any rank point after i */ double [ ] interpolatedPrecision = new double [ pairs . length ] ; double n = numCorrectPairs ; double maxPrecision = n / pairs . length ; for ( int i = pairs . length - 1 ; i >= 0 ; i -- ) { if ( correctPair ( i ) ) { interpolatedPrecision [ i ] = maxPrecision ; n -- ; maxPrecision = Math . max ( maxPrecision , n / ( i + 1 ) ) ; } } /** plot points on the graph */ n = 0 ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( correctPair ( i ) ) { n ++ ; double recallAtRankI = n / numCorrectPairs ; out . println ( recallAtRankI + "\t" + interpolatedPrecision [ i ] ) ; } } }
Graph interpolated precision vs recall
212
6
20,214
public void displayResults ( boolean showMismatches , PrintStream out ) throws IOException { PrintfFormat fmt = new PrintfFormat ( "%s %3d %7.2f | %30s | %30s\n" ) ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( pairs [ i ] != null ) { String label = pairs [ i ] . isCorrect ( ) ? "+" : "-" ; String aText = ( pairs [ i ] . getA ( ) == null ) ? "***" : pairs [ i ] . getA ( ) . unwrap ( ) ; String bText = ( pairs [ i ] . getB ( ) == null ) ? "***" : pairs [ i ] . getB ( ) . unwrap ( ) ; if ( showMismatches || "+" . equals ( label ) ) { out . print ( fmt . sprintf ( new Object [ ] { label , new Integer ( i + 1 ) , new Double ( pairs [ i ] . getDistance ( ) ) , aText , bText } ) ) ; } } } }
Show results in a simple format .
239
7
20,215
public void dumpResults ( PrintStream out ) throws IOException { PrintfFormat fmt = new PrintfFormat ( "%7.2f\t%s\t%s\n" ) ; for ( int i = 0 ; i < pairs . length ; i ++ ) { if ( pairs [ i ] != null ) { String aText = ( pairs [ i ] . getA ( ) == null ) ? "***" : pairs [ i ] . getA ( ) . unwrap ( ) ; String bText = ( pairs [ i ] . getB ( ) == null ) ? "***" : pairs [ i ] . getB ( ) . unwrap ( ) ; out . print ( fmt . sprintf ( new Object [ ] { new Double ( pairs [ i ] . getDistance ( ) ) , aText , bText } ) ) ; } } }
Show results in an easily machine - readable format .
182
10
20,216
public static void main ( String [ ] args ) throws IOException { ch . epfl . bbp . shaded . opennlp . maxent . GISModel m = new SuffixSensitiveGISModelReader ( new File ( args [ 0 ] ) ) . getModel ( ) ; new SuffixSensitiveGISModelWriter ( m , new File ( args [ 1 ] ) ) . persist ( ) ; }
To convert between different formats of the new style .
89
10
20,217
private boolean unknownByPDFExtractor ( ArrayList < ArrayList < TextPiece > > wordsByPage ) { ArrayList < TextPiece > wordsOfPageOne = wordsByPage . get ( 0 ) ; boolean isUnknownCode = false ; int i = 0 ; float codeSize = 0.0f ; while ( i < wordsOfPageOne . size ( ) ) { codeSize = codeSize + Math . max ( wordsOfPageOne . get ( i ) . getXScale ( ) , wordsOfPageOne . get ( i ) . getFontSize ( ) ) ; i ++ ; } codeSize = codeSize / ( float ) wordsOfPageOne . size ( ) ; if ( codeSize <= 1.2 ) isUnknownCode = true ; return ( isUnknownCode ) ; }
Detects PDF documents encoded in unknown codes
167
8
20,218
private Vector getDistinctSortedY ( Vector distinctY , Vector piecesEachY , ArrayList < TextPiece > wordsOfAPage , TableCandidate tc ) { int pieceNumThisPage = wordsOfAPage . size ( ) ; float x_columnToGetYs = m_docInfo . getMinX ( ) ; float endX_columnToGetYs = m_docInfo . getMiddleX ( ) ; if ( ( tc . isWideTable ( ) == false ) && ( tc . getCaptionX ( ) >= m_docInfo . getMiddleX ( ) ) ) { x_columnToGetYs = m_docInfo . getMiddleX ( ) ; endX_columnToGetYs = m_docInfo . getMaxX ( ) ; } float [ ] sortY = new float [ pieceNumThisPage ] ; for ( int bb = 0 ; bb < pieceNumThisPage ; bb ++ ) { if ( ( wordsOfAPage . get ( bb ) . getX ( ) >= x_columnToGetYs ) && ( wordsOfAPage . get ( bb ) . getEndX ( ) <= endX_columnToGetYs ) ) { sortY [ bb ] = wordsOfAPage . get ( bb ) . getY ( ) ; } } Arrays . sort ( sortY ) ; int bb = 0 ; float lastY = 0.0f ; while ( bb < pieceNumThisPage ) { if ( distinctY . size ( ) > 0 ) lastY = ( ( Float ) distinctY . lastElement ( ) ) . floatValue ( ) ; if ( ( sortY [ bb ] - lastY ) >= m_docInfo . getAverageLineGap ( ) / 2.0 ) distinctY . addElement ( new Float ( sortY [ bb ] ) ) ; bb ++ ; } return distinctY ; }
We do not sort the text pieces according to Y values in the WHOLE page because if a document contains more than one column and the table is within one document column this action will bring the text pieces in other document columns as noise texts . By default we sort Y coordinate values based on the text pieces in the left part of the page If we find a table is not a wide table and located in the right part we only process the right half of the page
413
92
20,219
private String getMatchedTabledKeyword ( String line ) { for ( String keyword : Config . TABLE_KEYWORDS ) { if ( line . startsWith ( keyword ) ) { return keyword ; } } return null ; }
Checks and returns the table caption keyword at the beginning of a give line
48
15
20,220
private String getMatchedFigureKeyword ( String line ) { for ( String keyword : Config . FIGURE_KEYWORDS ) { if ( line . startsWith ( keyword ) ) { return keyword ; } } return null ; }
Checks and returns the figure caption keyword at the beginning of a give line
48
15
20,221
private void findFootnoteBeginRow ( TableCandidate tc ) { for ( int i = 0 ; i < tc . getRows ( ) . size ( ) ; i ++ ) { TableRow row = tc . getRows ( ) . get ( i ) ; TextPiece firstCell = row . getCells ( ) . get ( 0 ) ; String text = firstCell . getText ( ) ; if ( text . startsWith ( "*" ) || text . startsWith ( "t " ) || text . startsWith ( "$" ) || text . startsWith ( "?" ) || text . startsWith ( "''" ) || text . startsWith ( "Note:" ) || ( text . startsWith ( "a" ) && i >= tc . getRows ( ) . size ( ) - 2 && row . isSuperScriptRow ( ) ) ) { tc . setFootnoteBeginRow ( i ) ; break ; } } if ( tc . getFootnoteBeginRow ( ) == - 1 ) tc . setFootnoteBeginRow ( tc . getRows ( ) . size ( ) ) ; }
Finds the first line of the potential table footnote
232
10
20,222
private void determineFootnoteHeading ( TableCandidate tc ) { /* * Gets the maximal column number based on all table rows before footnote */ int maxColumnNum = 0 ; for ( int i = 0 ; i < tc . getFootnoteBeginRow ( ) ; i ++ ) { TableRow row = tc . getRows ( ) . get ( i ) ; if ( row . getCells ( ) . size ( ) > maxColumnNum ) { maxColumnNum = row . getCells ( ) . size ( ) ; } } tc . setMaxColumnNumber ( maxColumnNum ) ; /* * Counts the number of table column heading lines * TODO: this heading finding algorithm should be improved */ int headingLineNumber = 0 ; for ( int i = 0 ; i < tc . getFootnoteBeginRow ( ) ; i ++ ) { TableRow row = tc . getRows ( ) . get ( i ) ; if ( row . getCells ( ) . size ( ) < maxColumnNum ) { headingLineNumber ++ ; } else break ; } /* * Based on observation, usually we have missing cells, especially happen in the first column */ if ( headingLineNumber > 0 ) headingLineNumber -- ; tc . setHeadingLineNumber ( Math . max ( 0 , headingLineNumber ) ) ; }
Adjusts the table heading rows and footnote rows
274
9
20,223
public void getTableStructure ( int cc , TableCandidate tc , ArrayList < TextPiece > wordsOfAPage ) { float minGapBtwColumns = 1000.0f ; float [ ] leftX_tableColumns = tc . getLeftX_tableColumns ( ) ; float [ ] rightX_tableColumns = tc . getRightX_tableColumns ( ) ; int YNum = tc . getRows ( ) . size ( ) ; for ( int zz = 1 ; zz < cc ; zz ++ ) { float thisColumnGap = leftX_tableColumns [ zz ] - rightX_tableColumns [ zz - 1 ] ; if ( thisColumnGap < minGapBtwColumns ) minGapBtwColumns = thisColumnGap ; } double columnGapThreshold = 0.0 ; //if (withoutKwd==true) columnGapThreshold = parameters.ave_X_Gap_inLine*1.6; if ( minGapBtwColumns > columnGapThreshold ) { getEachCellContent ( YNum , cc , tc ) ; getRealHeadingBasedOnCells ( YNum , cc , tc ) ; getColumnHeading ( tc ) ; getRowHeadingBasedOnCells ( tc ) ; tc . setMetadataStructureLevel ( YNum , cc , wordsOfAPage , m_docInfo ) ; //tc.setMetaStructureLevelx(YNum, cc, wordsOfAPage, m_docInfo); if ( ( tc . getFootnoteBeginRow ( ) > 1 ) & ( tc . getMaxColumnNumber ( ) > 1 ) ) { } else tc . setValid ( false ) ; } else { m_docInfo . setErrorMsg ( "Although we detected some tabular structures in page " + ( tc . getPageId_thisTable ( ) + 1 ) + ", we do not treat them as tables because the space gaps between columns are not large enough." ) ; } }
Implements the table structure decomposition step
439
9
20,224
public void getRealHeadingBasedOnCells ( int YNum , int cc , TableCandidate tc ) { int footnoteLineIndex = tc . getFootnoteBeginRow ( ) ; String [ ] [ ] cells = tc . getCells ( ) ; int i = 0 ; while ( i < footnoteLineIndex ) { int j = 0 , nonNullCellNum = 0 ; while ( j < cc ) { if ( cells [ i ] [ j ] == "" ) { break ; } nonNullCellNum ++ ; j ++ ; } if ( nonNullCellNum == cc ) break ; else i ++ ; } /* * if the next row contain unit symbols, this row has a very large possibility to be a table column heading row */ if ( ( i + 1 ) < footnoteLineIndex ) { boolean hasUnitSymbols = false ; int j = 0 ; while ( j < cc ) { if ( ( cells [ i + 1 ] [ j ] . indexOf ( "/yg rnI--" ) > 0 ) || ( cells [ i + 1 ] [ j ] . indexOf ( "(%)" ) > 0 ) || ( cells [ i + 1 ] [ j ] . indexOf ( "w-'" ) > 0 ) || ( cells [ i + 1 ] [ j ] . indexOf ( "CLg g-'" ) > 0 ) || ( cells [ i + 1 ] [ j ] . indexOf ( "pg ml-1" ) >= 0 ) ) { i ++ ; break ; } j ++ ; } } /* * Based on observation, the column heading rows always contain missing cells. * But the first data row always does not contain missing cell */ if ( i == YNum ) i = 0 ; if ( i > 0 ) i -- ; tc . setHeadingLineNumber ( i ) ; }
Adjusts the real table heading rows based on the cell information
382
12
20,225
public void getColumnHeading ( TableCandidate tc ) { int headings = tc . getHeadingLineNumber ( ) ; String [ ] [ ] cells = tc . getCells ( ) ; String columnHeadings = "" ; for ( int i = 0 ; i <= headings ; i ++ ) { int j = cells [ i ] . length ; for ( int k = 0 ; k < j ; k ++ ) { cells [ i ] [ k ] = tc . replaceAllSpecialChracters ( cells [ i ] [ k ] ) ; columnHeadings = columnHeadings + cells [ i ] [ k ] + "; " ; } columnHeadings = columnHeadings + "\n" ; } tc . setColumnHeadings ( columnHeadings ) ; }
Gets the table column headings
163
7
20,226
private void addEvents ( String sentence ) { String [ ] parts = sentence . split ( " " ) ; String outcome = NameFinderME . OTHER ; List toks = new ArrayList ( ) ; List outcomes = new ArrayList ( ) ; for ( int pi = 0 , pl = parts . length ; pi < pl ; pi ++ ) { if ( parts [ pi ] . equals ( "<START>" ) ) { outcome = NameFinderME . START ; } else if ( parts [ pi ] . equals ( "<END>" ) ) { outcome = NameFinderME . OTHER ; } else { //regular token toks . add ( parts [ pi ] ) ; outcomes . add ( outcome ) ; if ( outcome . equals ( NameFinderME . START ) ) { outcome = NameFinderME . CONTINUE ; } } } events = new Event [ toks . size ( ) ] ; for ( int ti = 0 , tl = toks . size ( ) ; ti < tl ; ti ++ ) { events [ ti ] = new Event ( ( String ) outcomes . get ( ti ) , cg . getContext ( ti , toks , outcomes , prevTags ) ) ; } for ( int ti = 0 , tl = toks . size ( ) ; ti < tl ; ti ++ ) { prevTags . put ( toks . get ( ti ) , outcomes . get ( ti ) ) ; } }
Adds name events for the specified sentence .
300
8
20,227
public java . util . List < ObjectId > getObjectId ( ) { if ( objectId == null ) { objectId = new ArrayList < ObjectId > ( ) ; } return this . objectId ; }
Gets the value of the objectId property .
45
10
20,228
public java . util . List < Caption > getCaption ( ) { if ( caption == null ) { caption = new ArrayList < Caption > ( ) ; } return this . caption ; }
Gets the value of the caption property .
40
9
20,229
public java . util . List < Object > getAltTextOrLongDescOrEmail ( ) { if ( altTextOrLongDescOrEmail == null ) { altTextOrLongDescOrEmail = new ArrayList < Object > ( ) ; } return this . altTextOrLongDescOrEmail ; }
Gets the value of the altTextOrLongDescOrEmail property .
63
15
20,230
public java . util . List < Object > getDispFormulaOrDispFormulaGroupOrChemStructWrap ( ) { if ( dispFormulaOrDispFormulaGroupOrChemStructWrap == null ) { dispFormulaOrDispFormulaGroupOrChemStructWrap = new ArrayList < Object > ( ) ; } return this . dispFormulaOrDispFormulaGroupOrChemStructWrap ; }
Gets the value of the dispFormulaOrDispFormulaGroupOrChemStructWrap property .
92
22
20,231
public java . util . List < Object > getAttribOrPermissions ( ) { if ( attribOrPermissions == null ) { attribOrPermissions = new ArrayList < Object > ( ) ; } return this . attribOrPermissions ; }
Gets the value of the attribOrPermissions property .
55
13
20,232
public Constituent getParent ( ) { if ( Constituent_Type . featOkTst && ( ( Constituent_Type ) jcasType ) . casFeat_parent == null ) jcasType . jcas . throwFeatMissing ( "parent" , "de.julielab.jules.types.Constituent" ) ; return ( Constituent ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( Constituent_Type ) jcasType ) . casFeatCode_parent ) ) ) ; }
getter for parent - gets The parent in a constituency tree C
140
13
20,233
public void setParent ( Constituent v ) { if ( Constituent_Type . featOkTst && ( ( Constituent_Type ) jcasType ) . casFeat_parent == null ) jcasType . jcas . throwFeatMissing ( "parent" , "de.julielab.jules.types.Constituent" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( Constituent_Type ) jcasType ) . casFeatCode_parent , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for parent - sets The parent in a constituency tree C
135
13
20,234
public boolean hasNextQuery ( ) { for ( int i = 0 ; i < innerLearners . length ; i ++ ) { if ( innerLearners [ i ] . hasNextQuery ( ) ) return true ; } return comboHasNextQuery ( ) ; }
See if someone has a query
55
6
20,235
public DistanceInstance nextQuery ( ) { // need to save out the i-th field, if it's been prepared. // poll sublearners in random order, to be fair // indices [0,innerLearners.length-1] are the inner learners, // index innerLearners.length is the comboLearner ArrayList indices = new ArrayList ( innerLearners . length + 1 ) ; for ( int i = 0 ; i < indices . size ( ) ; i ++ ) indices . set ( i , new Integer ( i ) ) ; Collections . shuffle ( indices ) ; for ( int i = 0 ; i < indices . size ( ) ; i ++ ) { int k = ( ( Integer ) indices . get ( i ) ) . intValue ( ) ; if ( k == innerLearners . length && comboHasNextQuery ( ) ) { return comboNextQuery ( ) ; } else if ( innerLearners [ k ] . hasNextQuery ( ) ) { return innerLearners [ k ] . nextQuery ( ) ; } } throw new IllegalStateException ( "someone seems to have forgotten they want a query" ) ; }
Get a next query from one of the sublearners
239
11
20,236
public void addExample ( DistanceInstance answeredQuery ) { MyMultiDistanceInstance di = asMultiDistanceInstance ( answeredQuery ) ; for ( int i = 0 ; i < innerLearners . length ; i ++ ) { innerLearners [ i ] . addExample ( di . get ( i ) ) ; } comboAddExample ( di ) ; }
Pass new labels to the sublearners .
72
9
20,237
public StringWrapperIterator prepare ( StringWrapperIterator it ) { List multiWrappers = asMultiStringWrapperList ( it ) ; if ( multiWrappers . size ( ) == 0 ) return new BasicStringWrapperIterator ( Collections . EMPTY_SET . iterator ( ) ) ; MultiStringWrapper prototype = ( MultiStringWrapper ) multiWrappers . get ( 0 ) ; for ( int i = 0 ; i < prototype . size ( ) ; i ++ ) { int j = prototype . getDistanceLearnerIndex ( i ) ; StringDistanceLearner learner = innerLearners [ j ] ; StringWrapperIterator prepped = learner . prepare ( new JthStringWrapperValueIterator ( j , multiWrappers . iterator ( ) ) ) ; for ( int k = 0 ; k < multiWrappers . size ( ) ; k ++ ) { MultiStringWrapper msw = ( MultiStringWrapper ) multiWrappers . get ( k ) ; StringWrapper w = prepped . nextStringWrapper ( ) ; msw . set ( i , w ) ; } } return new BasicStringWrapperIterator ( multiWrappers . iterator ( ) ) ; }
Prepare data for the sublearners .
250
9
20,238
public DistanceInstanceIterator prepare ( DistanceInstanceIterator it ) { List multiDistances = asMultiDistanceInstanceList ( it ) ; return new BasicDistanceInstanceIterator ( multiDistances . iterator ( ) ) ; }
Prepare data for the learners .
43
7
20,239
private StringWrapper prepareForLearner ( StringWrapper w , StringDistanceLearner learner ) { StringWrapperIterator it = new BasicStringWrapperIterator ( Collections . singleton ( w ) . iterator ( ) ) ; return learner . prepare ( it ) . nextStringWrapper ( ) ; }
Prepare a single StringWrapper for a learner
65
11
20,240
protected StringDistance [ ] getInnerDistances ( ) { StringDistance [ ] innerDistances = new StringDistance [ innerLearners . length ] ; for ( int j = 0 ; j < innerLearners . length ; j ++ ) { innerDistances [ j ] = innerLearners [ j ] . getDistance ( ) ; } return innerDistances ; }
Get an array of trained inner distances .
77
8
20,241
public String getOntologyId ( ) { if ( Developmental_Type . featOkTst && ( ( Developmental_Type ) jcasType ) . casFeat_ontologyId == null ) jcasType . jcas . throwFeatMissing ( "ontologyId" , "neuroner.NeuroNER.Developmental" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Developmental_Type ) jcasType ) . casFeatCode_ontologyId ) ; }
getter for ontologyId - gets ontologyId
115
11
20,242
private static void showUsage ( ) { System . out . println ( "BatchExtractor <pdf-dir-path> <output-dir-path> <parser>" ) ; System . out . println ( "BatchExtractor <pdf-dir-path> <output-dir-path> <parser> --debug" ) ; System . out . println ( "BatchExtractor <pdf-dir-path> <output-dir-path> <parser> --small" ) ; System . out . println ( "\tparser= pdfbox | tet" ) ; }
Shows usages by displaying the information on the screen such as the PDF path output path the PDF parser process mode etc .
122
25
20,243
public List < java . lang . Object > getYearOrMonthOrDayOrSeasonOrMedlineDate ( ) { if ( yearOrMonthOrDayOrSeasonOrMedlineDate == null ) { yearOrMonthOrDayOrSeasonOrMedlineDate = new ArrayList < java . lang . Object > ( ) ; } return this . yearOrMonthOrDayOrSeasonOrMedlineDate ; }
Gets the value of the yearOrMonthOrDayOrSeasonOrMedlineDate property .
83
19
20,244
public NGram createNGram ( List words ) { int [ ] nums = new int [ words . size ( ) ] ; //ngram needs it own copy of this array so keep making a unique one for each instance. for ( int wi = 0 ; wi < nums . length ; wi ++ ) { nums [ wi ] = wordMap . getIndex ( words . get ( wi ) ) ; if ( nums [ wi ] == - 1 ) { return null ; } } return new NGram ( nums ) ; }
Creates a new n - gram for the specified list of words .
112
14
20,245
private static boolean shouldDehyphenate ( String w1 , String w2 ) { boolean dehyphenate = true ; String rule = "DH" ; // choice by default, dehyphenate if ( w1 . length ( ) <= 1 ) { // w1 has only one char dehyphenate = false ; rule = "N11" ; } else if ( w2 . length ( ) <= 1 ) { // w2 has only one char dehyphenate = false ; rule = "N12" ; } else if ( numberEnd . matcher ( w1 ) . find ( ) ) { // number at the end of w1 dehyphenate = false ; rule = "N21" ; } else if ( numberStart . matcher ( w2 ) . find ( ) ) { // number at the beginning of w2 dehyphenate = false ; rule = "N22" ; } else if ( greekEnd . matcher ( w1 ) . find ( ) ) { // greek letter at the end of w1 dehyphenate = false ; rule = "N31" ; } else if ( greekStart . matcher ( w2 ) . find ( ) ) { // greek letter at the beginning of w2 dehyphenate = false ; rule = "N32" ; } if ( dehyphenate ) { String word = w1 . substring ( 0 , w1 . length ( ) - 1 ) + w2 ; LOG . debug ( "\"" + w1 + "\",\"" + w2 + "\",\"" + rule + "\",\"" + word + "\"\n" ) ; } else { LOG . debug ( "\"" + w1 + "\",\"" + w2 + "\",\"" + rule + "\",\"" + w1 + w2 + "\"\n" ) ; } return dehyphenate ; }
Decides whether a word should be dehyphenated
408
11
20,246
public < R > void visit ( String key , Visitor < T , R > visitor ) { if ( root != null ) { visit ( key , visitor , null , root ) ; } }
visit the node those key matches the given key
40
10
20,247
private < R > void visit ( String prefix , Visitor < T , R > visitor , RadixTreeNode < T > parent , RadixTreeNode < T > node ) { int numberOfMatchingCharacters = node . getNumberOfMatchingCharacters ( prefix ) ; // if the node key and prefix match, we found a match! if ( numberOfMatchingCharacters == prefix . length ( ) && numberOfMatchingCharacters == node . getKey ( ) . length ( ) ) { visitor . visit ( prefix , parent , node ) ; } else if ( node . getKey ( ) . equals ( "" ) == true // either we are at the // root || ( numberOfMatchingCharacters < prefix . length ( ) && numberOfMatchingCharacters >= node . getKey ( ) . length ( ) ) ) { // OR we need to // traverse the childern String newText = prefix . substring ( numberOfMatchingCharacters , prefix . length ( ) ) ; for ( RadixTreeNode < T > child : node . getChildern ( ) ) { // recursively search the child nodes if ( child . getKey ( ) . startsWith ( newText . charAt ( 0 ) + "" ) ) { visit ( newText , visitor , node , child ) ; break ; } } } }
recursively visit the tree based on the supplied key . calls the Visitor for the node those key matches the given prefix
275
25
20,248
private void formatNodeTo ( Formatter f , int level , RadixTreeNode < T > node ) { for ( int i = 0 ; i < level ; i ++ ) { f . format ( " " ) ; } f . format ( "|" ) ; for ( int i = 0 ; i < level ; i ++ ) { f . format ( "-" ) ; } if ( node . isReal ( ) == true ) f . format ( "%s[%s]*%n" , node . getKey ( ) , node . getValue ( ) ) ; else f . format ( "%s%n" , node . getKey ( ) ) ; for ( RadixTreeNode < T > child : node . getChildern ( ) ) { formatNodeTo ( f , level + 1 , child ) ; } }
WARNING! Do not use this for a large Trie it s for testing purpose only .
175
18
20,249
@ Override public void formatTo ( Formatter formatter , int flags , int width , int precision ) { formatNodeTo ( formatter , 0 , root ) ; }
Writes a textual representation of this tree to the given formatter .
36
14
20,250
private ValueUnitWrapper normalizeSpecialCases ( double value , String unit ) throws UnknownUnitException { if ( unit . equals ( "mol/dm3" ) ) { return new ValueUnitWrapper ( value , MOLAR_NORMALIZED_UNIT ) ; } else { throw new UnknownUnitException ( unit ) ; } }
deals with the normalization of special cases
73
8
20,251
private ValueUnitWrapper normalizeMassUnit ( final double value , final String unit ) throws UnknownUnitException { Matcher matcher = mMassUnitPatter . matcher ( unit ) ; if ( matcher . find ( ) ) { double normalizationFactor = 1.0 ; String numeratorSIPrefix = matcher . group ( 1 ) ; Double numeratorFactor = getSIFactor ( numeratorSIPrefix ) ; if ( numeratorFactor != null ) { normalizationFactor *= numeratorFactor ; } String denominatorSIPrefix = matcher . group ( 3 ) ; String denominatorUnit = matcher . group ( 4 ) ; Double denominatorFactor = getSIFactor ( denominatorSIPrefix ) ; if ( denominatorFactor != null ) { int power = ( denominatorUnit . endsWith ( "3" ) ) ? 3 : 1 ; normalizationFactor /= Math . pow ( denominatorFactor , power ) ; } if ( denominatorUnit . equals ( "l" ) || denominatorUnit . equals ( "L" ) ) { normalizationFactor *= 1000 ; } assert mSIPrefixes . get ( "kilo" ) != null : "kilo seems not to be in the table !" ; double normalizedValue = ( normalizationFactor * value ) / mSIPrefixes . get ( "kilo" ) ; return new ValueUnitWrapper ( normalizedValue , MASS_NORMALIZED_UNIT ) ; } else { throw new UnknownUnitException ( unit ) ; } }
deals with the normalization of unit confronting weight and volume
333
11
20,252
private ValueUnitWrapper normalizeMolarUnit ( final double value , final String unit ) throws UnknownUnitException { Matcher matcher = mMolarUnitPattern . matcher ( unit ) ; if ( matcher . find ( ) ) { String siPrefix = matcher . group ( 1 ) ; Double convFactor = getSIFactor ( siPrefix ) ; if ( convFactor == null ) { throw new UnknownUnitException ( unit ) ; } else { double normalizedValue = convFactor * value ; return new ValueUnitWrapper ( normalizedValue , MOLAR_NORMALIZED_UNIT ) ; } } else { throw new UnknownUnitException ( unit ) ; } }
deals with normalization of measure of molarity
144
10
20,253
public StringArray getTokens ( ) { if ( FeatureTokens_Type . featOkTst && ( ( FeatureTokens_Type ) jcasType ) . casFeat_tokens == null ) jcasType . jcas . throwFeatMissing ( "tokens" , "ch.epfl.bbp.uima.types.FeatureTokens" ) ; return ( StringArray ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( FeatureTokens_Type ) jcasType ) . casFeatCode_tokens ) ) ) ; }
getter for tokens - gets
141
6
20,254
public void setTokens ( StringArray v ) { if ( FeatureTokens_Type . featOkTst && ( ( FeatureTokens_Type ) jcasType ) . casFeat_tokens == null ) jcasType . jcas . throwFeatMissing ( "tokens" , "ch.epfl.bbp.uima.types.FeatureTokens" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( FeatureTokens_Type ) jcasType ) . casFeatCode_tokens , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for tokens - sets
137
6
20,255
public String getTokens ( int i ) { if ( FeatureTokens_Type . featOkTst && ( ( FeatureTokens_Type ) jcasType ) . casFeat_tokens == null ) jcasType . jcas . throwFeatMissing ( "tokens" , "ch.epfl.bbp.uima.types.FeatureTokens" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( FeatureTokens_Type ) jcasType ) . casFeatCode_tokens ) , i ) ; return jcasType . ll_cas . ll_getStringArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( FeatureTokens_Type ) jcasType ) . casFeatCode_tokens ) , i ) ; }
indexed getter for tokens - gets an indexed value -
191
12
20,256
public void setTokens ( int i , String v ) { if ( FeatureTokens_Type . featOkTst && ( ( FeatureTokens_Type ) jcasType ) . casFeat_tokens == null ) jcasType . jcas . throwFeatMissing ( "tokens" , "ch.epfl.bbp.uima.types.FeatureTokens" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( FeatureTokens_Type ) jcasType ) . casFeatCode_tokens ) , i ) ; jcasType . ll_cas . ll_setStringArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( FeatureTokens_Type ) jcasType ) . casFeatCode_tokens ) , i , v ) ; }
indexed setter for tokens - sets an indexed value -
195
12
20,257
public String getDictCanon ( ) { if ( DictTerm_Type . featOkTst && ( ( DictTerm_Type ) jcasType ) . casFeat_DictCanon == null ) jcasType . jcas . throwFeatMissing ( "DictCanon" , "org.apache.uima.conceptMapper.DictTerm" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( DictTerm_Type ) jcasType ) . casFeatCode_DictCanon ) ; }
getter for DictCanon - gets canonical form
126
11
20,258
public void setDictCanon ( String v ) { if ( DictTerm_Type . featOkTst && ( ( DictTerm_Type ) jcasType ) . casFeat_DictCanon == null ) jcasType . jcas . throwFeatMissing ( "DictCanon" , "org.apache.uima.conceptMapper.DictTerm" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( DictTerm_Type ) jcasType ) . casFeatCode_DictCanon , v ) ; }
setter for DictCanon - sets canonical form
129
11
20,259
public void setMatchedTokens ( FSArray v ) { if ( DictTerm_Type . featOkTst && ( ( DictTerm_Type ) jcasType ) . casFeat_matchedTokens == null ) jcasType . jcas . throwFeatMissing ( "matchedTokens" , "org.apache.uima.conceptMapper.DictTerm" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( DictTerm_Type ) jcasType ) . casFeatCode_matchedTokens , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for matchedTokens - sets
138
7
20,260
public TOP getMatchedTokens ( int i ) { if ( DictTerm_Type . featOkTst && ( ( DictTerm_Type ) jcasType ) . casFeat_matchedTokens == null ) jcasType . jcas . throwFeatMissing ( "matchedTokens" , "org.apache.uima.conceptMapper.DictTerm" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DictTerm_Type ) jcasType ) . casFeatCode_matchedTokens ) , i ) ; return ( TOP ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( DictTerm_Type ) jcasType ) . casFeatCode_matchedTokens ) , i ) ) ) ; }
indexed getter for matchedTokens - gets an indexed value -
213
13
20,261
public void setCount ( Object o , int c ) { int [ ] nums = ( int [ ] ) cset . get ( o ) ; if ( nums != null ) { nums [ 0 ] = c ; } else { cset . put ( o , new int [ ] { c , 1 } ) ; } }
Assigns the specified object the specified count in the set .
70
13
20,262
protected Context [ ] getParameters ( int [ ] [ ] outcomePatterns ) throws java . io . IOException { Context [ ] params = new Context [ NUM_PREDS ] ; int pid = 0 ; for ( int i = 0 ; i < outcomePatterns . length ; i ++ ) { //construct outcome pattern int [ ] outcomePattern = new int [ outcomePatterns [ i ] . length - 1 ] ; for ( int k = 1 ; k < outcomePatterns [ i ] . length ; k ++ ) { outcomePattern [ k - 1 ] = outcomePatterns [ i ] [ k ] ; } //populate parameters for each context which uses this outcome pattern. for ( int j = 0 ; j < outcomePatterns [ i ] [ 0 ] ; j ++ ) { double [ ] contextParameters = new double [ outcomePatterns [ i ] . length - 1 ] ; for ( int k = 1 ; k < outcomePatterns [ i ] . length ; k ++ ) { contextParameters [ k - 1 ] = readDouble ( ) ; } params [ pid ] = new Context ( outcomePattern , contextParameters ) ; pid ++ ; } } return params ; }
Reads the parameters from a file and populates an array of context objects .
246
16
20,263
public Annotation getEnclosingAnnot ( ) { if ( TopicToken_Type . featOkTst && ( ( TopicToken_Type ) jcasType ) . casFeat_enclosingAnnot == null ) jcasType . jcas . throwFeatMissing ( "enclosingAnnot" , "ch.epfl.bbp.uima.types.TopicToken" ) ; return ( Annotation ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( TopicToken_Type ) jcasType ) . casFeatCode_enclosingAnnot ) ) ) ; }
getter for enclosingAnnot - gets
151
9
20,264
public void setEnclosingAnnot ( Annotation v ) { if ( TopicToken_Type . featOkTst && ( ( TopicToken_Type ) jcasType ) . casFeat_enclosingAnnot == null ) jcasType . jcas . throwFeatMissing ( "enclosingAnnot" , "ch.epfl.bbp.uima.types.TopicToken" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( TopicToken_Type ) jcasType ) . casFeatCode_enclosingAnnot , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for enclosingAnnot - sets
147
9
20,265
public void setHighLevelMeta ( int i ) { String meta = "<Table>\n" ; meta = meta + "<pageNumInDoc>" + ( i + 1 ) + "</pageNumInDoc>\n" ; m_caption = replaceAllSpecialChracters ( m_caption ) ; meta = meta + "<TableCaption>" + m_caption + "</TableCaption>\n" ; String location = "" ; if ( m_topCaptionLocation ) location = "top" ; else location = "below" ; location = replaceAllSpecialChracters ( location ) ; meta = meta + "<CaptionLocation>" + location + "</CaptionLocation>\n" ; m_metadata_HighLevel = replaceAllSpecialChracters ( m_metadata_HighLevel ) ; meta = meta + "<dataHighLevel>" + m_metadata_HighLevel + "</dataHighLevel>\n" ; this . setMetadataHighLevel ( meta ) ; }
Sets the high - level table metadata
214
8
20,266
public void setEmptyMetadataStructureLevel ( int YNum , int cc , List < TextPiece > wordsOfAPage , DocInfo m_docInfo ) { String meta = "" ; meta = "<TableColumnHeading>\n" + "</TableColumnHeading>" + "\n" ; meta = meta + "<TableContent>\n" ; meta = meta + "</TableContent>" + "\n" ; meta = meta + "<TableRowHeading>" + "</TableRowHeading>" + "\n" ; meta = meta + "<TableFootnote>" ; meta = meta + "... </TableFootnote>" + "\n" ; meta = meta + "<ColumnNum>" + "</ColumnNum>" + "\n" ; meta = meta + "<RowNum>" + "</RowNum>" + "\n" ; meta = meta + "<ColumnCoordinates>" + "</ColumnCoordinates>" + "\n" ; meta = meta + "<TableHeight>" + "</TableHeight>" + "\n" ; meta = meta + "<TableWidth>" + "</TableWidth>" + "\n" ; meta = meta + "<isWideTable>" + m_WideTable + "</isWideTable>\n" ; m_referenceText = replaceAllSpecialChracters ( m_referenceText ) ; meta = meta + "<TableReferenceText>" + m_referenceText + "</TableReferenceText>" + "\n" ; meta = meta + "</Table>" + "\n" ; setMetadataStructureLevel ( meta ) ; int tableNum = m_docInfo . getTableNum ( ) ; }
Sets an empty metadata file
344
6
20,267
public static String replaceAllSpecialChracters ( String toBeReplaced ) { toBeReplaced = toBeReplaced . replaceAll ( "&" , "&amp;" ) ; toBeReplaced = toBeReplaced . replaceAll ( "<" , "&lt;" ) ; toBeReplaced = toBeReplaced . replaceAll ( ">" , "&gt;" ) ; toBeReplaced = toBeReplaced . replaceAll ( "\"" , "&quot;" ) ; toBeReplaced = toBeReplaced . replaceAll ( "'" , "&apos;" ) ; // toBeReplaced = toBeReplaced.replace("^", "&circ"); // toBeReplaced = toBeReplaced.replaceAll("0xb", ""); int len = toBeReplaced . length ( ) ; char [ ] temp = toBeReplaced . toCharArray ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char xCode = temp [ i ] ; if ( ( xCode > ' ' && xCode <= ' ' ) || ( xCode == ' ' ) || ( xCode == ' ' ) || ( xCode == ' ' ) || ( xCode == ' ' ) || ( xCode == ' ' ) || ( xCode == ' ' ) ) { String sub1 = toBeReplaced . substring ( 0 , i ) ; String sub2 = toBeReplaced . substring ( i + 1 , len ) ; String replacement = "" ; if ( ( xCode > ' ' && xCode <= ' ' ) ) replacement = " " ; if ( xCode == ' ' ) replacement = " " ; if ( xCode == ' ' ) replacement = " " ; if ( xCode == ' ' ) replacement = " " ; if ( xCode == ' ' ) replacement = " " ; if ( xCode == ' ' ) replacement = " " ; if ( xCode == ' ' ) replacement = " " ; toBeReplaced = sub1 + replacement + sub2 ; } len = toBeReplaced . length ( ) ; temp = toBeReplaced . toCharArray ( ) ; } return ( toBeReplaced ) ; }
Replaces all special characters in a given string
474
9
20,268
public void addPreviousPunctuation ( Parse punct ) { if ( this . prevPunctSet == null ) { this . prevPunctSet = new LinkedHashSet ( ) ; } prevPunctSet . add ( punct ) ; }
Designates that the specifed punctuation should is prior to this parse .
52
16
20,269
public void addNextPunctuation ( Parse punct ) { if ( this . nextPunctSet == null ) { this . nextPunctSet = new LinkedHashSet ( ) ; } nextPunctSet . add ( punct ) ; }
Designates that the specifed punctuation follows this parse .
52
13
20,270
public void insert ( final Parse constituent ) { Span ic = constituent . span ; if ( span . contains ( ic ) ) { //double oprob=c.prob; int pi = 0 ; int pn = parts . size ( ) ; for ( ; pi < pn ; pi ++ ) { Parse subPart = ( Parse ) parts . get ( pi ) ; //System.err.println("Parse.insert:con="+constituent+" sp["+pi+"] "+subPart+" "+subPart.getType()); Span sp = subPart . span ; if ( sp . getStart ( ) >= ic . getEnd ( ) ) { break ; } // constituent contains subPart else if ( ic . contains ( sp ) ) { //System.err.println("Parse.insert:con contains subPart"); parts . remove ( pi ) ; pi -- ; constituent . parts . add ( subPart ) ; subPart . setParent ( constituent ) ; //System.err.println("Parse.insert: "+subPart.hashCode()+" -> "+subPart.getParent().hashCode()); pn = parts . size ( ) ; } else if ( sp . contains ( ic ) ) { //System.err.println("Parse.insert:subPart contains con"); subPart . insert ( constituent ) ; return ; } } //System.err.println("Parse.insert:adding con="+constituent+" to "+this); parts . add ( pi , constituent ) ; constituent . setParent ( this ) ; //System.err.println("Parse.insert: "+constituent.hashCode()+" -> "+constituent.getParent().hashCode()); } else { throw ( new InternalError ( "Inserting constituent not contained in the sentence!" ) ) ; } }
Inserts the specified constituent into this parse based on its text span . This method assumes that the specified constituent can be inserted into this parse .
390
28
20,271
public double getTagSequenceProb ( ) { //System.err.println("Parse.getTagSequenceProb: "+type+" "+this); if ( parts . size ( ) == 1 && ( ( Parse ) parts . get ( 0 ) ) . type . equals ( ParserME . TOK_NODE ) ) { //System.err.println(this+" "+prob); return ( Math . log ( prob ) ) ; } else if ( parts . size ( ) == 0 ) { System . err . println ( "Parse.getTagSequenceProb: Wrong base case!" ) ; return ( 0.0 ) ; } else { double sum = 0.0 ; for ( Iterator pi = parts . iterator ( ) ; pi . hasNext ( ) ; ) { sum += ( ( Parse ) pi . next ( ) ) . getTagSequenceProb ( ) ; } return ( sum ) ; } }
Returns the probability associed with the pos - tag sequence assigned to this parse .
203
17
20,272
public void updateHeads ( HeadRules rules ) { if ( parts != null && parts . size ( ) != 0 ) { for ( int pi = 0 , pn = parts . size ( ) ; pi < pn ; pi ++ ) { Parse c = ( Parse ) parts . get ( pi ) ; c . updateHeads ( rules ) ; } this . head = rules . getHead ( ( Parse [ ] ) parts . toArray ( new Parse [ parts . size ( ) ] ) , type ) ; if ( head == null ) { head = this ; } } else { this . head = this ; } }
Computes the head parses for this parse and its sub - parses and stores this information in the parse data structure .
134
25
20,273
public boolean isPosTag ( ) { return ( parts . size ( ) == 1 && ( ( Parse ) parts . get ( 0 ) ) . getType ( ) . equals ( ParserME . TOK_NODE ) ) ; }
Indicates wether this parse node is a pos - tag .
51
13
20,274
public Parse getCommonParent ( Parse node ) { if ( this == node ) { return parent ; } Set parents = new HashSet ( ) ; Parse cparent = this ; while ( cparent != null ) { parents . add ( cparent ) ; cparent = cparent . getParent ( ) ; } while ( node != null ) { if ( parents . contains ( node ) ) { return node ; } node = node . getParent ( ) ; } return null ; }
Returns the deepest shared parent of this node and the specified node . If the nodes are identical then their parent is returned . If one node is the parent of the other then the parent node is returned .
102
40
20,275
protected int countCorrectPairs ( MatchData data ) { // count the number of times each id appears in each source */ Map counter = new HashMap ( ) ; for ( int i = 0 ; i < data . numSources ( ) ; i ++ ) { String src = data . getSource ( i ) ; for ( int j = 0 ; j < data . numInstances ( src ) ; j ++ ) { String id = data . getInstance ( src , j ) . getId ( ) ; if ( id != null ) { IdKey key = new IdKey ( id , src ) ; Integer c = ( Integer ) counter . get ( key ) ; counter . put ( key , ( c == null ? new Integer ( 1 ) : new Integer ( c . intValue ( ) + 1 ) ) ) ; } } } /* // show the counter for (Iterator i=counter.keySet().iterator(); i.hasNext(); ) { IdKey key = (IdKey) i.next(); System.out.println( key.src+"#"+key.id+" = "+counter.get(key) ); } */ // count the number of correct pairs int numCorrectPairs = 0 ; Set idsInSrc1 = new HashSet ( ) ; for ( int i = 0 ; i < data . numSources ( ) ; i ++ ) { String src1 = data . getSource ( i ) ; idsInSrc1 . clear ( ) ; for ( int j = 0 ; j < data . numInstances ( src1 ) ; j ++ ) { String id = data . getInstance ( src1 , j ) . getId ( ) ; idsInSrc1 . add ( id ) ; for ( int k = i + 1 ; k < data . numSources ( ) ; k ++ ) { String src2 = data . getSource ( k ) ; Integer cInteger = ( Integer ) counter . get ( new IdKey ( id , src2 ) ) ; if ( cInteger != null ) { numCorrectPairs += cInteger . intValue ( ) ; } //System.out.println( "src1:"+src1+" id:"+id+" src2:"+src2+" c:"+cInteger); } } if ( clusterMode ) { // count how often something in src1 can be matched correctly with something // else in src1 for ( Iterator j = idsInSrc1 . iterator ( ) ; j . hasNext ( ) ; ) { String id = ( String ) j . next ( ) ; Integer cInteger = ( Integer ) counter . get ( new IdKey ( id , src1 ) ) ; int c = cInteger . intValue ( ) ; numCorrectPairs += c * ( c - 1 ) / 2 ; } } } return numCorrectPairs ; }
Compute number of correct pairs betwn src1 and src2 where src2 > src1
602
19
20,276
protected void loadGrams ( DataInputStream input ) throws IOException { gramSet = new HashSet ( ) ; try { while ( true ) { int gramLength = input . readInt ( ) ; int [ ] words = new int [ gramLength ] ; for ( int wi = 0 ; wi < gramLength ; wi ++ ) { words [ wi ] = input . readInt ( ) ; } gramSet . add ( new NGram ( words ) ) ; } } catch ( EOFException e ) { } }
Loads the contents of the specified input stream into this dictionary .
108
13
20,277
public boolean contains ( String [ ] words ) { if ( words . length == 1 ) { return wordMap . contains ( words [ 0 ] ) ; } else { NGram ngram = nGramFactory . createNGram ( words ) ; if ( ngram == null ) { return false ; } else { return gramSet . contains ( ngram ) ; } } }
Returns true if this dictionary contains the n - gram consisting of the specified words .
78
16
20,278
public static void main ( String [ ] args ) throws IOException { if ( args . length == 0 ) { System . err . println ( "Usage: Dictionary dictionary_file" ) ; System . exit ( 0 ) ; } Dictionary dict = new Dictionary ( args [ 0 ] ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( null != ( line = in . readLine ( ) ) ) { String [ ] words = line . split ( " " ) ; if ( dict . contains ( words ) ) { System . out . println ( "Dictionary contains: " + line ) ; } else { System . out . println ( "Dictionary does not contain: " + line ) ; } } /* for (Iterator di = dict.iterator();di.hasNext();) { System.out.println(di.next()); } */ }
Allows a dictionery to be queried for specific n - grams from the command - line from statndard in using space delimited n - grams on a single line .
191
35
20,279
public Title getSectionHeading ( ) { if ( Section_Type . featOkTst && ( ( Section_Type ) jcasType ) . casFeat_sectionHeading == null ) jcasType . jcas . throwFeatMissing ( "sectionHeading" , "de.julielab.jules.types.Section" ) ; return ( Title ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( Section_Type ) jcasType ) . casFeatCode_sectionHeading ) ) ) ; }
getter for sectionHeading - gets the title of the section
136
13
20,280
public void setSectionHeading ( Title v ) { if ( Section_Type . featOkTst && ( ( Section_Type ) jcasType ) . casFeat_sectionHeading == null ) jcasType . jcas . throwFeatMissing ( "sectionHeading" , "de.julielab.jules.types.Section" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( Section_Type ) jcasType ) . casFeatCode_sectionHeading , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for sectionHeading - sets the title of the section
133
13
20,281
public String getSectionId ( ) { if ( Section_Type . featOkTst && ( ( Section_Type ) jcasType ) . casFeat_sectionId == null ) jcasType . jcas . throwFeatMissing ( "sectionId" , "de.julielab.jules.types.Section" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Section_Type ) jcasType ) . casFeatCode_sectionId ) ; }
getter for sectionId - gets the id of the section for example as mentioned in the original file or level of the section
111
25
20,282
public void setSectionId ( String v ) { if ( Section_Type . featOkTst && ( ( Section_Type ) jcasType ) . casFeat_sectionId == null ) jcasType . jcas . throwFeatMissing ( "sectionId" , "de.julielab.jules.types.Section" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Section_Type ) jcasType ) . casFeatCode_sectionId , v ) ; }
setter for sectionId - sets the id of the section for example as mentioned in the original file or level of the section
114
25
20,283
final public void train ( StringWrapperIterator i ) { Set seenTokens = new HashSet ( ) ; while ( i . hasNext ( ) ) { StringWrapper s = ( StringWrapper ) i . next ( ) ; BagOfTokens bag = asBagOfTokens ( i . nextStringWrapper ( ) ) ; for ( Iterator j = bag . tokenIterator ( ) ; j . hasNext ( ) ; ) { Token tokj = ( Token ) j . next ( ) ; totalTokens ++ ; // increment backgroundFrequency counts Integer freq = ( Integer ) backgroundFrequency . get ( tokj ) ; if ( freq == null ) backgroundFrequency . put ( tokj , ONE ) ; else if ( freq == ONE ) backgroundFrequency . put ( tokj , TWO ) ; else if ( freq == TWO ) backgroundFrequency . put ( tokj , THREE ) ; else backgroundFrequency . put ( tokj , new Integer ( freq . intValue ( ) + 1 ) ) ; } } }
Accumulate statistics on how often each token occurs .
218
11
20,284
final public StringWrapper prepare ( String s ) { BagOfTokens bag = new BagOfTokens ( s , tokenizer . tokenize ( s ) ) ; double totalWeight = bag . getTotalWeight ( ) ; for ( Iterator i = bag . tokenIterator ( ) ; i . hasNext ( ) ; ) { Token tok = ( Token ) i . next ( ) ; double freq = bag . getWeight ( tok ) ; bag . setWeight ( tok , smoothedProbability ( tok , freq , totalWeight ) ) ; } return bag ; }
Preprocess a string by finding tokens and giving them weights W such that W is the smoothed probability of the token appearing in the document .
123
28
20,285
protected double backgroundProb ( Token tok ) { Integer freqInteger = ( Integer ) backgroundFrequency . get ( tok ) ; double freq = freqInteger == null ? 0 : freqInteger . intValue ( ) ; return freq / totalTokens ; }
Probability of token in the background language model
58
10
20,286
final public double score ( StringWrapper s , StringWrapper t ) { BagOfTokens sBag = ( BagOfTokens ) s ; BagOfTokens tBag = ( BagOfTokens ) t ; double sum = 0 ; for ( Iterator i = sBag . tokenIterator ( ) ; i . hasNext ( ) ; ) { Token tok = ( Token ) i . next ( ) ; if ( tBag . contains ( tok ) ) { double ps = sBag . getWeight ( tok ) ; double pt = tBag . getWeight ( tok ) ; sum -= h ( ps + pt ) - h ( ps ) - h ( pt ) ; } } return 0.5 * sum / Math . log ( 2 ) ; }
Jensen - Shannon distance between distributions .
163
8
20,287
public void prepare ( StringDistance [ ] innerDistances ) { if ( ! fieldsPrepared ) { for ( int i = 0 ; i < size ( ) ; i ++ ) { StringDistance d = innerDistances [ getDistanceLearnerIndex ( i ) ] ; set ( i , d . prepare ( get ( i ) . unwrap ( ) ) ) ; } } }
Prepare each field with the appropriate distance
79
8
20,288
public String getMod ( ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_mod == null ) jcasType . jcas . throwFeatMissing ( "mod" , "de.julielab.jules.types.ace.Timex2" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_mod ) ; }
getter for mod - gets
117
6
20,289
public void setMod ( String v ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_mod == null ) jcasType . jcas . throwFeatMissing ( "mod" , "de.julielab.jules.types.ace.Timex2" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_mod , v ) ; }
setter for mod - sets
120
6
20,290
public String getComment ( ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_comment == null ) jcasType . jcas . throwFeatMissing ( "comment" , "de.julielab.jules.types.ace.Timex2" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_comment ) ; }
getter for comment - gets
117
6
20,291
public void setComment ( String v ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_comment == null ) jcasType . jcas . throwFeatMissing ( "comment" , "de.julielab.jules.types.ace.Timex2" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_comment , v ) ; }
setter for comment - sets
120
6
20,292
public String getAnchor_val ( ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_anchor_val == null ) jcasType . jcas . throwFeatMissing ( "anchor_val" , "de.julielab.jules.types.ace.Timex2" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_anchor_val ) ; }
getter for anchor_val - gets
130
8
20,293
public void setAnchor_val ( String v ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_anchor_val == null ) jcasType . jcas . throwFeatMissing ( "anchor_val" , "de.julielab.jules.types.ace.Timex2" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_anchor_val , v ) ; }
setter for anchor_val - sets
133
8
20,294
public String getVal ( ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_val == null ) jcasType . jcas . throwFeatMissing ( "val" , "de.julielab.jules.types.ace.Timex2" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_val ) ; }
getter for val - gets
117
6
20,295
public void setVal ( String v ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_val == null ) jcasType . jcas . throwFeatMissing ( "val" , "de.julielab.jules.types.ace.Timex2" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_val , v ) ; }
setter for val - sets
120
6
20,296
public String getSet ( ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_set == null ) jcasType . jcas . throwFeatMissing ( "set" , "de.julielab.jules.types.ace.Timex2" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_set ) ; }
getter for set - gets
117
6
20,297
public void setSet ( String v ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_set == null ) jcasType . jcas . throwFeatMissing ( "set" , "de.julielab.jules.types.ace.Timex2" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_set , v ) ; }
setter for set - sets
120
6
20,298
public String getNon_specific ( ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_non_specific == null ) jcasType . jcas . throwFeatMissing ( "non_specific" , "de.julielab.jules.types.ace.Timex2" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_non_specific ) ; }
getter for non_specific - gets
125
8
20,299
public void setNon_specific ( String v ) { if ( Timex2_Type . featOkTst && ( ( Timex2_Type ) jcasType ) . casFeat_non_specific == null ) jcasType . jcas . throwFeatMissing ( "non_specific" , "de.julielab.jules.types.ace.Timex2" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Timex2_Type ) jcasType ) . casFeatCode_non_specific , v ) ; }
setter for non_specific - sets
128
8