input
stringlengths
10
828
output
stringlengths
5
107
public void pause game system out println pause key pressed doesn t do anything yet
pause the game fixme essentially this should pause all the threads
public void display results ituple results system out println results if results null system out println none return for ituple t results document doc document field t get payload get value system out println doc get base uri
very non fancy display of the results retrieved from the tuple space
public string input search return joption pane show input dialog enter your search scanner sc new scanner system in system out println enter your search return sc next line
very rudimentary ui to get users xpath search expression
public void add string filename throws exception dom factory boilerplate document builder factory dom factory document builder factory new instance dom factory set namespace aware true never forget this document builder builder dom factory new document builder file thefile new file filename system out println thefile get absolute path document doc builder parse thefile this add filename doc
loads xml files to the database
protected void add query template ituple tpl tsscanner scanner new tsscanner tpl worker inbox template scanners put tpl scanner scanner start
add a query template and a thread to scan for that template
public string to string string result null if varname null if is formal result varname else result varname else result super to string return result
returns a string representation of the tuple
public void stop super stop for tsscanner scanner template scanners values scanner mystop
stop this worker
protected void ignore query ituple template ituple query ituple key template list ituple list null if key null template scanners contains key key tsscanner searchscanner template scanners get key searchscanner ignore query log debug name added query to be ignored query else log debug name doesn t have search among his templates
adds a tuple to the list of done queries
protected void add listener tuple listener listener ituple template query listener lis new query listener listener template lis start synchronized search listeners search listeners add lis log debug returning from launching an async search
add a listener for asynchronous search responses
public ituple space get ts return space
only for testing purpose
protected void asynchronous query ituple query ituple answer template tuple listener listener throws tuple space exception space out query add listener listener answer template add a listener for this query
method to do asynchronous queries on the tuple space output query register listener
public void out ituple tuple throws tuple space exception synchronized this insert tuple tuple notify all
inserts a tuple in the tuple space
public boolean matches ifield field if type null throw new illegal argument exception template fields type must refer to a non null object else if formal field instanceof ivalued field ivalued field field is formal i e either this or field is formal return type is assignable from field get type else i e both of them are actual ivalued field f ivalued field field return type is assignable from field get type value equals f get value
determines the rule used for pattern matching between fields
public string to string return new string rappresentazione di un sub type field non implementata
returns a string representation of the tuple
public void outg ituple tuples throws tuple space exception synchronized this for int i 0 i tuples length i insert tuple tuples i notify all
inserts multiple tuples in the tuple space
public void work answer all queries from supported templates answer queries
work normal processing of this worker
public regex field set pattern string pattern this pattern pattern compile pattern return this
it sets the pattern used for regular expression matching
public ituple in ituple template throws tuple space exception ituple result null synchronized this while result null result inp template if result null try wait catch interrupted exception e throw new tuple space error internal error halting return result
withdraws from the tuple space a tuple matching the templates specified
public regex field set pattern string pattern int flags this pattern pattern compile pattern flags return this
it sets the pattern used for regular expression matching with relative
public ituple inp ituple template throws tuple space exception ituple result null synchronized this if ts size 0 result lookup tuple template false return result
withdraws from the tuple space a tuple matching the templates specified
public range field set lower bound comparable low boolean included if up null up compare to low 0 throw new illegal argument exception lower bound must be strictly lesser than upper bound else this low low lowinc included return this
set the ranges lower bound
public string to string string toreturn tuple node node tuples get root while node null toreturn node tuple to string n toreturn sem permits node semaphore available permits n node node next return toreturn
warning not thread safe only present for test purposes
public boolean matches ifield field if type null throw new illegal argument exception template fields type must refer to a non null object else if field instanceof ivalued field ivalued field field is formal i e field is formal return type equals field get type else if type equals field get type false pre matching based on type if types are different matching is false return false ivalued field f ivalued field field boolean value match true boolean result f get type is assignable from string class if result result pattern matcher string f get value matches return result
determines the rule used for pattern matching between fields
public range field set upper bound comparable up boolean included if low null low compare to up 0 throw new illegal argument exception upper bound must be strictly greater than upper bound else this up up upinc included return this
set the ranges upper bound
public string to string return new string rappresentazione di un regex field non implementata return pattern
modified this from the original version
public ituple rd ituple template throws tuple space exception ituple result null synchronized this while result null result rdp template if result null try wait catch interrupted exception e throw new tuple space error internal error halting return result
reads from the tuple space a copy of a tuple matching the templates
public comparable get lower bound return low
returns the lower bound object
public comparable get upper bound return up
returns the upper bound object
public ituple rdp ituple template throws tuple space exception ituple result null synchronized this if ts size 0 result lookup tuple template true return result
reads from the tuple space a copy of a tuple matching the templates
public boolean is lower bound included return lowinc
returns code true code if the lower bound is included in the
public boolean is upper bound included return upinc
returns code true code if the lower bound is included in the
public boolean is empty boolean ans root null return ans
check if the list isnt empty
public string to string string content size ts size n for ituple it ts content it to string n return content
returns a string representation of the tuple space
public string to string return new string rappresentazione di un range field non implementata
returns a string representation of the tuple
public ituple remove head tuple if root null return null ituple to return null try lock head permit number root semaphore acquire get a read right on the root node to return root tuple get the tuple in the first node root semaphore release release just in case it has an effect on memory root root next define the new root as the first node inserted release head permit number catch interrupted exception e e print stack trace lock the list for writing return to return
remove and return the first tuple in this list
public ituple read head tuple if root null return null ituple to return null try lock head 1 get reading rights on the list root semaphore acquire get a read right on the root node to return root tuple get the tuple in the first node release head 1 root semaphore release catch interrupted exception e e print stack trace lock the list for writing return to return
read the first tuple in the list
public object get value if is formal throw new illegal argument exception impossible to get the value of a formal field return value
returns the value of this field
public tuple node get root return root
get the root node of the linked list
public ivalued field set value object value if value null throw new illegal argument exception value must refer to a non null object if value instanceof serializable throw new illegal argument exception values of lights field must be serializable this value serializable value this type value get class formal false return this
sets the value of this field to the object passed as a parameter
public boolean is formal return formal
returns code true code if the field is a formal code false code
public sync iterator iterator mode mode return new sync iterator this mode
creates an iterator for this linked list capable of the mode operations
public ituple add ifield field fields add element field return this
adds a field at the end of the tuple
public ituple set ifield field int index fields set element at field index return this
replaces the field at position code index code with the given one
public boolean equals object o if o instanceof ivalued field return false get rid of non fields ivalued field field ivalued field o boolean are equal type equals field get type same type if formal return are equal field is formal else the current field is actual if ivalued field field is formal if the other is formal return false else if they re both actual then their values must match return are equal value equals field get value values are the same
equals determines if two fields are identical stronger than matching
public ifield get int index return ifield fields element at index
returns the field at position code index code
public ituple insert at ifield field int index fields insert element at field index return this
inserts the given field at position code index code
public ituple remove at int index fields remove index return this
removes the field at position code index code
public int length return fields size
returns the number of fields in the tuple
public boolean matches ituple tuple if fields size 0 return true if this equals tuple return true boolean matching fields size tuple length int i 0 while matching i fields size matching matching ifield fields element at i matches tuple get i i return matching
determines the rule used for pattern matching between tuples
public boolean has next if current null case where we haven t started iterating if thelist is empty removal flag list is empty or we ve reached the end by removing the last element of the list return false return true if current next null return false return true
determine whether the iterator is at the end of the list or not
public boolean equals object tuple if tuple instanceof tuple tuple thetuple tuple tuple boolean matching fields size thetuple length int i 0 while matching i fields size matching matching ifield fields element at i equals thetuple get i i return matching else return false
determines whether two tuples are exactly identical stronger than matching
public void start int permits permit number if current mode mode read permits 1 try lock the head of the list i e acquire the right number of permits from it thelist lock head permits catch interrupted exception e todo auto generated catch block e print stack trace
initialize the iterator by locking the head of the list
public ituple inp ituple template throws tuple space exception return lookup tuple template false
in this implementation the returned tuple is the first one
protected connection get connection throws sqlexception return driver manager get connection db url
this method returns a connection
public boolean does email id exist user user throws exception boolean returnvalue false connection conn null prepared statement pstmt null result set rset null try conn get connection pstmt conn prepare statement select count as count from users where email pstmt set string 1 user get user email trim rset pstmt execute query if rset next int count rset get int count if count 0 returnvalue true catch exception exe exe print stack trace logger error unable to check if the email exists throw exe finally close connection pstmt rset conn return returnvalue
this function checks if the emailid is already taken
public boolean update user status user user throws exception boolean return value false connection conn null prepared statement pstmt null string sql update users set status where userid try conn get connection pstmt conn prepare statement sql pstmt set string 1 user is active y n pstmt set int 2 user get user id pstmt execute return value true catch exception exe exe print stack trace logger error unable to update user status exe throw exe finally close connection pstmt conn return return value
this function updates the users status
public string get file info string file name file file new file resource bundle get string filepath file name string builder text new string builder string nl system get property line separator scanner scanner null try scanner new scanner new file input stream file while scanner has next line text append scanner next line nl catch exception exe exe print stack trace logger error error reading file exe finally scanner close return text to string
this method gets the file information from the transformed folder
private void cleanse character group bean cbean array list terms group cooccurrences cbean get cooccurrences for terms group term group cooccurrences if term group get term get term equals term group set term null if term group get co occured term get term equals term group set co occured term null
this private function cleanses the cbean from blank terms
private void select file answerdir new file this answerdir file alist answerdir list files for int i 0 i alist length i string fname alist i get name string content read this outdir fname output this selectdir fname content
use the answerdir to select xml files for evaluation
public string get complete node structure node bean node boolean is for report string complete node complete node get dtree node node is for report if node get is leaf complete node div class clip id node get id array list structure node bean childen list node get childen list for int i 0 i childen list size i complete node get complete node childen list get i is for report complete node div return complete node
generate the html of node and its childen
private void output hashtable string list collection string field enumeration string en collection keys while en has more elements string id en next element list object structs collection get id iterator object it structs iterator while it has next element s element it next string value format values field id s insert field value
save results into database table
public string get filename of family description string family name string result result set rs null connection conn null try conn get connection database statement s conn create statement rs s execute query select filename from fnav19 filename2taxon where family family name and subfamily and tribe and subtribe and genus and subgenus and section and subsection and species and subspecies and variety while rs next result rs get string filename catch sqlexception e e print stack trace finally try conn close catch sqlexception e e print stack trace return result
get the filename for the family description of a taxon
public connection get connection string database throws sqlexception connection con null try class for name driver con driver manager get connection url database user password catch class not found exception e system out println e get message system exit 1 return con
gets a new connection to a my sql database
public itaxon parse taxon itaxon taxon taxon factory get taxon object taxon rank taxon name try unmarshaller unmarshaller annotation context create unmarshaller string filename filename taxon dao get filename for description taxon rank taxon name string path props get property input path filename treatment treatment treatment unmarshaller unmarshal new file path description description treatment get description list statement statement list description get statement build structure tree taxon statement list for statement statement statement list taxon add statement text entry statement get id statement get text catch jaxbexception e e print stack trace taxon normalize all names return taxon
parses the file of the taxon
public void taxon to sdd itaxon taxon string filename try marshaller marshaller sdd context create marshaller datasets root sdd factory create datasets add metadata root add dataset root taxon marshaller marshal root new file filename catch jaxbexception e e print stack trace
transform the model for a single taxon into an sdd document
public void taxon hierarchy to sdd taxon hierarchy hierarchy string filename try marshaller marshaller sdd context create marshaller datasets root sdd factory create datasets add metadata root add dataset root hierarchy marshaller marshal root new file filename system out println modifier map for string s this state to modifier key set system out println s map character local state def modifier def map this state to modifier get s for character local state def state map key set system out println t state map get state system out println end modifier map catch jaxbexception e e print stack trace
converts a taxon hierarchy into an associated sdd xml file
public void taxon to rdf itaxon taxon string filename model taxon model model factory create default model add taxonomy vocabulary statements taxon model taxon iterator tree node structure structures taxon get structure tree iterator add structures to model taxon model structures add relations to model taxon model taxon get relations write rdf taxon model filename
convert a taxon object into an rdf model
public model taxon to rdf itaxon taxon model taxon model model factory create default model add taxonomy vocabulary statements taxon model taxon iterator tree node structure structures taxon get structure tree iterator add structures to model taxon model structures add relations to model taxon model taxon get relations return taxon model
create an rdf model for a given taxon object
public taxon hierarchy get hierarchy return hierarchy
returns the underlying taxon hierarchy for this matrix
public void print simple for string s this table key set map itaxon istate map table get s for itaxon taxon map key set system out println character s taxon taxon get name map get taxon to string
pretty prints the table
private void add modifier model taxon model statement statement istate state property modifier predicate new property impl rdf props get property prefix modifier literal modifier taxon model create typed literal state get modifier taxon model add taxon model create reified statement rdf props get property prefix reified concat statement get subject get local name concat statement get predicate get local name statement modifier predicate modifier taxon model remove statement
attach a modifier to the rdf model
private void add relations to model model taxon model list relation relations for relation r relations resource from taxon model get resource rdf props get property prefix structure concat structure r get from get 0 get name resource to taxon model get resource rdf props get property prefix structure concat structure r get to get 0 get name property predicate new property impl rdf props get property prefix property concat r get name taxon model add from predicate to
adds all of the relations to the model
private void write rdf model m string filename rdfwriter writer m get writer rdf xml writer set property allow bad uris true output stream out null try out new file output stream filename catch file not found exception e e print stack trace writer write m out xml rdf try out close catch ioexception e e print stack trace
write an rdf model to file with given filename
protected void add dataset datasets root itaxon taxon dataset dataset sdd factory create dataset dataset set lang en us add taxon name to dataset dataset taxon add representation to dataset dataset taxon add descriptive concepts to dataset dataset taxon null add coded description to dataset dataset taxon root get dataset add dataset
adds a dataset to the root datasets object using data from taxon object
public void set root tree node t root this root root
set the root of this tree
public void add child tree node t child child set parent this this children add child
add a child node to this node
public void add children collection t children for t child children tree node t tree node new tree node t child tree node set parent this this children add tree node
add a collection of children to this node
public void add model model model this dataset get default model add model
adds a given model to the default model of this dataset
public void run file testfolders source list files for int i 0 i testfolders length i file atestfolder testfolders i execute command atestfolder save performance in performance object score performance record performance atestfolder
run the program to be evaluated folder by folder
private string build taxon name string string buffer namesb new string buffer for int i 0 i ranks size i namesb append names i namesb append return namesb to string replace first trim
string up non empty names from top to bottom of taxon ranks
protected boolean is figure table int para id string para string source return is figure table para trim para para trim if is figure table para trace back trace back fig tbl content para id source return true return false
need to trace back if a figure is found table is found
protected void process paragraph element wp throws exception attribute att attribute xpath select single node wp w p pr w p style w val string style if att null todo issue a warning system out println this paragraph has no p style attribute return else style att get value system out println style element se new element style se set text style element pe new element paragraph pe add content se extract text paragraph wp pe add the element to the treatment root element treatment add content pe
to process a w p tag
protected void add paragraphs array list para ids array list paras array list sources try database accessor insert paragraphs this prefix para ids paras sources conn catch exception e e print stack trace
preserve original case and leading spaces
private void output throws exception try string file target extracted count xml string target folder target extracted file tf new file target folder if tf exists tf is file tf mkdir 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 throw e
to output the treatment element
protected boolean start with atoken string para string source return false we don t do footnotes for this volume so return false what should be here is a list of tokens such as or 1 that starts a footnote
footnote should appear at least count threshold times in the document
protected void trace back fig tbl content int para id string source try array list string para ids new array list string array list string paras new array list string separate figs from tables string condition source source and para id para id database accessor select paragraphs prefix condition para id para ids paras conn if paras size 1 if paras get 0 matches table table d trace back table content para id source else trace back fig content para id source catch exception e e print stack trace
searching for those in one page limit for figure and table content words
protected void fix add2 last headings string source try string set type content string condition type content heading and add2last like y database accessor update paragraph prefix set condition conn catch exception e e print stack trace
reset the add2last headings to content
protected boolean is figure table int para id string para string source para para trim pattern pattern pattern compile fig figure table fig table figure fl g fl gure s d matcher m pattern matcher para if m matches trace back should be done after all pagenumbers are found trace back fig tbl content para id source return true return false
need to trace back if a figure is found table is found
protected void add representation to dataset dataset dataset itaxon taxon representation rep sdd factory create representation label text label text sdd factory create label text string taxon rank taxon get taxon rank to string string label the taxon rank taxon get name label text set value label detail text detail text sdd factory create detail text detail text set value generated from hong s mark up of fna document rep get representation group add label text rep get representation group add detail text dataset set representation rep
add a represenation element to a dataset
private void append add2last for int i padd2last size 1 i 0 i if padd2last get i null padd2last get i starts with y this paragraphs set i 1 this paragraphs get i 1 this paragraphs get i this paragraphs remove i this ptypes remove i this padd2last remove i this para ids remove i
operates on this
private string format string xml todo auto generated method stub string r int count 0 xml xml replace all jj replace all a z punct pattern p pattern compile matcher m p matcher xml while m matches r m group 1 r m group 2 id count text m group 3 xml m group 4 if m group 2 compare to ignore case rb 0 this adverbs contains m group 3 m group 3 matches b chunked sentence prepositions b this adverbs add m group 3 m p matcher xml count r xml return r
nn heads will become
public void reset this subjects new array list element static so a ditto sent can see the last subject this latestelements new array list element save the last set of elements added independent from adding elements to statement this unassignedcharacter null this inbrackets false this pstructures new array list element this cstructures new array list element
reset annotator to process next description paragraph
protected void add metadata datasets root technical metadata metadata sdd factory create technical metadata xmlgregorian calendar xgc now xmlgregorian calendar converter as xmlgregorian calendar new date system current time millis metadata set created xgc now document generator gen sdd factory create document generator gen set name rdf to sdd conversion tool gen set version 0 1 metadata set generator gen root set technical metadata metadata
adds metadata to the root datasets object
private element trace back4 element afteror element beforeor int afterorindex int endindex string text cs get text afterorindex endindex from afterorindex include to endindex not include text text replace all sg replace all w replace all s trim text text replace first s so afteror element beforeor clone this add attribute afteror modifier text return afteror
track back in this
private int chunks int count 0 iterator string it this chunkedtokens iterator while it has next if it next matches l count return count
count the chunks in chunkedtokens
protected string plaintextextractor string str string str1 pattern pattern1 pattern compile w s x matcher matcher pattern1 matcher str while matcher find int i matcher start int j matcher end str1 str1 concat str sub sequence i j to string matcher reset return str1
strip out all
private int find chunk int index ofkeyword string keyword search downwards string chunk int i index ofkeyword do i chunk this chunkedtokens get i while chunk length 0 if chunk index of keyword 0 return i search upwards chunk i index ofkeyword do i chunk this chunkedtokens get i while chunk length 0 if chunk index of keyword 0 return i system out println wrong chunks in chunked sentence system exit 1 should never reach here return 0
find the index in this
private string normalize as as string str string result pattern p pattern compile b as s w s as b matcher m p matcher str while m matches result m group 1 result m group 2 replace all s replace all str m group 3 m p matcher str result str return result trim
as wide as as wide as in
private string check jjagainst marked sent string npjj string lastid boolean has n false int last integer parse int lastid string words npjj split s for int i words length 1 i 0 i find the last nn as marked in markedsent e g posoftokens if this posoftokens last starts with nn words i else has n true break if has n npjj for int i 0 i words length i find the last nn as marked in markedsent e g posoftokens npjj words i return npjj replace all s trim
if np has a noun cut off at the last noun
private void populate curation list list string curation list string word try connection conn driver manager get connection url statement stmt conn create statement result set rs stmt execute query select category from this glossarytable where term word if rs next string cat rs get string category if cat matches application utilities get property structurecategorypatterninglossary add2 word roles table word op else add2 word roles table word c else curation list add word catch exception sqlexe logger error couldn t update sentence table in volume markup db accessor populate curation list sqlexe sqlexe print stack trace
if word in glossary add it to wordroles