input
stringlengths
10
828
output
stringlengths
5
107
private string reversed string tokens string ts tokens split s s string result for int i ts length 1 i 0 i result i return result trim
turn b a to a b
public boolean is name string text try checking in the hns if text contains if check hnsserver text substring 0 text index of return true else if check hnsserver text return true checking in zoobank if check zoobank server text return true catch exception exe exe print stack trace return false
this function tells if text is a name recognized by any name server
private boolean check hnsserver string text throws exception parser parser new parser application utilities get property hns text tag name filter filter new tag name filter tr node list list parser parse filter boolean found false for int i 1 i list size i found process my nodes text list element at i false if found break return found
this function checks the name in hns server
public boolean is name string text string source try if source equals ignore case hns return check hnsserver text if source equals ignore case zoobank return check zoobank server text catch exception exe exe print stack trace return false
this function checks whether the name exists in the given server
public string annotate names string segment string source not working on this now return null
this function annotates a text segment using the src name server
private string fix num text mix string mix file source string buffer fixed new string buffer pattern p pattern compile d a z matcher m p matcher mix while m matches fixed append m group 1 append num string save m group 2 m group 3 save save substring 0 save length mixlength save length mixlength save to table mix m group 3 try statement stmt conn create statement stmt execute insert into tablename1 mix file values save source get name catch exception e e print stack trace fixed append mix return fixed to string
save original text mix in file source in a table
private void output throws parsing exception try string file target extracted count xml document doc new document treatment buffered output stream out new buffered output stream new file output stream file producer outputter output doc out consumer listener info count file catch ioexception e logger error exception in volume extractor output e throw new parsing exception e
to output the treatment element
private void update glossary try statement stmt conn create statement string q select distinct term decision from this data prefix group decisions as t1 this data prefix grouped terms as t2 where term not in select term from fnaglossary and t1 group id t2 group id result set rs stmt execute query q statement stmt1 conn create statement while rs next string q1 insert into fnaglossary term category status values rs get string term rs get string decision learned stmt1 execute q1 stmt1 close rs close stmt close catch exception e e print stack trace
add new character state to glossary
private void adjust pointer4 dot long int pointer boolean iscase false while this chunkedtokens size pointer this chunkedtokens get pointer trim length 0 pointer if this chunkedtokens size pointer this chunkedtokens get pointer trim matches optional pointer while this chunkedtokens size pointer this chunkedtokens get pointer trim length 0 pointer while this chunkedtokens size pointer this chunkedtokens get pointer trim matches long broad wide thick required pointer iscase true if iscase this pointer pointer
needed for cases like 10 cm
public int compare state group g1 state group g2 if g1 to string compare to g2 to string 0 return 0 each g is different not possible to return 0 int known1 g1 number of associated int known2 g2 number of associated int count1 g1 get count int count2 g2 get count int v known1 known2 if v 0 return count2 count1 any order is fine else return v
order by number of associated size
public void open throws exception final display display display get default device data data new device data data tracking true final display display new display data sleak sleak new sleak sleak open red display get system color swt color red green display get system color swt color green create contents display shell open shell layout while shell is disposed if display read and dispatch display sleep if shell is disposed system exit 0
open the window
private boolean verify file boolean passed true for int i 1 i total i file file new file path i xml if file exists listener info file get name file does not exist passed false else if file is file listener info file get name file is not a file passed false return passed
to verify the extracted files validity
private void parse sentences enumeration en sentences keys while en has more elements integer key integer en next element int sentid key int value string taggedsent string sentences get key parse sentence sentid taggedsent
parse or and to patterns
protected string standardize string t string tokens t split s string result for int i 0 i tokens length i string st this locations get tokens i if st null st this statenames get tokens i if st null result tokens i else result st return result trim
s africa south africa
public void set pointer2 next comma for this pointer this chunkedtokens size pointer if this chunkedtokens get pointer matches break
when parsing fails at certain point forward the pointer to the next comma
public void run listener set progress bar visible true transform listener set progress bar visible false
transform the extracted data to the xml format
private int get distance int arow int rownumber for int i arow length 1 i 0 i if arow i 1 return i rownumber return 0
the distance between a 1 in upper matrix to the diagonal line
protected void parse sentences enumeration string en sentences keys while en has more elements string source en next element string taggedsent string sentences get source parse sentence source taggedsent
parse or and to patterns
private string tag states string sent string taggedsent pattern tagsp pattern compile b this statespatterns b pattern case insensitive matcher m tagsp matcher sent while m matches taggedsent m group 1 m group 2 sent m group 3 m tagsp matcher sent taggedsent sent return taggedsent replace all
tag states with
private string string colors string text boolean did false string pt b this colors s this colors b pattern p pattern compile pt matcher m p matcher text while m find text text replace first pt c m p matcher text did true if did system out println color text return text
turn reddish purple to reddish purple
private void save tag try main db save tag data tag table catch exception exe logger error exception encountered in loading tags from database in main form save tag exe exe print stack trace load tag table reset context box context styled text set text
this is used when save is clicked on step5
private boolean un paired terms array list terms data bean terms iterator terms data bean it terms iterator while it has next terms data bean tdb it next if tdb get term2 null tdb get term2 length 0 return false return true
check and see if terms contains only term1s
private int get number of groups saved int return value 0 set string keys group info key set for string key keys character group bean char grp bean group info get key if char grp bean is saved return value return return value
this function checks how
public int get games return games
the games this team currently has
public string get non tie break points try return point representation get points catch index out of bounds exception e return
the points this team has in current set formatted for printing
public string get html name return string escape utils escape html name
the teams html displayable name
public void inc games team team team info tennis team info tennis get team info tennis team team info tennis inc games action log added game to team info tennis get name team info tennis get games
increase number of games for team
public int get games team team team info tennis team info tennis get team info tennis team return team info tennis get games
number of won games in the current set for the team
private void initialize map team team info clone teams this teams new hash map team team info if clone teams null for team t clone teams key set this teams put t clone teams get t clone this action log impl new action log impl
sets up a newly created or newly cloned
public int get previous games team team team info tennis team info tennis get team info tennis team list integer past set games team info tennis get past set games if past set games size 0 return 1 return past set games get past set games size 1
number of won games in the past set for the team
public string get default game try string default game null for iterator it game model config keys it has next string game string it next jsonobject options game model config get jsonobject game opt jsonobject options if options null options opt boolean option default if default game null throw new runtime exception more than one default game in config file name default game game default game game return default game catch jsonexception e throw new runtime exception error in config file name e
tells which game is configured as default game
public void reset games for team info ti current teams values team info tennis team info tennis team info tennis ti team info tennis add past set games team info tennis get games team info tennis reset games team info tennis reset points action log reset games and points counters
reset game and point counters
protected game state ifc new game state return new game state
instantiates a new game state instance appropriate for this game model
protected game state current return game state undo stack current
provides the current state
public void dec points string previous printable points get non tie break points for team team team values get team info tennis team dec points action log reduced points from previous printable points to get non tie break points
reduce number of points for all teams
private string get non tie break points return string format s s get team info tennis team left get non tie break points get team info tennis team right get non tie break points
format current points for log output
public string create error page throwable exc string writer error sw new string writer exc print stack trace new print writer error sw velocity context context new velocity context context put css file style file context put error error sw to string string writer page sw new string writer try ve merge template error vm context page sw catch exception e page sw write error output failed exc return page sw to string
create an error page for the given throwable
private team info tennis get team info tennis team team return team info tennis current teams get team
current team info for tennis
public string create message page string message throws exception velocity context context new velocity context context put css file style file context put message message string writer page sw new string writer ve merge template message vm context page sw return page sw to string
create a generic message page
public string create sign in page string ticket out throws exception velocity context context new velocity context context put css file style file context put ticket out ticket out string writer page sw new string writer ve merge template sign in vm context page sw return page sw to string
create the controller sign in page
public string create score board page context context throws exception context put refresh seconds config client poll interval sec context put css file style file string writer w new string writer ve merge template template file context w return w to string
create a counter page for the given context
protected void set decision reached game model ifc model boolean reached logic may be added by sub classes
propagate the information if the decision has been reached to child
protected string to string string indentation string builder sb new string builder sb append indentation this get class get simple name append arguments sb sb append return sb to string
pretty printed recursive output of command processor configuration
private void generate next previous value current value current value new string builder append random string random string length append append counter to string to string
advances the sequence to the next value
protected void append arguments string builder sb sub classes may add actions
sub classes may append their arguments to by overriding this method
private boolean is current string ticket return string utils equals ticket current value
tells if the provided ticket is the current ticket
public sequence map explode sequence map exploded new sequence map exploded put get command processor sequence this return exploded
creates a collection of command processors with the same behavior
private boolean is previous string ticket return string utils equals ticket previous value
tells if the provided ticket is the one from before the current one
protected int sum sets game model ifc model int total sets 0 for team t team values total sets model get sets t return total sets
sums all sets that the teams currently have
private string random string int length string builder sb new string builder length while sb length length int rand pos int floor random random chars length sb append random chars char at rand pos return sb to string
creates a random string of requested length with randomly selected
protected int sum points game model ifc model int total points 0 for team t team values total points model get points t return total points
sums all points that the teams currently have
public http server get server return server
the server instance
public game factory get factory if factory null synchronized this could have been created while waiting for lock if factory null factory new game factory game mode return factory
provides the central code game factory code instance
private void engage shutdown new thread override public void run wait for incoming calls try thread sleep config server shutdown delay sec 1000 catch interrupted exception e go on wait for current calls to finish server stop config server shutdown delay sec start
start delayed server shutdown
public uri get viewer uri return get uri viewer path null
uri for viewer
public uri get controller uri return get uri contoller path null
uri for controller
public game model ifc model return model
the model instance for mvc strategy
public uri get controller uri string cmd string query command cmd return get uri contoller path query
uri for controller with command
private uri get uri string relative path string query string path add trailing slash config base path relative path try return new uri http null config host config port path query null catch urisyntax exception e throw new runtime exception uri configuration problem e
uri for given parameters
public html view view return view
the view instance for mvc strategy
public command processor ifc get command processor return command processor
the command processor for executing controller commands
public string get base path return add trailing slash config base path
returns base path
private command processor ifc create command processor game mode game mode command processors com procs new command processors com procs add new undo processor com procs add new server state processor com procs add new teams processor try for command processor cp new command processors game mode get logic com procs add all cp explode values catch jsonexception e throw new runtime exception failed instantiating game logic e command processor composite result new command processor composite com procs log debug result return result
builds the appropriate command processor for the active game
protected void action log string msg current action log impl add msg log info msg
logs a message for an undoable action
private boolean multiline contains string page string regex pattern return page matches s regex pattern
looks for regex pattern in whole page
private void server log string msg log info msg
logs a message for an operation that can not be undone
public gaboto get gaboto return gaboto
returns the gaboto model this snapshot is built upon
public long size return model size
returns the number of triples in the underlying model
public time span get time span for entity resource res return get time span for entity res get uri
extracts additional time information for an entity represented by its rdf resource
public time span get time span for entity string uri try return gaboto get entitys lifetime uri catch entity does not exist exception e return null
extracts additional time information for an entity represented by its uri
public void set gaboto gaboto gaboto this gaboto gaboto
sets the gaboto model this query should be working on
public property get property string property uri return model get property property uri
extracts a property object for a given uri
public resource get resource string uri throws resource does not exist exception if contains resource uri throw new resource does not exist exception uri return model get resource uri
returns an rdf resource
public boolean contains resource string uri return model get graph contains node create uri uri node any node any
tests if a resource with the specified uri exists
public boolean contains resource resource res return contains resource res get uri
tests if a resource exists
public boolean is supported format string format for string s get supported formats if s equals format return true return false
tests if the query supports the passed output format
public entity pool load entities with property property prop collection resource resources new hash set resource res iterator it model list resources with property prop while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public entity pool load entities with property property prop boolean value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public void add string graph time span ts system err println tdi adding graph lookup put graph ts
adds another graph to the index
public void add named graph graph time span ts add graph get graph name get uri ts
adds another graph to the index
public entity pool load entities with property property prop char value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public time span canonicalize if has fixed duration return time span create from instants get begin get end return this
returns a canonicalized version of this time span
public entity pool load entities with property property prop double value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public boolean can unify time instant ti if this start year equals ti get start year if this get start month null ti get start month null return true else if this get start month equals ti get start month if this get start day null ti get start day null system err println can unify return true else if this get start day equals ti get start day system err println can unify return true return false
tests if an instant is roughly the same
public entity pool load entities with property property prop float value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public void set start day integer start day if start day null start day 31 throw new illegal argument exception there is no month with more than 31 days argument was start day if start day null start day 1 throw new illegal argument exception days start with day 1 start day this start day start day
sets the starting point day
public entity pool load entities with property property prop long value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public void set start month integer start month if start month null start month int value 11 throw new illegal argument exception there is no year with more than 12 months zero based argument was start month if start month null start month int value 0 throw new illegal argument exception month number start month this start month start month
sets the starting point month
public entity pool load entities with property property prop object value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resources add it next resource return load entity pool from resources resources
loads entities that have a certain property
public int get start unit if start day null return start unit day else if start month null return start unit month return start unit year
returns the resolution of this time span
public entity pool load entities with property property prop rdfnode value system err println value value collection resource resources new hash set resource res iterator it model list resources with property prop value while it has next resource r it next resource system err println adding r resources add r return load entity pool from resources resources
loads entities that have a certain property
public integer get duration day return duration day null 0 duration day
returns the duration of days
private entity pool load entity pool from resources collection resource resources entity pool configuration pool config new entity pool configuration this pool config set resources resources pool config set add referenced entities to pool false return entity pool create from pool config
creates an entity pool from some resources out of this snapshot
public gaboto entity load entity string uri collection resource res col new hash set resource resource res try res this get resource uri catch resource does not exist exception e throw new entity does not exist exception uri res col add res create config entity pool configuration config new entity pool configuration this config set resources res col entity pool pool entity pool create from config return pool get entity uri
loads a specific entity
public void set duration day integer duration day if duration day null duration day 31 throw new illegal argument exception there is no month on earth that has more than 31 days you might just want to add an extra month if duration day null this duration day null else this duration day duration day 0 null duration day
sets the duration of days
public gaboto snapshot exec sparqlconstruct string query query execution qexec query execution factory create query get model model m null try m qexec exec construct finally qexec close return new gaboto snapshot m gaboto
executes a construct sparql query
public integer get duration month return duration month null 0 duration month
returns the duration of months
public gaboto snapshot exec sparqldescribe string query query execution qexec query execution factory create query get model model m null try m qexec exec describe finally qexec close return new gaboto snapshot m gaboto
executes a describe sparql query
public void set duration month integer duration month if duration month null duration month 12 throw new illegal argument exception there is no year on earth that has more than 12 months you might just want to add an extra year if duration month null this duration month null else this duration month duration month 0 null duration month
sets the duration of months
public boolean exec sparqlask string query query execution qexec query execution factory create query get model boolean result false try result qexec exec ask finally qexec close return result
executes an ask sparql query