idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
8,500 | public Parse adjoin ( final Parse sister , final HeadRules rules ) { final Parse lastChild = this . parts . get ( this . parts . size ( ) - 1 ) ; final Parse adjNode = new Parse ( this . text , new Span ( lastChild . getSpan ( ) . getStart ( ) , sister . getSpan ( ) . getEnd ( ) ) , lastChild . getType ( ) , 1 , rules . getHead ( new Parse [ ] { lastChild , sister } , lastChild . getType ( ) ) ) ; adjNode . parts . add ( lastChild ) ; if ( sister . prevPunctSet != null ) { adjNode . parts . addAll ( sister . prevPunctSet ) ; } adjNode . parts . add ( sister ) ; this . parts . set ( this . parts . size ( ) - 1 , adjNode ) ; this . span = new Span ( this . span . getStart ( ) , sister . getSpan ( ) . getEnd ( ) ) ; this . head = rules . getHead ( getChildren ( ) , this . type ) ; this . headIndex = this . head . headIndex ; return adjNode ; } | Sister adjoins this node s last child and the specified sister node and returns their new parent node . The new parent node replace this nodes last child . |
8,501 | public static void pruneParse ( final Parse parse ) { final List < Parse > nodes = new LinkedList < Parse > ( ) ; nodes . add ( parse ) ; while ( nodes . size ( ) != 0 ) { final Parse node = nodes . remove ( 0 ) ; final Parse [ ] children = node . getChildren ( ) ; if ( children . length == 1 && node . getType ( ) . equals ( children [ 0 ] . getType ( ) ) ) { final int index = node . getParent ( ) . parts . indexOf ( node ) ; children [ 0 ] . setParent ( node . getParent ( ) ) ; node . getParent ( ) . parts . set ( index , children [ 0 ] ) ; node . parent = null ; node . parts = null ; } nodes . addAll ( Arrays . asList ( children ) ) ; } } | Prune the specified sentence parse of vacuous productions . |
8,502 | public boolean isFlat ( ) { boolean flat = true ; for ( int ci = 0 ; ci < this . parts . size ( ) ; ci ++ ) { flat &= this . parts . get ( ci ) . isPosTag ( ) ; } return flat ; } | Returns true if this constituent contains no sub - constituents . |
8,503 | public Parse [ ] getTagNodes ( ) { final List < Parse > tags = new LinkedList < Parse > ( ) ; final List < Parse > nodes = new LinkedList < Parse > ( ) ; nodes . addAll ( this . parts ) ; while ( nodes . size ( ) != 0 ) { final Parse p = nodes . remove ( 0 ) ; if ( p . isPosTag ( ) ) { tags . add ( p ) ; } else { nodes . addAll ( 0 , p . parts ) ; } } return tags . toArray ( new Parse [ tags . size ( ) ] ) ; } | Returns the parse nodes which are children of this node and which are pos tags . |
8,504 | public static void addNames ( final String tag , final Span [ ] names , final Parse [ ] tokens ) { for ( final Span nameTokenSpan : names ) { final Parse startToken = tokens [ nameTokenSpan . getStart ( ) ] ; final Parse endToken = tokens [ nameTokenSpan . getEnd ( ) - 1 ] ; final Parse commonParent = startToken . getCommonParent ( endToken ) ; if ( commonParent != null ) { final Span nameSpan = new Span ( startToken . getSpan ( ) . getStart ( ) , endToken . getSpan ( ) . getEnd ( ) ) ; if ( nameSpan . equals ( commonParent . getSpan ( ) ) ) { commonParent . insert ( new Parse ( commonParent . getText ( ) , nameSpan , tag , 1.0 , endToken . getHeadIndex ( ) ) ) ; } else { final Parse [ ] kids = commonParent . getChildren ( ) ; boolean crossingKids = false ; for ( final Parse kid : kids ) { if ( nameSpan . crosses ( kid . getSpan ( ) ) ) { crossingKids = true ; } } if ( ! crossingKids ) { commonParent . insert ( new Parse ( commonParent . getText ( ) , nameSpan , tag , 1.0 , endToken . getHeadIndex ( ) ) ) ; } else { if ( commonParent . getType ( ) . equals ( "NP" ) ) { final Parse [ ] grandKids = kids [ 0 ] . getChildren ( ) ; if ( grandKids . length > 1 && nameSpan . contains ( grandKids [ grandKids . length - 1 ] . getSpan ( ) ) ) { commonParent . insert ( new Parse ( commonParent . getText ( ) , commonParent . getSpan ( ) , tag , 1.0 , commonParent . getHeadIndex ( ) ) ) ; } } } } } } } | Utility method to inserts named entities . |
8,505 | public void put ( String key , String value ) throws IllegalArgumentException { if ( ! key . matches ( "[a-z-]*" ) ) { throw new IllegalArgumentException ( "The key must contains letters and dash" ) ; } for ( char c : value . toCharArray ( ) ) { if ( c < 32 || c > 127 ) { throw new IllegalArgumentException ( "The metadata value is not ASCII encoded" ) ; } } map . put ( key , value ) ; } | Add a value in metadata |
8,506 | public static void loadResource ( final String serializerId , @ SuppressWarnings ( "rawtypes" ) final Map < String , ArtifactSerializer > artifactSerializers , final String resourcePath , final Map < String , Object > resources ) { final File resourceFile = new File ( resourcePath ) ; if ( resourceFile != null ) { final String resourceId = IOUtils . normalizeLexiconName ( resourceFile . getName ( ) ) ; final ArtifactSerializer < ? > serializer = artifactSerializers . get ( serializerId ) ; final InputStream resourceIn = IOUtils . openFromFile ( resourceFile ) ; try { resources . put ( resourceId , serializer . create ( resourceIn ) ) ; } catch ( final InvalidFormatException e ) { e . printStackTrace ( ) ; } catch ( final IOException e ) { e . printStackTrace ( ) ; } finally { try { resourceIn . close ( ) ; } catch ( final IOException e ) { } } } } | Load a resource by resourceId . |
8,507 | public List < String > getBioDictionaryMatch ( final String [ ] tokens ) { final List < String > entitiesList = new ArrayList < String > ( ) ; String prefix = "-" + BioCodec . START ; String gazEntry = null ; String searchSpan = null ; for ( int i = 0 ; i < tokens . length ; i ++ ) { gazEntry = null ; int j ; for ( j = tokens . length - 1 ; j >= i ; j -- ) { searchSpan = createSpan ( tokens , i , j ) ; gazEntry = lookup ( searchSpan . toLowerCase ( ) ) ; if ( gazEntry != null ) { break ; } } prefix = "-" + BioCodec . START ; if ( gazEntry != null ) { while ( i < j ) { entitiesList . add ( ( gazEntry + prefix ) . intern ( ) ) ; prefix = "-" + BioCodec . CONTINUE ; i ++ ; } } if ( gazEntry != null ) { entitiesList . add ( ( gazEntry + prefix ) . intern ( ) ) ; } else { entitiesList . add ( BioCodec . OTHER ) ; } } return entitiesList ; } | Performs gazetteer match in a bio encoding . |
8,508 | public List < String > getBilouDictionaryMatch ( final String [ ] tokens ) { final List < String > entitiesList = new ArrayList < String > ( ) ; String prefix = "-" + BilouCodec . START ; String gazClass = null ; String searchSpan = null ; for ( int i = 0 ; i < tokens . length ; i ++ ) { gazClass = null ; int j ; for ( j = tokens . length - 1 ; j >= i ; j -- ) { searchSpan = createSpan ( tokens , i , j ) ; gazClass = lookup ( searchSpan . toLowerCase ( ) ) ; if ( gazClass != null ) { break ; } } prefix = "-" + BilouCodec . START ; if ( gazClass != null ) { while ( i < j ) { entitiesList . add ( ( gazClass + prefix ) . intern ( ) ) ; prefix = "-" + BilouCodec . CONTINUE ; i ++ ; } } if ( gazClass != null ) { if ( prefix . equals ( "-" + BilouCodec . START ) ) { entitiesList . add ( ( gazClass + "-" + BilouCodec . UNIT ) . intern ( ) ) ; } else if ( prefix . equals ( "-" + BilouCodec . CONTINUE ) ) { entitiesList . add ( ( gazClass + "-" + BilouCodec . LAST ) . intern ( ) ) ; } } else { entitiesList . add ( BilouCodec . OTHER ) ; } } return entitiesList ; } | Performs gazetteer match in a bilou encoding . |
8,509 | private String createSpan ( final String [ ] tokens , final int from , final int to ) { String tokenSpan = "" ; for ( int i = from ; i < to ; i ++ ) { tokenSpan += tokens [ i ] + " " ; } tokenSpan += tokens [ to ] ; return tokenSpan ; } | Create a multi token entry search in the dictionary Map . |
8,510 | public void update ( Bbox mapBounds ) { for ( final SnappingRule condition : snappingRules ) { condition . getSourceProvider ( ) . update ( mapBounds ) ; condition . getSourceProvider ( ) . getSnappingSources ( new GeometryArrayFunction ( ) { public void execute ( Geometry [ ] geometries ) { condition . getAlgorithm ( ) . setGeometries ( geometries ) ; } } ) ; } } | Update the playing field for snapping by providing a bounding box wherein the source providers should present their geometries . |
8,511 | public void swap ( ) { if ( modeContext . equals ( ModeContext . VIEW_MODE ) ) { modeContext = ModeContext . EDIT_MODE ; } else { modeContext = ModeContext . VIEW_MODE ; } } | Swap the ModeContext . |
8,512 | protected LabeledPasswordTextFieldPanel < String , T > newPasswordTextField ( final String id , final IModel < T > model ) { final IModel < String > labelModel = ResourceModelFactory . newResourceModel ( "global.password.label" , this ) ; final IModel < String > placeholderModel = ResourceModelFactory . newResourceModel ( "global.enter.your.password.label" , this ) ; final LabeledPasswordTextFieldPanel < String , T > pwTextField = new LabeledPasswordTextFieldPanel < String , T > ( id , model , labelModel ) { private static final long serialVersionUID = 1L ; protected PasswordTextField newPasswordTextField ( final String id , final IModel < T > model ) { final PasswordTextField pwTextField = new PasswordTextField ( id , new PropertyModel < > ( model , "password" ) ) ; pwTextField . setOutputMarkupId ( true ) ; if ( placeholderModel != null ) { pwTextField . add ( new AttributeAppender ( "placeholder" , placeholderModel ) ) ; } return pwTextField ; } } ; return pwTextField ; } | Factory method for creating the EmailTextField for the password . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a EmailTextField for the password . |
8,513 | private void prepareWebView ( ) { mWebView . getSettings ( ) . setJavaScriptEnabled ( true ) ; mWebView . setVisibility ( View . VISIBLE ) ; mWebView . setWebViewClient ( new WebViewClient ( ) { private boolean done = false ; public void onPageFinished ( WebView view , String url ) { if ( ! done && url . startsWith ( mAppInfo . getRedirectUrl ( ) ) ) { done = true ; getCredentials ( url ) ; mWebView . setVisibility ( View . INVISIBLE ) ; } } } ) ; } | Adds a callback on the web view to catch the redirect URL |
8,514 | private void getCredentials ( final String code ) { new AsyncTask < Void , Void , Boolean > ( ) { protected Boolean doInBackground ( Void ... params ) { try { mBootstrapper . getUserCredentials ( code ) ; return true ; } catch ( IOException ex ) { LOGGER . error ( "Error getting oauth credentials" , ex ) ; setResult ( RESULT_CANCELED ) ; finish ( ) ; } catch ( CStorageException ex ) { LOGGER . error ( "Error getting oauth credentials" , ex ) ; setResult ( RESULT_CANCELED ) ; finish ( ) ; } return false ; } protected void onPostExecute ( Boolean result ) { if ( result ) { setResult ( RESULT_OK ) ; } else { setResult ( RESULT_CANCELED ) ; } finish ( ) ; } } . execute ( ) ; } | Gets user credentials and save them If OK set result OK and come back to calling activity |
8,515 | private float [ ] restoreAttribs ( float precision , int [ ] intAttribs ) { int ae = CTM_ATTR_ELEMENT_COUNT ; int vc = intAttribs . length / ae ; float [ ] values = new float [ intAttribs . length ] ; int [ ] prev = new int [ ae ] ; for ( int i = 0 ; i < vc ; ++ i ) { for ( int j = 0 ; j < ae ; ++ j ) { int value = intAttribs [ i * ae + j ] + prev [ j ] ; values [ i * ae + j ] = value * precision ; prev [ j ] = value ; } } return values ; } | Calculate inverse derivatives of the vertex attributes . |
8,516 | private float [ ] restoreUVCoords ( float precision , int [ ] intUVCoords ) { int vc = intUVCoords . length / CTM_UV_ELEMENT_COUNT ; float [ ] values = new float [ intUVCoords . length ] ; int prevU = 0 , prevV = 0 ; for ( int i = 0 ; i < vc ; ++ i ) { int u = intUVCoords [ i * CTM_UV_ELEMENT_COUNT ] + prevU ; int v = intUVCoords [ i * CTM_UV_ELEMENT_COUNT + 1 ] + prevV ; values [ i * CTM_UV_ELEMENT_COUNT ] = u * precision ; values [ i * CTM_UV_ELEMENT_COUNT + 1 ] = v * precision ; prevU = u ; prevV = v ; } return values ; } | Calculate inverse derivatives of the UV coordinates . |
8,517 | private float [ ] restoreNormals ( int [ ] intNormals , float [ ] vertices , int [ ] indices , float normalPrecision ) { float [ ] smoothNormals = calcSmoothNormals ( vertices , indices ) ; float [ ] normals = new float [ vertices . length ] ; int vc = vertices . length / CTM_POSITION_ELEMENT_COUNT ; int ne = CTM_NORMAL_ELEMENT_COUNT ; for ( int i = 0 ; i < vc ; ++ i ) { float magn = intNormals [ i * ne ] * normalPrecision ; double thetaScale , theta ; int intPhi = intNormals [ i * ne + 1 ] ; double phi = intPhi * ( 0.5 * PI ) * normalPrecision ; if ( intPhi == 0 ) { thetaScale = 0.0f ; } else if ( intPhi <= 4 ) { thetaScale = PI / 2.0f ; } else { thetaScale = ( 2.0f * PI ) / intPhi ; } theta = intNormals [ i * ne + 2 ] * thetaScale - PI ; double [ ] n2 = new double [ 3 ] ; n2 [ 0 ] = sin ( phi ) * cos ( theta ) ; n2 [ 1 ] = sin ( phi ) * sin ( theta ) ; n2 [ 2 ] = cos ( phi ) ; float [ ] basisAxes = makeNormalCoordSys ( smoothNormals , i * ne ) ; double [ ] n = new double [ 3 ] ; for ( int j = 0 ; j < 3 ; ++ j ) { n [ j ] = basisAxes [ j ] * n2 [ 0 ] + basisAxes [ 3 + j ] * n2 [ 1 ] + basisAxes [ 6 + j ] * n2 [ 2 ] ; } for ( int j = 0 ; j < 3 ; ++ j ) { normals [ i * ne + j ] = ( float ) ( n [ j ] * magn ) ; } } return normals ; } | Convert the normals back to cartesian coordinates . |
8,518 | public List < Option > getCommandLineOptions ( ) { final List < Option > ret = new LinkedList < Option > ( ) ; String help ; help = TIME_HELP ; ret . add ( new Option ( SHORT_OPT_TIME , LONG_OPT_TIME , false , help ) ) ; help = WARNINGS_AS_ERRORS ; ret . add ( new Option ( null , LONG_OPT_PEDANTIC , false , help ) ) ; help = SYSTEM_CONFIG_PATH ; Option o = new Option ( SHRT_OPT_SYSCFG , LONG_OPT_SYSCFG , true , help ) ; o . setArgName ( ARG_SYSCFG ) ; ret . add ( o ) ; return ret ; } | Returns a list of phase - agnostic command - line options . |
8,519 | private void setOptions ( RuntimeConfiguration rc ) { if ( hasOption ( SHORT_OPT_TIME ) ) { rc . setTime ( true ) ; } if ( hasOption ( LONG_OPT_DEBUG ) ) { rc . setDebug ( true ) ; } if ( hasOption ( LONG_OPT_VERBOSE ) ) { rc . setVerbose ( true ) ; } if ( hasOption ( LONG_OPT_PEDANTIC ) ) { rc . setWarningsAsErrors ( true ) ; } } | Sets the phase - agnostic runtime configuration . |
8,520 | protected void stageOutput ( final String output ) { boolean print = getPhaseConfiguration ( ) . isVerbose ( ) ; if ( print ) { output ( INDENT + INDENT + output ) ; } } | Prints stage output with two levels of indentation . |
8,521 | protected final File createDirectoryArtifact ( final File outputDirectory , final String artifact ) { String path = asPath ( outputDirectory . getAbsolutePath ( ) , artifact ) ; final File ret = new File ( path ) ; if ( ! ret . isDirectory ( ) ) { if ( ! ret . mkdir ( ) ) { error ( DIRECTORY_CREATION_FAILED + ret ) ; bail ( ExitCode . BAD_OUTPUT_DIRECTORY ) ; } } return ret ; } | Creates the directory artifact failing if the directory couldn t be created . |
8,522 | protected static void harness ( PhaseApplication phase ) { try { phase . start ( ) ; phase . stop ( ) ; phase . end ( ) ; } catch ( BELRuntimeException bre ) { err . println ( bre . getUserFacingMessage ( ) ) ; systemExit ( bre . getExitCode ( ) ) ; } catch ( OutOfMemoryError oom ) { err . println ( ) ; oom . printStackTrace ( ) ; long upperlimit = getRuntime ( ) . maxMemory ( ) ; double ulMB = upperlimit * 9.53674316e-7 ; final NumberFormat fmt = new DecimalFormat ( "#0" ) ; String allocation = fmt . format ( ulMB ) ; err . println ( "\n(current allocation is " + allocation + " MB)" ) ; systemExit ( ExitCode . OOM_ERROR ) ; } } | Directs phase application lifecycle . |
8,523 | public URIBuilder queryParameters ( Map < String , String > queryParams ) { this . queryParams . clear ( ) ; this . queryParams . putAll ( queryParams ) ; return this ; } | Set the query parameters |
8,524 | public URIBuilder addParameter ( String key , String value ) { if ( key != null && value != null ) { queryParams . put ( key , value ) ; } return this ; } | Add a single query parameter . Parameter is ignored if it has null value . |
8,525 | public URI build ( ) { StringBuilder builder = new StringBuilder ( baseURI . toString ( ) ) ; builder . append ( path . toString ( ) ) ; if ( queryParams != null && ! queryParams . isEmpty ( ) ) { builder . append ( queryParameters ( ) ) ; } return URI . create ( builder . toString ( ) ) ; } | Build the URI with the given informations |
8,526 | public static void convertNonCanonicalStrings ( final List < Token > sentence , final String lang ) { for ( final Token token : sentence ) { token . setTokenValue ( apostrophe . matcher ( token . getTokenValue ( ) ) . replaceAll ( "'" ) ) ; token . setTokenValue ( ellipsis . matcher ( token . getTokenValue ( ) ) . replaceAll ( THREE_DOTS ) ) ; token . setTokenValue ( longDash . matcher ( token . getTokenValue ( ) ) . replaceAll ( "--" ) ) ; if ( lang . equalsIgnoreCase ( "en" ) ) { token . setTokenValue ( oneFourth . matcher ( token . getTokenValue ( ) ) . replaceAll ( "1\\\\/4" ) ) ; token . setTokenValue ( oneThird . matcher ( token . getTokenValue ( ) ) . replaceAll ( "1\\\\/3" ) ) ; token . setTokenValue ( oneHalf . matcher ( token . getTokenValue ( ) ) . replaceAll ( "1\\\\/2" ) ) ; token . setTokenValue ( threeQuarters . matcher ( token . getTokenValue ( ) ) . replaceAll ( "3\\\\/4" ) ) ; token . setTokenValue ( sterling . matcher ( token . getTokenValue ( ) ) . replaceAll ( "#" ) ) ; } token . setTokenValue ( oneFourth . matcher ( token . getTokenValue ( ) ) . replaceAll ( "1/4" ) ) ; token . setTokenValue ( oneThird . matcher ( token . getTokenValue ( ) ) . replaceAll ( "1/3" ) ) ; token . setTokenValue ( oneHalf . matcher ( token . getTokenValue ( ) ) . replaceAll ( "1/2" ) ) ; token . setTokenValue ( twoThirds . matcher ( token . getTokenValue ( ) ) . replaceAll ( "2/3" ) ) ; token . setTokenValue ( threeQuarters . matcher ( token . getTokenValue ( ) ) . replaceAll ( "3/4" ) ) ; token . setTokenValue ( cents . matcher ( token . getTokenValue ( ) ) . replaceAll ( "cents" ) ) ; } } | Converts non - unicode and other strings into their unicode counterparts . |
8,527 | public static void normalizeQuotes ( final List < Token > sentence , final String lang ) { for ( final Token token : sentence ) { if ( lang . equalsIgnoreCase ( "en" ) ) { token . setTokenValue ( leftSingleQuote . matcher ( token . getTokenValue ( ) ) . replaceAll ( "`" ) ) ; token . setTokenValue ( rightSingleQuote . matcher ( token . getTokenValue ( ) ) . replaceAll ( "'" ) ) ; token . setTokenValue ( leftDoubleQuote . matcher ( token . getTokenValue ( ) ) . replaceAll ( "``" ) ) ; token . setTokenValue ( rightDoubleQuote . matcher ( token . getTokenValue ( ) ) . replaceAll ( "''" ) ) ; } else if ( lang . equalsIgnoreCase ( "ca" ) || lang . equalsIgnoreCase ( "de" ) || lang . equalsIgnoreCase ( "es" ) || lang . equalsIgnoreCase ( "eu" ) || lang . equalsIgnoreCase ( "fr" ) || lang . equalsIgnoreCase ( "gl" ) || lang . equalsIgnoreCase ( "it" ) || lang . equalsIgnoreCase ( "nl" ) || lang . equalsIgnoreCase ( "pt" ) || lang . equalsIgnoreCase ( "ru" ) ) { token . setTokenValue ( toAsciiSingleQuote . matcher ( token . getTokenValue ( ) ) . replaceAll ( "'" ) ) ; token . setTokenValue ( toAsciiDoubleQuote . matcher ( token . getTokenValue ( ) ) . replaceAll ( "\"" ) ) ; } } } | Normalizes non - ambiguous quotes according to language and corpus . |
8,528 | public static void normalizeDoubleQuotes ( final List < Token > sentence , final String lang ) { boolean isLeft = true ; for ( int i = 0 ; i < sentence . size ( ) ; i ++ ) { if ( lang . equalsIgnoreCase ( "en" ) ) { final Matcher doubleAsciiQuoteMatcher = doubleAsciiQuote . matcher ( sentence . get ( i ) . getTokenValue ( ) ) ; final Matcher singleAsciiQuoteMatcher = singleAsciiQuote . matcher ( sentence . get ( i ) . getTokenValue ( ) ) ; if ( doubleAsciiQuoteMatcher . find ( ) ) { if ( isLeft && i < sentence . size ( ) - 1 && doubleAsciiQuoteAlphaNumeric . matcher ( sentence . get ( i + 1 ) . getTokenValue ( ) ) . find ( ) ) { sentence . get ( i ) . setTokenValue ( "``" ) ; isLeft = false ; } else if ( ! isLeft ) { sentence . get ( i ) . setTokenValue ( "''" ) ; isLeft = true ; } } else if ( singleAsciiQuoteMatcher . find ( ) ) { if ( i < sentence . size ( ) - 2 && sentence . get ( i + 1 ) . getTokenValue ( ) . matches ( "[A-Za-z]" ) && sentence . get ( i + 2 ) . getTokenValue ( ) . matches ( "[^ \t\n\r\u00A0\u00B6]" ) ) { sentence . get ( i ) . setTokenValue ( "`" ) ; } } } } } | Normalizes double and ambiguous quotes according to language and corpus . |
8,529 | public String [ ] segmenterExceptions ( final String [ ] lines ) { final List < String > sentences = new ArrayList < > ( ) ; for ( final String line : lines ) { final String segmentedLine = segmenterNonBreaker ( line ) ; final String [ ] lineSentences = segmentedLine . split ( "\n" ) ; for ( final String lineSentence : lineSentences ) { sentences . add ( lineSentence ) ; } } return sentences . toArray ( new String [ sentences . size ( ) ] ) ; } | Segment the rest of the text taking into account some exceptions for periods as sentence breakers . It decides when a period marks an end of sentence . |
8,530 | private String segmenterNonBreaker ( String line ) { line = line . trim ( ) ; line = RuleBasedTokenizer . doubleSpaces . matcher ( line ) . replaceAll ( " " ) ; final StringBuilder sb = new StringBuilder ( ) ; String segmentedText = "" ; int i ; final String [ ] words = line . split ( " " ) ; for ( i = 0 ; i < words . length - 1 ; i ++ ) { final Matcher nonSegmentedWordMatcher = nonSegmentedWords . matcher ( words [ i ] ) ; if ( nonSegmentedWordMatcher . find ( ) ) { final String curWord = nonSegmentedWordMatcher . replaceAll ( "$1" ) ; final String finalPunct = nonSegmentedWordMatcher . replaceAll ( "$2" ) ; if ( ! curWord . isEmpty ( ) && curWord . matches ( "(" + this . NON_BREAKER + ")" ) && finalPunct . isEmpty ( ) ) { } else if ( acronym . matcher ( words [ i ] ) . find ( ) ) { } else if ( nextCandidateWord . matcher ( words [ i + 1 ] ) . find ( ) ) { if ( ! ( ! curWord . isEmpty ( ) && curWord . matches ( NON_BREAKER_DIGITS ) && finalPunct . isEmpty ( ) && startDigit . matcher ( words [ i + 1 ] ) . find ( ) ) ) { words [ i ] = words [ i ] + "\n" ; } } } sb . append ( words [ i ] ) . append ( " " ) ; segmentedText = sb . toString ( ) ; } segmentedText = segmentedText + words [ i ] ; return segmentedText ; } | This function implements exceptions for periods as sentence breakers . It decides when a period induces a new sentence or not . |
8,531 | public String TokenizerNonBreaker ( String line ) { line = line . trim ( ) ; line = RuleBasedTokenizer . doubleSpaces . matcher ( line ) . replaceAll ( " " ) ; final StringBuilder sb = new StringBuilder ( ) ; String tokenizedText = "" ; int i ; final String [ ] words = line . split ( " " ) ; for ( i = 0 ; i < words . length ; i ++ ) { final Matcher wordDotMatcher = wordDot . matcher ( words [ i ] ) ; if ( wordDotMatcher . find ( ) ) { final String curWord = wordDotMatcher . replaceAll ( "$1" ) ; if ( curWord . contains ( "." ) && alphabetic . matcher ( curWord ) . find ( ) || curWord . matches ( "(" + this . NON_BREAKER + ")" ) || i < words . length - 1 && ( startLower . matcher ( words [ i + 1 ] ) . find ( ) || startPunct . matcher ( words [ i + 1 ] ) . find ( ) ) ) { } else if ( curWord . matches ( NON_BREAKER_DIGITS ) && i < words . length - 1 && startDigit . matcher ( words [ i + 1 ] ) . find ( ) ) { } else { words [ i ] = curWord + " ." ; } } sb . append ( words [ i ] ) . append ( " " ) ; tokenizedText = sb . toString ( ) ; } return tokenizedText ; } | It decides when periods do not need to be tokenized . |
8,532 | protected void attachExpansionRuleCitation ( Statement statement ) { AnnotationGroup ag = new AnnotationGroup ( ) ; Citation citation = getInstance ( ) . createCitation ( getName ( ) ) ; citation . setType ( CitationType . OTHER ) ; citation . setReference ( getName ( ) ) ; ag . setCitation ( citation ) ; statement . setAnnotationGroup ( ag ) ; } | Attach citation for expansion rule |
8,533 | public void onSwapToEdit ( final AjaxRequestTarget target , final Form < ? > form ) { swapFragments ( ) ; if ( target != null ) { Animate . slideUpAndDown ( view , target ) ; } else { LOGGER . error ( "AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToEdit(AjaxRequestTarget, Form)" ) ; } modeContext = ModeContext . EDIT_MODE ; } | Swaps from the view fragment to the edit fragment . |
8,534 | public void onSwapToView ( final AjaxRequestTarget target , final Form < ? > form ) { if ( target != null ) { Animate . slideUpAndDown ( edit , target ) ; } else { LOGGER . error ( "AjaxRequestTarget is null on method SwapFragmentPanel#onSwapToView(AjaxRequestTarget, Form)" ) ; } swapFragments ( ) ; modeContext = ModeContext . VIEW_MODE ; } | Swaps from the edit fragment to the view fragment . |
8,535 | private void swapFragments ( ) { final Fragment fragment = view ; view . replaceWith ( edit ) ; view = edit ; edit = fragment ; } | Swap the fragments . |
8,536 | protected void swapFragments ( final AjaxRequestTarget target , final Form < ? > form ) { if ( modeContext . equals ( ModeContext . VIEW_MODE ) ) { onSwapToEdit ( target , form ) ; } else { onSwapToView ( target , form ) ; } } | Swaps the fragments . |
8,537 | public void add ( HtmlObject child ) { asDivPanel ( ) . add ( child ) ; if ( child instanceof AbstractHtmlObject ) { ( ( AbstractHtmlObject ) child ) . setParent ( this ) ; } child . setLeft ( child . getLeft ( ) ) ; child . setTop ( child . getTop ( ) ) ; } | Add a new child HtmlObject to the list . Note that using this method children are added to the back of the list which means that they are added on top of the visibility stack and thus may obscure other children . Take this order into account when adding children . |
8,538 | public void insert ( HtmlObject child , int beforeIndex ) { asDivPanel ( ) . insertBefore ( child , beforeIndex ) ; if ( child instanceof AbstractHtmlObject ) { ( ( AbstractHtmlObject ) child ) . setParent ( this ) ; } child . setLeft ( child . getLeft ( ) ) ; child . setTop ( child . getTop ( ) ) ; } | Insert a new child HtmlObject in the list at a certain index . The position will determine it s place in the visibility stack where the first element lies at the bottom and the last element on top . |
8,539 | public boolean remove ( HtmlObject child ) { if ( child instanceof AbstractHtmlObject ) { ( ( AbstractHtmlObject ) child ) . setParent ( null ) ; } return asDivPanel ( ) . remove ( child ) ; } | Remove a child element from the list . |
8,540 | public static Map < String , List < StringValue > > getPageParametersMap ( final Request request ) { final Map < String , List < StringValue > > map = new HashMap < > ( ) ; addToParameters ( request . getRequestParameters ( ) , map ) ; addToParameters ( request . getQueryParameters ( ) , map ) ; addToParameters ( request . getPostParameters ( ) , map ) ; return map ; } | Gets a map with all parameters . Looks in the query request and post parameters . |
8,541 | public static String getParameter ( final PageParameters parameters , final String name ) { return getString ( parameters . get ( name ) ) ; } | Gets the parameter or returns null if it does not exists or is empty . |
8,542 | public static Integer toInteger ( final StringValue stringValue ) { Integer value = null ; if ( isNotNullOrEmpty ( stringValue ) ) { try { value = stringValue . toInteger ( ) ; } catch ( final StringValueConversionException e ) { LOGGER . error ( "Error by converting the given StringValue." , e ) ; } } return value ; } | Gets the Integer object or returns null if the given StringValue is null or empty . |
8,543 | protected Label newAddTabButtonLabel ( final String id , final IModel < String > model ) { return ComponentFactory . newLabel ( id , model ) ; } | Factory method for creating the new label of the button . |
8,544 | protected WebMarkupContainer newCloseLink ( final String linkId , final int index ) { return new AjaxFallbackLink < Void > ( linkId ) { private static final long serialVersionUID = 1L ; public void onClick ( final AjaxRequestTarget target ) { if ( target != null ) { onRemoveTab ( target , index ) ; } onAjaxUpdate ( target ) ; } } ; } | Factory method for links used to close the selected tab . |
8,545 | protected WebMarkupContainer newLink ( final String linkId , final int index ) { return new AjaxFallbackLink < Void > ( linkId ) { private static final long serialVersionUID = 1L ; public void onClick ( final AjaxRequestTarget target ) { setSelectedTab ( index ) ; if ( target != null ) { target . add ( AjaxAddableTabbedPanel . this ) ; } onAjaxUpdate ( target ) ; } } ; } | Factory method for links used to switch between tabs . |
8,546 | public void onRemoveTab ( final AjaxRequestTarget target , final int index ) { final int tabSize = getTabs ( ) . size ( ) ; if ( ( 2 <= tabSize ) && ( index < tabSize ) ) { setSelectedTab ( index ) ; getTabs ( ) . remove ( index ) ; target . add ( this ) ; } } | On remove tab removes the tab of the given index . |
8,547 | public void onRemoveTab ( final AjaxRequestTarget target , final T tab ) { final int index = getTabs ( ) . indexOf ( tab ) ; if ( 0 <= index ) { onRemoveTab ( target , index ) ; } } | On remove tab removes the given tab if it does exists . |
8,548 | private void setCurrentTab ( final int index ) { if ( this . currentTab == index ) { return ; } this . currentTab = index ; final Component component ; if ( ( currentTab == - 1 ) || tabs . isEmpty ( ) || ! getVisiblityCache ( ) . isVisible ( currentTab ) ) { component = newPanel ( ) ; } else { final T tab = tabs . get ( currentTab ) ; component = tab . getPanel ( TAB_PANEL_ID ) ; if ( component == null ) { throw new WicketRuntimeException ( "ITab.getPanel() returned null. TabbedPanel [" + getPath ( ) + "] ITab index [" + currentTab + "]" ) ; } } if ( ! component . getId ( ) . equals ( TAB_PANEL_ID ) ) { throw new WicketRuntimeException ( "ITab.getPanel() returned a panel with invalid id [" + component . getId ( ) + "]. You always have to return a panel with id equal to the provided panelId parameter. TabbedPanel [" + getPath ( ) + "] ITab index [" + currentTab + "]" ) ; } addOrReplace ( component ) ; } | Sets the current tab . |
8,549 | private boolean isNewGroup ( final OptGroup currentOptGroup ) { return ( last == null ) || ! currentOptGroup . getLabel ( ) . equals ( last . getLabel ( ) ) ; } | Checks if it is new group . |
8,550 | private void seqTrain ( ) throws IOException { final String paramFile = this . parsedArguments . getString ( "params" ) ; final TrainingParameters params = IOUtils . loadTrainingParameters ( paramFile ) ; String outModel = null ; if ( params . getSettings ( ) . get ( "OutputModel" ) == null || params . getSettings ( ) . get ( "OutputModel" ) . length ( ) == 0 ) { outModel = Files . getNameWithoutExtension ( paramFile ) + ".bin" ; params . put ( "OutputModel" , outModel ) ; } else { outModel = Flags . getModel ( params ) ; } final SequenceLabelerTrainer nercTrainer = new SequenceLabelerTrainer ( params ) ; final SequenceLabelerModel trainedModel = nercTrainer . train ( params ) ; CmdLineUtil . writeModel ( "ixa-pipe-ml" , new File ( outModel ) , trainedModel ) ; } | Main access to the Sequence Labeler train functionalities . |
8,551 | private void parserTrain ( ) throws IOException { final String paramFile = this . parsedArguments . getString ( "params" ) ; final String taggerParamsFile = this . parsedArguments . getString ( "taggerParams" ) ; final String chunkerParamsFile = this . parsedArguments . getString ( "chunkerParams" ) ; final TrainingParameters params = IOUtils . loadTrainingParameters ( paramFile ) ; final TrainingParameters chunkerParams = IOUtils . loadTrainingParameters ( chunkerParamsFile ) ; ParserModel trainedModel ; String outModel ; if ( params . getSettings ( ) . get ( "OutputModel" ) == null || params . getSettings ( ) . get ( "OutputModel" ) . length ( ) == 0 ) { outModel = Files . getNameWithoutExtension ( paramFile ) + ".bin" ; params . put ( "OutputModel" , outModel ) ; } else { outModel = Flags . getModel ( params ) ; } if ( taggerParamsFile . endsWith ( ".bin" ) ) { final InputStream posModel = new FileInputStream ( taggerParamsFile ) ; final ShiftReduceParserTrainer parserTrainer = new ShiftReduceParserTrainer ( params , chunkerParams ) ; trainedModel = parserTrainer . train ( params , posModel , chunkerParams ) ; } else { final TrainingParameters taggerParams = IOUtils . loadTrainingParameters ( taggerParamsFile ) ; final ShiftReduceParserTrainer parserTrainer = new ShiftReduceParserTrainer ( params , taggerParams , chunkerParams ) ; trainedModel = parserTrainer . train ( params , taggerParams , chunkerParams ) ; } CmdLineUtil . writeModel ( "ixa-pipe-ml" , new File ( outModel ) , trainedModel ) ; } | Main access to the ShiftReduceParser train functionalities . |
8,552 | private void seqeval ( ) throws IOException { final String metric = this . parsedArguments . getString ( "metric" ) ; final String lang = this . parsedArguments . getString ( "language" ) ; final String model = this . parsedArguments . getString ( "model" ) ; final String testset = this . parsedArguments . getString ( "testset" ) ; final String corpusFormat = this . parsedArguments . getString ( "corpusFormat" ) ; final String netypes = this . parsedArguments . getString ( "types" ) ; final String clearFeatures = this . parsedArguments . getString ( "clearFeatures" ) ; final String unknownAccuracy = this . parsedArguments . getString ( "unknownAccuracy" ) ; final Properties props = setEvalProperties ( lang , model , testset , corpusFormat , netypes , clearFeatures , unknownAccuracy ) ; final SequenceLabelerEvaluate evaluator = new SequenceLabelerEvaluate ( props ) ; if ( metric . equalsIgnoreCase ( "accuracy" ) ) { evaluator . evaluateAccuracy ( ) ; } else { if ( this . parsedArguments . getString ( "evalReport" ) != null ) { if ( this . parsedArguments . getString ( "evalReport" ) . equalsIgnoreCase ( "brief" ) ) { evaluator . evaluate ( ) ; } else if ( this . parsedArguments . getString ( "evalReport" ) . equalsIgnoreCase ( "error" ) ) { evaluator . evalError ( ) ; } else if ( this . parsedArguments . getString ( "evalReport" ) . equalsIgnoreCase ( "detailed" ) ) { evaluator . detailEvaluate ( ) ; } } else { evaluator . detailEvaluate ( ) ; } } } | Main evaluation entry point for sequence labeling . |
8,553 | private void parseval ( ) throws IOException { final String lang = this . parsedArguments . getString ( "language" ) ; final String model = this . parsedArguments . getString ( "model" ) ; final String testset = this . parsedArguments . getString ( "testset" ) ; final Properties props = setParsevalProperties ( lang , model , testset ) ; final ParserEvaluate parserEvaluator = new ParserEvaluate ( props ) ; parserEvaluator . evaluate ( ) ; } | Main parsing evaluation entry point . |
8,554 | private final void tokeval ( ) throws IOException { final String lang = this . parsedArguments . getString ( "language" ) ; final String testset = this . parsedArguments . getString ( "testset" ) ; final Properties props = setTokevalProperties ( lang , testset ) ; final TokenizerEvaluate evaluator = new TokenizerEvaluate ( props ) ; } | Main evaluation entry point for the tokenizer . |
8,555 | private void sequenceCrossValidate ( ) throws IOException { final String paramFile = this . parsedArguments . getString ( "params" ) ; final TrainingParameters params = IOUtils . loadTrainingParameters ( paramFile ) ; final SequenceCrossValidator crossValidator = new SequenceCrossValidator ( params ) ; crossValidator . crossValidate ( params ) ; } | Main access to the sequence labeler cross validation . |
8,556 | private void loadParserTrainingParameters ( ) { this . parserTrainerParser . addArgument ( "-p" , "--params" ) . required ( true ) . help ( "Load the parsing training parameters file.\n" ) ; this . parserTrainerParser . addArgument ( "-t" , "--taggerParams" ) . required ( true ) . help ( "Load the tagger training parameters file or an already trained POS tagger model.\n" ) ; this . parserTrainerParser . addArgument ( "-c" , "--chunkerParams" ) . required ( true ) . help ( "Load the chunker training parameters file.\n" ) ; } | Create the main parameters available for training ShiftReduceParse models . |
8,557 | public void cache ( Integer key , Object value ) { synchronized ( this ) { Integer curkey = keys . get ( value ) ; if ( curkey != null ) return ; cache . put ( key , value ) ; keys . put ( value , key ) ; } } | Caches an object by the provided key . |
8,558 | private void processRangeOptions ( final Map < String , String > properties ) { final String featuresRange = properties . get ( "range" ) ; final String [ ] rangeArray = Flags . processTokenClassFeaturesRange ( featuresRange ) ; if ( rangeArray [ 0 ] . equalsIgnoreCase ( "lower" ) ) { this . isLower = true ; } if ( rangeArray [ 1 ] . equalsIgnoreCase ( "wac" ) ) { this . isWordAndClassFeature = true ; } } | Process the options of which type of features are to be generated . |
8,559 | public T call ( ) throws Exception { T response = requestor . call ( ) ; try { validateResponse ( response ) ; return response ; } catch ( RuntimeException ex ) { if ( response instanceof Closeable ) { PcsUtils . closeQuietly ( ( Closeable ) response ) ; } throw ex ; } } | Performs and validates http request . |
8,560 | public static String getClientIpAddr ( HttpServletRequest request ) { for ( String header : HEADERS_ABOUT_CLIENT_IP ) { String ip = request . getHeader ( header ) ; if ( ip != null && ip . length ( ) != 0 && ! "unknown" . equalsIgnoreCase ( ip ) ) { return ip ; } } return request . getRemoteAddr ( ) ; } | get client ip |
8,561 | public static Cookie findCookie ( HttpServletRequest request , String name ) { if ( request != null ) { Cookie [ ] cookies = request . getCookies ( ) ; if ( cookies != null && cookies . length > 0 ) { for ( Cookie cookie : cookies ) { if ( cookie . getName ( ) . equals ( name ) ) { return cookie ; } } } } return null ; } | find cookie from request |
8,562 | public static String findCookieValue ( HttpServletRequest request , String name ) { Cookie cookie = findCookie ( request , name ) ; return cookie != null ? cookie . getValue ( ) : null ; } | find cookie value |
8,563 | public static String getFullRequestUrl ( HttpServletRequest request ) { StringBuilder buff = new StringBuilder ( request . getRequestURL ( ) . toString ( ) ) ; String queryString = request . getQueryString ( ) ; if ( queryString != null ) { buff . append ( "?" ) . append ( queryString ) ; } return buff . toString ( ) ; } | get request full url include params |
8,564 | public static void redirect ( HttpServletResponse response , String url , boolean movePermanently ) throws IOException { if ( ! movePermanently ) { response . sendRedirect ( url ) ; } else { response . setStatus ( HttpServletResponse . SC_MOVED_PERMANENTLY ) ; response . setHeader ( "Location" , url ) ; } } | redirect to url |
8,565 | public WmsLayer createLayer ( String title , String crs , TileConfiguration tileConfig , WmsLayerConfiguration layerConfig , WmsLayerInfo layerInfo ) { if ( layerInfo == null || layerInfo . isQueryable ( ) ) { return new FeatureInfoSupportedWmsLayer ( title , crs , layerConfig , tileConfig , layerInfo ) ; } else { return new WmsLayerImpl ( title , crs , layerConfig , tileConfig , layerInfo ) ; } } | Create a new WMS layer . This layer does not support a GetFeatureInfo call! If you need that you ll have to use the server extension of this plug - in . |
8,566 | public TileConfiguration createTileConfig ( WmsLayerInfo layerInfo , ViewPort viewPort , int tileWidth , int tileHeight ) throws IllegalArgumentException { Bbox bbox = layerInfo . getBoundingBox ( viewPort . getCrs ( ) ) ; if ( bbox == null ) { throw new IllegalArgumentException ( "Layer does not support map CRS (" + viewPort . getCrs ( ) + ")." ) ; } Coordinate origin = new Coordinate ( bbox . getX ( ) , bbox . getY ( ) ) ; return new TileConfiguration ( tileWidth , tileHeight , origin , viewPort ) ; } | Create a new tile configuration object from a WmsLayerInfo object . |
8,567 | public WmsLayerConfiguration createLayerConfig ( WmsLayerInfo layerInfo , String baseUrl , WmsService . WmsVersion version ) { WmsLayerConfiguration layerConfig = new WmsLayerConfiguration ( ) ; layerConfig . setBaseUrl ( baseUrl ) ; layerConfig . setLayers ( layerInfo . getName ( ) ) ; layerConfig . setVersion ( version ) ; return layerConfig ; } | Create a WMS layer configuration object from a LayerInfo object acquired through a WMS GetCapabilities call . |
8,568 | private File downloadResourceForUse ( String resourceLocation , ResourceType type ) throws ResourceDownloadError { File downloadResource = downloadResource ( resourceLocation , type ) ; return copyResource ( downloadResource , resourceLocation ) ; } | Download and copy the resource for use . |
8,569 | private File copyResource ( final File resource , final String resourceLocation ) throws ResourceDownloadError { final String tmpPath = asPath ( getSystemConfiguration ( ) . getCacheDirectory ( ) . getAbsolutePath ( ) , ResourceType . TMP_FILE . getResourceFolderName ( ) ) ; final String uuidDirName = UUID . randomUUID ( ) . toString ( ) ; final File copyFile = new File ( asPath ( tmpPath , uuidDirName , resource . getName ( ) ) ) ; File resourceCopy = copyToDirectory ( resource , resourceLocation , copyFile ) ; tempResources . add ( new File ( asPath ( tmpPath , uuidDirName ) ) ) ; return resourceCopy ; } | Copy the resource to the system s temporary resources . |
8,570 | private boolean areHashFilesEqual ( File hashFile1 , File hashFile2 , String remoteLocation ) throws ResourceDownloadError { try { String resource1Hash = readFileToString ( hashFile1 , UTF_8 ) ; String resource2Hash = readFileToString ( hashFile2 , UTF_8 ) ; return resource1Hash . trim ( ) . equalsIgnoreCase ( resource2Hash . trim ( ) ) ; } catch ( IOException e ) { throw new ResourceDownloadError ( remoteLocation , e . getMessage ( ) ) ; } } | Compares the hashes contained in the resource files . The hashes in the files are compared case - insensitively in order to support hexadecimal variations on a - f and A - F . |
8,571 | protected RepeatingView newRepeatingView ( final String id , final IModel < T > model ) { final RepeatingView fields = new RepeatingView ( "fields" ) ; form . add ( fields ) ; final T modelObject = model . getObject ( ) ; for ( final Field field : modelObject . getClass ( ) . getDeclaredFields ( ) ) { if ( field . getName ( ) . equalsIgnoreCase ( "serialVersionUID" ) ) { continue ; } final WebMarkupContainer row = new WebMarkupContainer ( fields . newChildId ( ) ) ; fields . add ( row ) ; final IModel < String > labelModel = Model . of ( field . getName ( ) ) ; row . add ( new Label ( "name" , labelModel ) ) ; final IModel < ? > fieldModel = new PropertyModel < Object > ( modelObject , field . getName ( ) ) ; row . add ( newEditorForBeanField ( "editor" , field , fieldModel ) ) ; } return fields ; } | Factory method for creating the RepeatingView . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a RepeatingView . |
8,572 | @ SuppressWarnings ( "unchecked" ) public static < F extends android . support . v4 . app . DialogFragment > F supportFindDialogFragmentByTag ( android . support . v4 . app . FragmentManager manager , String tag ) { return ( F ) manager . findFragmentByTag ( tag ) ; } | Find fragment registered on the manager . |
8,573 | protected Query createQuery ( String typeName , List < AttributeDescriptor > schema , Criterion criterion , int maxFeatures , int startIndex , List < String > attributeNames , String crs ) throws IOException { CriterionToFilterConverter converter = criterionToFilterFactory . createConverter ( ) ; Filter filter = converter . convert ( criterion , schema ) ; Query query = null ; if ( attributeNames == null ) { query = new Query ( typeName , filter , maxFeatures > 0 ? maxFeatures : Integer . MAX_VALUE , Query . ALL_NAMES , null ) ; } else { query = new Query ( typeName , filter , maxFeatures > 0 ? maxFeatures : Integer . MAX_VALUE , attributeNames . toArray ( new String [ attributeNames . size ( ) ] ) , null ) ; } if ( startIndex > 0 ) { query . setStartIndex ( startIndex ) ; } if ( null != crs ) { try { if ( crs . equalsIgnoreCase ( "EPSG:4326" ) ) { crs = "urn:x-ogc:def:crs:EPSG:4326" ; } query . setCoordinateSystem ( CRS . decode ( crs ) ) ; } catch ( NoSuchAuthorityCodeException e ) { log . warn ( "Problem getting CRS for id " + crs + ": " + e . getMessage ( ) ) ; } catch ( FactoryException e ) { log . warn ( "Problem getting CRS for id " + crs + ": " + e . getMessage ( ) ) ; } } return query ; } | Query a geotools source for features using the criterion as a filter . |
8,574 | protected List < Feature > convertFeatures ( FeatureCollection < SimpleFeatureType , SimpleFeature > features , int maxCoordinates , double startDistance ) throws IOException , GeomajasException { FeatureIterator < SimpleFeature > iterator = features . features ( ) ; List < Feature > dtoFeatures = new ArrayList < Feature > ( ) ; FeatureConverter converter = new FeatureConverter ( ) ; while ( iterator . hasNext ( ) ) { try { SimpleFeature feature = iterator . next ( ) ; dtoFeatures . add ( converter . toDto ( feature , maxCoordinates ) ) ; } catch ( Exception e ) { continue ; } } iterator . close ( ) ; return dtoFeatures ; } | Convert a feature collection to its dto equivalent . |
8,575 | protected Bbox getTotalBounds ( List < Feature > features ) { Bbox total = null ; for ( Feature featureDto : features ) { org . geomajas . geometry . Geometry geom = featureDto . getGeometry ( ) ; if ( geom != null ) { Bbox b = GeometryService . getBounds ( geom ) ; if ( total == null ) { total = b ; } else { total = BboxService . union ( total , b ) ; } } } return total ; } | Get the total bounds of all features in the collection . |
8,576 | public void pack ( Map < String , URI > agg , OutputStream out ) throws IOException { JarOutputStream jout = new JarOutputStream ( out ) ; try { URI manifest = agg . get ( "META-INF/MANIFEST.MF" ) ; if ( manifest != null ) { JarEntry entry = new JarEntry ( "META-INF/MANIFEST.MF" ) ; jout . putNextEntry ( entry ) ; StreamUtils . copyStream ( manifest . toURL ( ) . openStream ( ) , jout , false ) ; jout . closeEntry ( ) ; } for ( String name : agg . keySet ( ) ) { if ( name . equals ( "META-INF/MANIFEST.MF" ) ) { continue ; } JarEntry entry = new JarEntry ( name ) ; jout . putNextEntry ( entry ) ; StreamUtils . copyStream ( agg . get ( name ) . toURL ( ) . openStream ( ) , jout , false ) ; jout . closeEntry ( ) ; } } finally { jout . close ( ) ; } } | Just pack fully resolved resources into an outputstream . |
8,577 | public void addSubPath ( Coordinate [ ] coordinates , boolean closed ) { subPaths . add ( new SubPath ( coordinates , closed ) ) ; updateCoordinates ( ) ; } | Add a new sub - path to the path . A path can have multiple sub - paths . Sub - paths may be disconnected lines or rings but thanks to even - odd rule holes can be added as well . |
8,578 | public void addCoordinate ( Coordinate coordinate ) { Coordinate [ ] newCoords = new Coordinate [ coordinates . length + 1 ] ; System . arraycopy ( coordinates , 0 , newCoords , 0 , coordinates . length ) ; newCoords [ coordinates . length ] = coordinate ; setCoordinates ( newCoords ) ; } | Add a coordinate to the path . |
8,579 | public void moveCoordinate ( Coordinate coordinate , int index ) { if ( index < coordinates . length ) { coordinates [ index ] = ( Coordinate ) coordinate . clone ( ) ; } setCoordinates ( coordinates ) ; } | Move the coordinate at the specified index . |
8,580 | public T get ( String key ) { SoftReference < T > ref = cacheMap . get ( key ) ; if ( ref != null ) { if ( ref . get ( ) == null ) { logger . debug ( "Cached item was cleared: " + key ) ; } return ref . get ( ) ; } return null ; } | Retrieves an object from cache . If the object was cleared due to memory demand null will be returned . |
8,581 | protected WebResponse newWebResponse ( final WebRequest webRequest , final HttpServletResponse httpServletResponse ) { return new ServletWebResponse ( ( ServletWebRequest ) webRequest , httpServletResponse ) { public String encodeRedirectURL ( final CharSequence url ) { return isRobot ( webRequest ) ? url . toString ( ) : super . encodeRedirectURL ( url ) ; } public String encodeURL ( final CharSequence url ) { return isRobot ( webRequest ) ? url . toString ( ) : super . encodeURL ( url ) ; } private boolean isRobot ( final WebRequest request ) { final String agent = webRequest . getHeader ( "User-Agent" ) ; return BotAgentInspector . isAgent ( agent ) ; } } ; } | Disable sessionId in the url if it comes from a robot . |
8,582 | public Duration getUptime ( ) { final DateTime startup = getStartupDate ( ) ; if ( null != startup ) { return Duration . elapsed ( Time . valueOf ( startup . toDate ( ) ) ) ; } return Duration . NONE ; } | Gets the elapsed duration since this application was initialized . |
8,583 | protected IDataStore newApplicationDataStore ( ) { final StoreSettings storeSettings = getStoreSettings ( ) ; final Bytes maxSizePerSession = storeSettings . getMaxSizePerSession ( ) ; final File fileStoreFolder = storeSettings . getFileStoreFolder ( ) ; return new DiskDataStore ( this . getName ( ) , fileStoreFolder , maxSizePerSession ) ; } | Factory method that can be overwritten to provide an application data store . Here the default will be returned . |
8,584 | protected void onApplicationConfigurations ( ) { onBeforeApplicationConfigurations ( ) ; onGlobalSettings ( ) ; if ( RuntimeConfigurationType . DEVELOPMENT . equals ( this . getConfigurationType ( ) ) ) { onDevelopmentModeSettings ( ) ; } if ( RuntimeConfigurationType . DEPLOYMENT . equals ( this . getConfigurationType ( ) ) ) { onDeploymentModeSettings ( ) ; } } | Sets the application configurations . |
8,585 | public TileBasedLayer createLayer ( String id , TileConfiguration conf , final TileRenderer tileRenderer ) { return new AbstractTileBasedLayer ( id , conf ) { public TileRenderer getTileRenderer ( ) { return tileRenderer ; } } ; } | Create a new tile based layer with an existing tile renderer . |
8,586 | public MapConfiguration createOsmMap ( int nrOfLevels ) { MapConfiguration configuration = new MapConfigurationImpl ( ) ; Bbox bounds = new Bbox ( - OSM_HALF_WIDTH , - OSM_HALF_WIDTH , 2 * OSM_HALF_WIDTH , 2 * OSM_HALF_WIDTH ) ; configuration . setCrs ( OSM_EPSG , CrsType . METRIC ) ; configuration . setHintValue ( MapConfiguration . INITIAL_BOUNDS , bounds ) ; configuration . setMaxBounds ( Bbox . ALL ) ; List < Double > resolutions = new ArrayList < Double > ( ) ; for ( int i = 0 ; i < nrOfLevels ; i ++ ) { resolutions . add ( OSM_HALF_WIDTH / ( OSM_TILE_SIZE * Math . pow ( 2 , i - 1 ) ) ) ; } configuration . setResolutions ( resolutions ) ; return configuration ; } | Create an OSM compliant map configuration with this number of zoom levels . |
8,587 | private long getLongFromDom ( Document dom , String tag ) { return Long . parseLong ( dom . getElementsByTagName ( tag ) . item ( 0 ) . getTextContent ( ) ) ; } | Retrieves a long value according to a Dom and a tag |
8,588 | private CMBlob getBlobByName ( CMFolder cmFolder , String baseName ) throws ParseException { StringBuilder innerXml = new StringBuilder ( ) ; innerXml . append ( "<folder id=" ) . append ( "'" ) . append ( cmFolder . getId ( ) ) . append ( "'" ) . append ( "/>" ) . append ( "<query>" ) . append ( "\"" ) . append ( XmlUtils . escape ( baseName ) ) . append ( "\"" ) . append ( "</query>" ) . append ( "<count>1</count>" ) ; HttpPost request = buildSoapRequest ( "queryFolder" , innerXml . toString ( ) ) ; CResponse response = retryStrategy . invokeRetry ( getApiRequestInvoker ( request , cmFolder . getCPath ( ) ) ) ; Document dom = response . asDom ( ) ; NodeList elementList = dom . getElementsByTagNameNS ( "*" , "entry" ) ; if ( elementList . getLength ( ) == 0 ) { return null ; } CMBlob cmBlob = CMBlob . buildCMFile ( cmFolder , ( Element ) elementList . item ( 0 ) ) ; return cmBlob ; } | Gets a blob according to the parent folder id of the folder . |
8,589 | private CMFolder loadFoldersStructure ( ) { CMFolder rootFolder = new CMFolder ( getRootId ( ) , "root" ) ; HttpPost request = buildSoapRequest ( "getFolderXML" , "<folder id='" + rootFolder . getId ( ) + "'/>" ) ; CResponse response = retryStrategy . invokeRetry ( getApiRequestInvoker ( request , null ) ) ; Element rootElement = findRootFolderElement ( response . asDom ( ) ) ; scanFolderLevel ( rootElement , rootFolder ) ; return rootFolder ; } | Gets the folders tree structure beginning from the root folder . |
8,590 | private Element findRootFolderElement ( Document dom ) { NodeList list = dom . getElementsByTagNameNS ( "*" , "folder" ) ; final String localRootId = getRootId ( ) ; for ( int i = 0 ; i < list . getLength ( ) ; i ++ ) { Element e = ( Element ) list . item ( i ) ; if ( e . getAttribute ( "id" ) . equals ( localRootId ) ) { return e ; } } throw new CStorageException ( "Could not find root folder with id=" + localRootId ) ; } | Gets the element corresponding to the root folder in the DOM . |
8,591 | private void scanFolderLevel ( Element element , CMFolder cmFolder ) { NodeList nodeList = element . getChildNodes ( ) ; for ( int i = 0 ; i < nodeList . getLength ( ) ; i ++ ) { Node currentNode = nodeList . item ( i ) ; if ( currentNode . getNodeType ( ) != Node . ELEMENT_NODE ) { continue ; } Element currentElement = ( Element ) currentNode ; if ( ! currentElement . getLocalName ( ) . equals ( "folder" ) ) { continue ; } CMFolder childFolder = cmFolder . addChild ( currentElement . getAttribute ( "id" ) , currentElement . getAttribute ( "name" ) ) ; scanFolderLevel ( currentElement , childFolder ) ; } } | Recursive method that parses folders XML and builds CMFolder structure . |
8,592 | private CMFolder createIntermediateFolders ( CMFolder cmRoot , CPath cpath ) { List < String > baseNames = cpath . split ( ) ; CMFolder currentFolder = cmRoot ; CMFolder childFolder = null ; boolean firstFolderCreation = true ; for ( String baseName : baseNames ) { childFolder = currentFolder . getChildByName ( baseName ) ; if ( childFolder == null ) { if ( firstFolderCreation ) { try { CMBlob cmBlob = getBlobByName ( currentFolder , baseName ) ; if ( cmBlob != null ) { throw new CInvalidFileTypeException ( cmBlob . getPath ( ) , false ) ; } } catch ( ParseException e ) { throw new CStorageException ( e . getMessage ( ) , e ) ; } firstFolderCreation = false ; } childFolder = rawCreateFolder ( currentFolder , baseName ) ; } currentFolder = childFolder ; } return childFolder ; } | Creates folder with given path with required intermediate folders . |
8,593 | public static void setTop ( Element element , int top ) { if ( Dom . isIE ( ) ) { while ( top > 1000000 ) { top -= 1000000 ; } while ( top < - 1000000 ) { top += 1000000 ; } } Dom . setStyleAttribute ( element , "top" , top + "px" ) ; } | Apply the top style attribute on the given element . |
8,594 | public static void setLeft ( Element element , int left ) { if ( Dom . isIE ( ) ) { while ( left > 1000000 ) { left -= 1000000 ; } while ( left < - 1000000 ) { left += 1000000 ; } } Dom . setStyleAttribute ( element , "left" , left + "px" ) ; } | Apply the left style attribute on the given element . |
8,595 | private void init ( final String title , final int initialWidth , final int initialHeight , final Component component ) { if ( title != null ) { setTitle ( title ) ; } setInitialWidth ( initialWidth ) ; setInitialHeight ( initialHeight ) ; setContent ( component ) ; } | Initialize the given fields . |
8,596 | public List < Annotation > getAllAnnotations ( ) { List < Annotation > ret = new ArrayList < Annotation > ( ) ; if ( annotationGroup != null ) ret . addAll ( annotationGroup . getAnnotations ( ) ) ; if ( statements != null ) { for ( final Statement stmt : statements ) { AnnotationGroup ag = stmt . getAnnotationGroup ( ) ; if ( ag != null && hasItems ( ag . getAnnotations ( ) ) ) { ret . addAll ( ag . getAnnotations ( ) ) ; } } } if ( statementGroups != null ) { for ( final StatementGroup sg : statementGroups ) ret . addAll ( sg . getAllAnnotations ( ) ) ; } return ret ; } | Returns a list of all annotations contained by this statement group its statements and nested statement groups . |
8,597 | public List < Parameter > getAllParameters ( ) { List < Parameter > ret = new ArrayList < Parameter > ( ) ; if ( statements != null ) { for ( final Statement stmt : statements ) ret . addAll ( stmt . getAllParameters ( ) ) ; } if ( statementGroups != null ) { for ( final StatementGroup sg : statementGroups ) ret . addAll ( sg . getAllParameters ( ) ) ; } return ret ; } | Returns a list of all parameters contained by this statement group s statements and nested statement groups . |
8,598 | public List < Statement > getAllStatements ( ) { List < Statement > ret = new ArrayList < Statement > ( ) ; if ( statements != null ) { ret . addAll ( statements ) ; } if ( statementGroups != null ) { for ( final StatementGroup sg : statementGroups ) ret . addAll ( sg . getAllStatements ( ) ) ; } return ret ; } | Returns a list of all statements contained by this statement group s statements and nested statement groups . |
8,599 | public void removeGeometry ( Geometry geometry ) throws GeometryMergeException { if ( ! busy ) { throw new GeometryMergeException ( "Can't remove a geometry if no merging process is active." ) ; } geometries . remove ( geometry ) ; eventBus . fireEvent ( new GeometryMergeRemovedEvent ( geometry ) ) ; } | Remove a geometry from the merging list again . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.