Shuu12121 commited on
Commit
728152a
·
verified ·
1 Parent(s): f50b6fc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +650 -363
README.md CHANGED
@@ -8,374 +8,660 @@ tags:
8
  - loss:CosineSimilarityLoss
9
  base_model: Shuu12121/CodeModernBERT-Owl
10
  widget:
11
- - source_sentence: " public void scan() throws Throwable {\n client = new\
12
- \ FTPClient();\n log.info(\"connecting to \" + host + \"...\");\n \
13
- \ client.connect(host);\n log.info(client.getReplyString());\n \
14
- \ log.info(\"logging in...\");\n client.login(\"anonymous\", \"\");\n\
15
- \ log.info(client.getReplyString());\n Date date = Calendar.getInstance().getTime();\n\
16
- \ xmlDocument = new XMLDocument(host, dir, date);\n scanDirectory(dir);\n\
17
- \ }\n"
 
 
 
 
 
 
18
  sentences:
19
- - " public static void zip(ZipOutputStream out, File f, String base) throws Exception\
20
- \ {\n if (f.isDirectory()) {\n File[] fl = f.listFiles();\n\
21
- \ base = base.length() == 0 ? \"\" : base + File.separator;\n \
22
- \ for (int i = 0; i < fl.length; i++) {\n zip(out, fl[i],\
23
- \ base + fl[i].getName());\n }\n } else {\n out.putNextEntry(new\
24
- \ org.apache.tools.zip.ZipEntry(base));\n FileInputStream in = new\
25
- \ FileInputStream(f);\n IOUtils.copyStream(in, out);\n in.close();\n\
26
- \ }\n Thread.sleep(10);\n }\n"
27
- - " public static void zip(String destination, String folder) {\n File\
28
- \ fdir = new File(folder);\n File[] files = fdir.listFiles();\n \
29
- \ PrintWriter stdout = new PrintWriter(System.out, true);\n int read =\
30
- \ 0;\n FileInputStream in;\n byte[] data = new byte[1024];\n \
31
- \ try {\n ZipOutputStream out = new ZipOutputStream(new FileOutputStream(destination));\n\
32
- \ out.setMethod(ZipOutputStream.DEFLATED);\n for (int i\
33
- \ = 0; i < files.length; i++) {\n try {\n stdout.println(files[i].getName());\n\
34
- \ ZipEntry entry = new ZipEntry(files[i].getName());\n \
35
- \ in = new FileInputStream(files[i].getPath());\n \
36
- \ out.putNextEntry(entry);\n while ((read = in.read(data,\
37
- \ 0, 1024)) != -1) {\n out.write(data, 0, read);\n \
38
- \ }\n out.closeEntry();\n \
39
- \ in.close();\n } catch (Exception e) {\n e.printStackTrace();\n\
40
- \ }\n }\n out.close();\n } catch (IOException\
41
- \ ex) {\n ex.printStackTrace();\n }\n }\n"
42
- - " private void copyFile(URL from, File to) {\n try {\n InputStream\
43
- \ is = from.openStream();\n IOUtils.copy(is, new FileOutputStream(to));\n\
44
- \ } catch (IOException e) {\n e.printStackTrace();\n \
45
- \ }\n }\n"
46
- - source_sentence: " public void createMd5Hash() {\n try {\n \
47
- \ String vcardObject = new ContactToVcard(TimeZone.getTimeZone(\"UTC\"), \"UTF-8\"\
48
- ).convert(this);\n MessageDigest m = MessageDigest.getInstance(\"MD5\"\
49
- );\n m.update(vcardObject.getBytes());\n this.md5Hash =\
50
- \ new BigInteger(m.digest()).toString();\n if (log.isTraceEnabled())\
51
- \ {\n log.trace(\"Hash is:\" + this.md5Hash);\n }\n\
52
- \ } catch (ConverterException ex) {\n log.error(\"Error creating\
53
- \ hash:\" + ex.getMessage());\n } catch (NoSuchAlgorithmException noSuchAlgorithmException)\
54
- \ {\n log.error(\"Error creating hash:\" + noSuchAlgorithmException.getMessage());\n\
55
- \ }\n }\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  sentences:
57
- - " public static void main(String[] args) {\n try {\n int\
58
- \ encodeFlag = 0;\n if (args[0].equals(\"-e\")) {\n \
59
- \ encodeFlag = Base64.ENCODE;\n } else if (args[0].equals(\"-d\"))\
60
- \ {\n encodeFlag = Base64.DECODE;\n }\n String\
61
- \ infile = args[1];\n String outfile = args[2];\n File fin\
62
- \ = new File(infile);\n FileInputStream fis = new FileInputStream(fin);\n\
63
- \ BufferedInputStream bis = new BufferedInputStream(fis);\n \
64
- \ Base64.InputStream b64in = new Base64.InputStream(bis, encodeFlag | Base64.DO_BREAK_LINES);\n\
65
- \ File fout = new File(outfile);\n FileOutputStream fos\
66
- \ = new FileOutputStream(fout);\n BufferedOutputStream bos = new BufferedOutputStream(fos);\n\
67
- \ byte[] buff = new byte[1024];\n int read = -1;\n \
68
- \ while ((read = b64in.read(buff)) >= 0) {\n bos.write(buff,\
69
- \ 0, read);\n }\n bos.close();\n b64in.close();\n\
70
- \ } catch (Exception e) {\n e.printStackTrace();\n }\n\
71
- \ }\n"
72
- - " public static String md5(String str) {\n StringBuffer buf = new StringBuffer();\n\
73
- \ try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\"\
74
- );\n byte[] data = new byte[32];\n md.update(str.getBytes(md5Encoding),\
75
- \ 0, str.length());\n data = md.digest();\n for (int i =\
76
- \ 0; i < data.length; i++) {\n int halfbyte = (data[i] >>> 4) &\
77
- \ 0x0F;\n int two_halfs = 0;\n do {\n \
78
- \ if ((0 <= halfbyte) && (halfbyte <= 9)) buf.append((char) ('0' + halfbyte));\
79
- \ else buf.append((char) ('a' + (halfbyte - 10)));\n halfbyte\
80
- \ = data[i] & 0x0F;\n } while (two_halfs++ < 1);\n }\n\
81
- \ } catch (Exception e) {\n errorLog(\"{Malgn.md5} \" + e.getMessage());\n\
82
- \ }\n return buf.toString();\n }\n"
83
- - " public static String md5(String text, String charset) {\n MessageDigest\
84
- \ msgDigest = null;\n try {\n msgDigest = MessageDigest.getInstance(\"\
85
- MD5\");\n } catch (NoSuchAlgorithmException e) {\n throw new\
86
- \ IllegalStateException(\"System doesn't support MD5 algorithm.\");\n }\n\
87
- \ msgDigest.update(text.getBytes());\n byte[] bytes = msgDigest.digest();\n\
88
- \ byte tb;\n char low;\n char high;\n char tmpChar;\n\
89
- \ String md5Str = new String();\n for (int i = 0; i < bytes.length;\
90
- \ i++) {\n tb = bytes[i];\n tmpChar = (char) ((tb >>> 4)\
91
- \ & 0x000f);\n if (tmpChar >= 10) {\n high = (char)\
92
- \ (('a' + tmpChar) - 10);\n } else {\n high = (char)\
93
- \ ('0' + tmpChar);\n }\n md5Str += high;\n tmpChar\
94
- \ = (char) (tb & 0x000f);\n if (tmpChar >= 10) {\n low\
95
- \ = (char) (('a' + tmpChar) - 10);\n } else {\n low\
96
- \ = (char) ('0' + tmpChar);\n }\n md5Str += low;\n \
97
- \ }\n return md5Str;\n }\n"
98
- - source_sentence: " @Override\n public void run() {\n \
99
- \ try {\n IOUtils.copy(getSource(), processStdIn);\n\
100
- \ System.err.println(\"Copy done.\");\n \
101
- \ close();\n } catch (IOException e) {\n e.printStackTrace();\n\
102
- \ IOUtils.closeQuietly(ExternalDecoder.this);\n \
103
- \ }\n }\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  sentences:
105
- - " private String readJsonString() {\n StringBuilder builder = new StringBuilder();\n\
106
- \ HttpClient client = new DefaultHttpClient();\n HttpGet httpGet\
107
- \ = new HttpGet(SERVER_URL);\n try {\n HttpResponse response\
108
- \ = client.execute(httpGet);\n StatusLine statusLine = response.getStatusLine();\n\
109
- \ int statusCode = statusLine.getStatusCode();\n if (statusCode\
110
- \ == 200) {\n HttpEntity entity = response.getEntity();\n \
111
- \ InputStream content = entity.getContent();\n BufferedReader\
112
- \ reader = new BufferedReader(new InputStreamReader(content));\n \
113
- \ String line;\n while ((line = reader.readLine()) != null) {\n\
114
- \ builder.append(line);\n }\n } else\
115
- \ {\n Log.e(TAG, \"Failed to download file\");\n }\n\
116
- \ } catch (ClientProtocolException e) {\n e.printStackTrace();\n\
117
- \ } catch (IOException e) {\n e.printStackTrace();\n \
118
- \ }\n return builder.toString();\n }\n"
119
- - " public void run() {\n LogPrinter.log(Level.FINEST, \"Started Download\
120
- \ at : {0, date, long}\", new Date());\n if (!PipeConnected) {\n \
121
- \ throw new IllegalStateException(\"You should connect the pipe before with\
122
- \ getInputStream()\");\n }\n InputStream ins = null;\n if\
123
- \ (IsAlreadyDownloaded) {\n LogPrinter.log(Level.FINEST, \"The file\
124
- \ already Exists open and foward the byte\");\n try {\n \
125
- \ ContentLength = (int) TheAskedFile.length();\n ContentType\
126
- \ = URLConnection.getFileNameMap().getContentTypeFor(TheAskedFile.getName());\n\
127
- \ ins = new FileInputStream(TheAskedFile);\n byte[]\
128
- \ buffer = new byte[BUFFER_SIZE];\n int read = ins.read(buffer);\n\
129
- \ while (read >= 0) {\n Pipe.write(buffer, 0,\
130
- \ read);\n read = ins.read(buffer);\n }\n \
131
- \ } catch (IOException e) {\n e.printStackTrace();\n \
132
- \ } finally {\n if (ins != null) {\n \
133
- \ try {\n ins.close();\n } catch\
134
- \ (IOException e) {\n }\n }\n }\n\
135
- \ } else {\n LogPrinter.log(Level.FINEST, \"the file does not\
136
- \ exist locally so we try to download the thing\");\n File theDir =\
137
- \ TheAskedFile.getParentFile();\n if (!theDir.exists()) {\n \
138
- \ theDir.mkdirs();\n }\n for (URL url : ListFastest)\
139
- \ {\n FileOutputStream fout = null;\n boolean OnError\
140
- \ = false;\n long timestart = System.currentTimeMillis();\n \
141
- \ long bytecount = 0;\n try {\n \
142
- \ URL newUrl = new URL(url.toString() + RequestedFile);\n LogPrinter.log(Level.FINEST,\
143
- \ \"the download URL = {0}\", newUrl);\n URLConnection conn\
144
- \ = newUrl.openConnection();\n ContentType = conn.getContentType();\n\
145
- \ ContentLength = conn.getContentLength();\n \
146
- \ ins = conn.getInputStream();\n fout = new FileOutputStream(TheAskedFile);\n\
147
- \ byte[] buffer = new byte[BUFFER_SIZE];\n \
148
- \ int read = ins.read(buffer);\n while (read >= 0) {\n \
149
- \ fout.write(buffer, 0, read);\n \
150
- \ Pipe.write(buffer, 0, read);\n read = ins.read(buffer);\n\
151
- \ bytecount += read;\n }\n \
152
- \ Pipe.flush();\n } catch (IOException e) {\n \
153
- \ OnError = true;\n } finally {\n \
154
- \ if (ins != null) {\n try {\n \
155
- \ ins.close();\n } catch (IOException e) {\n \
156
- \ }\n }\n if (fout !=\
157
- \ null) {\n try {\n fout.close();\n\
158
- \ } catch (IOException e) {\n }\n\
159
- \ }\n }\n long timeend = System.currentTimeMillis();\n\
160
- \ if (OnError) {\n continue;\n \
161
- \ } else {\n long timetook = timeend - timestart;\n \
162
- \ BigDecimal speed = new BigDecimal(bytecount).multiply(new BigDecimal(1000)).divide(new\
163
- \ BigDecimal(timetook), MathContext.DECIMAL32);\n for (ReportCalculatedStatistique\
164
- \ report : Listener) {\n report.reportUrlStat(url, speed,\
165
- \ timetook);\n }\n break;\n \
166
- \ }\n }\n }\n LogPrinter.log(Level.FINEST, \"download\
167
- \ finished at {0,date,long}\", new Date());\n if (Pipe != null) {\n \
168
- \ try {\n Pipe.close();\n } catch (IOException\
169
- \ e) {\n e.printStackTrace();\n }\n }\n }\n"
170
- - " public void run(String srcf, String dst) {\n final Path srcPath =\
171
- \ new Path(\"./\" + srcf);\n final Path desPath = new Path(dst);\n \
172
- \ try {\n Path[] srcs = FileUtil.stat2Paths(hdfs.globStatus(srcPath),\
173
- \ srcPath);\n OutputStream out = FileSystem.getLocal(conf).create(desPath);\n\
174
- \ for (int i = 0; i < srcs.length; i++) {\n System.out.println(srcs[i]);\n\
175
- \ InputStream in = hdfs.open(srcs[i]);\n IOUtils.copyBytes(in,\
176
- \ out, conf, false);\n in.close();\n }\n \
177
- \ out.close();\n } catch (IOException ex) {\n System.err.print(ex.getMessage());\n\
178
- \ }\n }\n"
179
- - source_sentence: " private void readHomePage(ITestThread testThread) throws IOException\
180
- \ {\n if (null == testThread) {\n throw new IllegalArgumentException(\"\
181
- Test thread may not be null.\");\n }\n final InputStream urlIn =\
182
- \ new URL(testUrl).openStream();\n final int availableBytes = urlIn.available();\n\
183
- \ if (0 == availableBytes) {\n throw new IllegalStateException(\"\
184
- Zero bytes on target host.\");\n }\n in = new BufferedReader(new\
185
- \ InputStreamReader(urlIn));\n String line;\n while (null != in\
186
- \ && null != (line = in.readLine())) {\n page.append(line);\n \
187
- \ page.append('\\n');\n if (0 != lineDelay) {\n \
188
- \ OS.sleep(lineDelay);\n }\n if (testThread.isActionStopped())\
189
- \ {\n break;\n }\n }\n }\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  sentences:
191
- - " @Override\n public ReturnValue do_run() {\n int bufLen = 500 *\
192
- \ 1024;\n ReturnValue ret = new ReturnValue();\n ret.setExitStatus(ReturnValue.SUCCESS);\n\
193
- \ File output = null;\n if (((String) options.valueOf(\"input-file\"\
194
- )).startsWith(\"s3://\")) {\n Pattern p = Pattern.compile(\"s3://(\\\
195
- \\S+):(\\\\S+)@(\\\\S+)\");\n Matcher m = p.matcher((String) options.valueOf(\"\
196
- input-file\"));\n boolean result = m.find();\n String accessKey\
197
- \ = null;\n String secretKey = null;\n String URL = (String)\
198
- \ options.valueOf(\"input-file\");\n if (result) {\n \
199
- \ accessKey = m.group(1);\n secretKey = m.group(2);\n \
200
- \ URL = \"s3://\" + m.group(3);\n } else {\n \
201
- \ try {\n HashMap<String, String> settings = (HashMap<String,\
202
- \ String>) ConfigTools.getSettings();\n accessKey = settings.get(\"\
203
- AWS_ACCESS_KEY\");\n secretKey = settings.get(\"AWS_SECRET_KEY\"\
204
- );\n } catch (Exception e) {\n ret.setExitStatus(ReturnValue.SETTINGSFILENOTFOUND);\n\
205
- \ ret.setProcessExitStatus(ReturnValue.SETTINGSFILENOTFOUND);\n\
206
- \ return (ret);\n }\n }\n \
207
- \ if (accessKey == null || secretKey == null) {\n ret.setExitStatus(ReturnValue.ENVVARNOTFOUND);\n\
208
- \ ret.setProcessExitStatus(ReturnValue.ENVVARNOTFOUND);\n \
209
- \ return (ret);\n }\n AmazonS3 s3 = new AmazonS3Client(new\
210
- \ BasicAWSCredentials(accessKey, secretKey));\n p = Pattern.compile(\"\
211
- s3://([^/]+)/(\\\\S+)\");\n m = p.matcher(URL);\n result\
212
- \ = m.find();\n if (result) {\n String bucket = m.group(1);\n\
213
- \ String key = m.group(2);\n S3Object object = s3.getObject(new\
214
- \ GetObjectRequest(bucket, key));\n System.out.println(\"Content-Type:\
215
- \ \" + object.getObjectMetadata().getContentType());\n output =\
216
- \ new File((String) options.valueOf(\"output-dir\") + File.separator + key);\n\
217
- \ output.getParentFile().mkdirs();\n if (!output.exists()\
218
- \ || output.length() != object.getObjectMetadata().getContentLength()) {\n \
219
- \ System.out.println(\"Downloading an S3 object from bucket: \"\
220
- \ + bucket + \" with key: \" + key);\n BufferedInputStream\
221
- \ reader = new BufferedInputStream(object.getObjectContent(), bufLen);\n \
222
- \ try {\n BufferedOutputStream writer = new\
223
- \ BufferedOutputStream(new FileOutputStream(output), bufLen);\n \
224
- \ while (true) {\n int data = reader.read();\n\
225
- \ if (data == -1) {\n \
226
- \ break;\n }\n writer.write(data);\n\
227
- \ }\n reader.close();\n \
228
- \ writer.close();\n } catch (FileNotFoundException\
229
- \ e) {\n System.err.println(e.getMessage());\n \
230
- \ } catch (IOException e) {\n System.err.println(e.getMessage());\n\
231
- \ }\n } else {\n System.out.println(\"\
232
- Skipping download of S3 object from bucket: \" + bucket + \" with key: \" + key\
233
- \ + \" since local output exists: \" + output.getAbsolutePath());\n \
234
- \ }\n }\n } else if (((String) options.valueOf(\"input-file\"\
235
- )).startsWith(\"http://\") || ((String) options.valueOf(\"input-file\")).startsWith(\"\
236
- https://\")) {\n Pattern p = Pattern.compile(\"(https*)://(\\\\S+):(\\\
237
- \\S+)@(\\\\S+)\");\n Matcher m = p.matcher((String) options.valueOf(\"\
238
- input-file\"));\n boolean result = m.find();\n String protocol\
239
- \ = null;\n String user = null;\n String pass = null;\n\
240
- \ String URL = (String) options.valueOf(\"input-file\");\n \
241
- \ if (result) {\n protocol = m.group(1);\n user\
242
- \ = m.group(2);\n pass = m.group(3);\n URL = protocol\
243
- \ + \"://\" + m.group(4);\n }\n URL urlObj = null;\n \
244
- \ try {\n urlObj = new URL(URL);\n if (urlObj\
245
- \ != null) {\n URLConnection urlConn = urlObj.openConnection();\n\
246
- \ if (user != null && pass != null) {\n \
247
- \ String userPassword = user + \":\" + pass;\n String\
248
- \ encoding = new Base64().encodeBase64String(userPassword.getBytes());\n \
249
- \ urlConn.setRequestProperty(\"Authorization\", \"Basic \" +\
250
- \ encoding);\n }\n p = Pattern.compile(\"\
251
- ://([^/]+)/(\\\\S+)\");\n m = p.matcher(URL);\n \
252
- \ result = m.find();\n if (result) {\n \
253
- \ String host = m.group(1);\n String path =\
254
- \ m.group(2);\n output = new File((String) options.valueOf(\"\
255
- output-dir\") + path);\n output.getParentFile().mkdirs();\n\
256
- \ if (!output.exists() || output.length() != urlConn.getContentLength())\
257
- \ {\n System.out.println(\"Downloading an http object\
258
- \ from URL: \" + URL);\n BufferedInputStream reader\
259
- \ = new BufferedInputStream(urlConn.getInputStream(), bufLen);\n \
260
- \ BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(output),\
261
- \ bufLen);\n while (true) {\n \
262
- \ int data = reader.read();\n if (data\
263
- \ == -1) {\n break;\n \
264
- \ }\n writer.write(data);\n \
265
- \ }\n reader.close();\n \
266
- \ writer.close();\n } else {\n \
267
- \ System.out.println(\"Skipping download of http object from\
268
- \ URL: \" + URL + \" since local output exists: \" + output.getAbsolutePath());\n\
269
- \ }\n }\n }\n \
270
- \ } catch (MalformedURLException e) {\n System.err.println(e.getMessage());\n\
271
- \ } catch (IOException e) {\n System.err.println(e.getMessage());\n\
272
- \ }\n } else {\n output = new File((String) options.valueOf(\"\
273
- input-file\"));\n }\n boolean result = FileTools.unzipFile(output,\
274
- \ new File((String) options.valueOf(\"output-dir\")));\n if (!result) {\n\
275
- \ ret.setStderr(\"Can't unzip software bundle \" + options.valueOf(\"\
276
- input-file\") + \" to directory \" + options.valueOf(\"output-dir\"));\n \
277
- \ ret.setExitStatus(ReturnValue.RUNTIMEEXCEPTION);\n }\n return\
278
- \ (ret);\n }\n"
279
- - " public void writeConfigurationFile() throws IOException, ComponentException\
280
- \ {\n SystemConfig config = parent.getParentSystem().getConfiguration();\n\
281
- \ File original = config.getLocation();\n File backup = new File(original.getParentFile(),\
282
- \ original.getName() + \".\" + System.currentTimeMillis());\n FileInputStream\
283
- \ in = new FileInputStream(original);\n FileOutputStream out = new FileOutputStream(backup);\n\
284
- \ byte[] buffer = new byte[2048];\n try {\n int bytesread\
285
- \ = 0;\n while ((bytesread = in.read(buffer)) > 0) {\n \
286
- \ out.write(buffer, 0, bytesread);\n }\n } catch (IOException\
287
- \ e) {\n logger.warn(\"Failed to copy backup of configuration file\"\
288
- );\n throw e;\n } finally {\n in.close();\n \
289
- \ out.close();\n }\n FileWriter replace = new FileWriter(original);\n\
290
- \ replace.write(config.toFileFormat());\n replace.close();\n \
291
- \ logger.info(\"Re-wrote configuration file \" + original.getPath());\n \
292
- \ }\n"
293
- - " @Override\n protected void doGet(HttpServletRequest req, HttpServletResponse\
294
- \ resp) throws ServletException, IOException {\n resp.addHeader(\"Cache-Control\"\
295
- , \"max-age=\" + Constants.HTTP_CACHE_SECONDS);\n String uuid = req.getRequestURI().substring(req.getRequestURI().indexOf(Constants.SERVLET_FULL_PREFIX)\
296
- \ + Constants.SERVLET_FULL_PREFIX.length() + 1);\n boolean notScale = ClientUtils.toBoolean(req.getParameter(Constants.URL_PARAM_NOT_SCALE));\n\
297
- \ ServletOutputStream os = resp.getOutputStream();\n if (uuid !=\
298
- \ null && !\"\".equals(uuid)) {\n try {\n String mimetype\
299
- \ = fedoraAccess.getMimeTypeForStream(uuid, FedoraUtils.IMG_FULL_STREAM);\n \
300
- \ if (mimetype == null) {\n mimetype = \"image/jpeg\"\
301
- ;\n }\n ImageMimeType loadFromMimeType = ImageMimeType.loadFromMimeType(mimetype);\n\
302
- \ if (loadFromMimeType == ImageMimeType.JPEG || loadFromMimeType\
303
- \ == ImageMimeType.PNG) {\n StringBuffer sb = new StringBuffer();\n\
304
- \ sb.append(config.getFedoraHost()).append(\"/objects/\").append(uuid).append(\"\
305
- /datastreams/IMG_FULL/content\");\n InputStream is = RESTHelper.get(sb.toString(),\
306
- \ config.getFedoraLogin(), config.getFedoraPassword(), false);\n \
307
- \ if (is == null) {\n return;\n \
308
- \ }\n try {\n IOUtils.copyStreams(is,\
309
- \ os);\n } catch (IOException e) {\n \
310
- \ resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);\n \
311
- \ LOGGER.error(\"Unable to open full image.\", e);\n } finally\
312
- \ {\n os.flush();\n if (is != null)\
313
- \ {\n try {\n is.close();\n\
314
- \ } catch (IOException e) {\n \
315
- \ resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);\n \
316
- \ LOGGER.error(\"Unable to close stream.\", e);\n \
317
- \ } finally {\n is = null;\n \
318
- \ }\n }\n }\n\
319
- \ } else {\n Image rawImg = KrameriusImageSupport.readImage(uuid,\
320
- \ FedoraUtils.IMG_FULL_STREAM, this.fedoraAccess, 0, loadFromMimeType);\n \
321
- \ BufferedImage scaled = null;\n if (!notScale)\
322
- \ {\n scaled = KrameriusImageSupport.getSmallerImage(rawImg,\
323
- \ 1250, 1000);\n } else {\n scaled =\
324
- \ KrameriusImageSupport.getSmallerImage(rawImg, 2500, 2000);\n \
325
- \ }\n KrameriusImageSupport.writeImageToStream(scaled,\
326
- \ \"JPG\", os);\n resp.setContentType(ImageMimeType.JPEG.getValue());\n\
327
- \ resp.setStatus(HttpURLConnection.HTTP_OK);\n \
328
- \ }\n } catch (IOException e) {\n resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);\n\
329
- \ LOGGER.error(\"Unable to open full image.\", e);\n \
330
- \ } catch (XPathExpressionException e) {\n resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);\n\
331
- \ LOGGER.error(\"Unable to create XPath expression.\", e);\n \
332
- \ } finally {\n os.flush();\n }\n }\n\
333
- \ }\n"
334
- - source_sentence: " public static boolean insert(final Cargo cargo) {\n \
335
- \ int result = 0;\n final Connection c = DBConnection.getConnection();\n\
336
- \ PreparedStatement pst = null;\n if (c == null) {\n \
337
- \ return false;\n }\n try {\n c.setAutoCommit(false);\n\
338
- \ final String sql = \"insert into cargo (nome) values (?)\";\n \
339
- \ pst = c.prepareStatement(sql);\n pst.setString(1, cargo.getNome());\n\
340
- \ result = pst.executeUpdate();\n c.commit();\n }\
341
- \ catch (final SQLException e) {\n try {\n c.rollback();\n\
342
- \ } catch (final SQLException e1) {\n e1.printStackTrace();\n\
343
- \ }\n System.out.println(\"[CargoDAO.insert] Erro ao inserir\
344
- \ -> \" + e.getMessage());\n } finally {\n DBConnection.closePreparedStatement(pst);\n\
345
- \ DBConnection.closeConnection(c);\n }\n if (result >\
346
- \ 0) {\n return true;\n } else {\n return false;\n\
347
- \ }\n }\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  sentences:
349
- - " public String md5sum(String toCompute) throws Exception {\n MessageDigest\
350
- \ md = MessageDigest.getInstance(\"MD5\");\n md.update(toCompute.getBytes());\n\
351
- \ java.math.BigInteger hash = new java.math.BigInteger(1, md.digest());\n\
352
- \ return hash.toString(16);\n }\n"
353
- - " protected void runTest(URL pBaseURL, String pName, String pHref) throws Exception\
354
- \ {\n URL url = new URL(pBaseURL, pHref);\n XSParser parser = new\
355
- \ XSParser();\n parser.setValidating(false);\n InputSource isource\
356
- \ = new InputSource(url.openStream());\n isource.setSystemId(url.toString());\n\
357
- \ String result;\n try {\n parser.parse(isource);\n \
358
- \ ++numOk;\n result = \"Ok\";\n } catch (Exception\
359
- \ e) {\n ++numFailed;\n result = e.getMessage();\n \
360
- \ }\n log(\"Running test \" + pName + \" with URL \" + url + \": \" +\
361
- \ result);\n }\n"
362
- - " public String generateMappackMD5(File mapPackFile) throws IOException, NoSuchAlgorithmException\
363
- \ {\n ZipFile zip = new ZipFile(mapPackFile);\n try {\n \
364
- \ Enumeration<? extends ZipEntry> entries = zip.entries();\n MessageDigest\
365
- \ md5Total = MessageDigest.getInstance(\"MD5\");\n MessageDigest md5\
366
- \ = MessageDigest.getInstance(\"MD5\");\n while (entries.hasMoreElements())\
367
- \ {\n ZipEntry entry = entries.nextElement();\n \
368
- \ if (entry.isDirectory()) continue;\n String name = entry.getName();\n\
369
- \ if (name.toUpperCase().startsWith(\"META-INF\")) continue;\n\
370
- \ md5.reset();\n InputStream in = zip.getInputStream(entry);\n\
371
- \ byte[] data = Utilities.getInputBytes(in);\n in.close();\n\
372
- \ byte[] digest = md5.digest(data);\n log.trace(\"\
373
- Hashsum \" + Hex.encodeHexString(digest) + \" includes \\\"\" + name + \"\\\"\"\
374
- );\n md5Total.update(digest);\n md5Total.update(name.getBytes());\n\
375
- \ }\n String md5sum = Hex.encodeHexString(md5Total.digest());\n\
376
- \ log.trace(\"md5sum of \" + mapPackFile.getName() + \": \" + md5sum);\n\
377
- \ return md5sum;\n } finally {\n zip.close();\n \
378
- \ }\n }\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  pipeline_tag: sentence-similarity
380
  library_name: sentence-transformers
381
  metrics:
@@ -397,6 +683,7 @@ model-index:
397
  - type: spearman_cosine
398
  value: 0.5635084463158045
399
  name: Spearman Cosine
 
400
  ---
401
 
402
  # SentenceTransformer based on Shuu12121/CodeModernBERT-Owl
 
8
  - loss:CosineSimilarityLoss
9
  base_model: Shuu12121/CodeModernBERT-Owl
10
  widget:
11
+ - source_sentence: |2
12
+ public void scan() throws Throwable {
13
+ client = new FTPClient();
14
+ log.info("connecting to " + host + "...");
15
+ client.connect(host);
16
+ log.info(client.getReplyString());
17
+ log.info("logging in...");
18
+ client.login("anonymous", "");
19
+ log.info(client.getReplyString());
20
+ Date date = Calendar.getInstance().getTime();
21
+ xmlDocument = new XMLDocument(host, dir, date);
22
+ scanDirectory(dir);
23
+ }
24
  sentences:
25
+ - |2
26
+ public static void zip(ZipOutputStream out, File f, String base) throws Exception {
27
+ if (f.isDirectory()) {
28
+ File[] fl = f.listFiles();
29
+ base = base.length() == 0 ? "" : base + File.separator;
30
+ for (int i = 0; i < fl.length; i++) {
31
+ zip(out, fl[i], base + fl[i].getName());
32
+ }
33
+ } else {
34
+ out.putNextEntry(new org.apache.tools.zip.ZipEntry(base));
35
+ FileInputStream in = new FileInputStream(f);
36
+ IOUtils.copyStream(in, out);
37
+ in.close();
38
+ }
39
+ Thread.sleep(10);
40
+ }
41
+ - |2
42
+ public static void zip(String destination, String folder) {
43
+ File fdir = new File(folder);
44
+ File[] files = fdir.listFiles();
45
+ PrintWriter stdout = new PrintWriter(System.out, true);
46
+ int read = 0;
47
+ FileInputStream in;
48
+ byte[] data = new byte[1024];
49
+ try {
50
+ ZipOutputStream out = new ZipOutputStream(new FileOutputStream(destination));
51
+ out.setMethod(ZipOutputStream.DEFLATED);
52
+ for (int i = 0; i < files.length; i++) {
53
+ try {
54
+ stdout.println(files[i].getName());
55
+ ZipEntry entry = new ZipEntry(files[i].getName());
56
+ in = new FileInputStream(files[i].getPath());
57
+ out.putNextEntry(entry);
58
+ while ((read = in.read(data, 0, 1024)) != -1) {
59
+ out.write(data, 0, read);
60
+ }
61
+ out.closeEntry();
62
+ in.close();
63
+ } catch (Exception e) {
64
+ e.printStackTrace();
65
+ }
66
+ }
67
+ out.close();
68
+ } catch (IOException ex) {
69
+ ex.printStackTrace();
70
+ }
71
+ }
72
+ - |2
73
+ private void copyFile(URL from, File to) {
74
+ try {
75
+ InputStream is = from.openStream();
76
+ IOUtils.copy(is, new FileOutputStream(to));
77
+ } catch (IOException e) {
78
+ e.printStackTrace();
79
+ }
80
+ }
81
+ - source_sentence: |2
82
+ public void createMd5Hash() {
83
+ try {
84
+ String vcardObject = new ContactToVcard(TimeZone.getTimeZone("UTC"), "UTF-8").convert(this);
85
+ MessageDigest m = MessageDigest.getInstance("MD5");
86
+ m.update(vcardObject.getBytes());
87
+ this.md5Hash = new BigInteger(m.digest()).toString();
88
+ if (log.isTraceEnabled()) {
89
+ log.trace("Hash is:" + this.md5Hash);
90
+ }
91
+ } catch (ConverterException ex) {
92
+ log.error("Error creating hash:" + ex.getMessage());
93
+ } catch (NoSuchAlgorithmException noSuchAlgorithmException) {
94
+ log.error("Error creating hash:" + noSuchAlgorithmException.getMessage());
95
+ }
96
+ }
97
  sentences:
98
+ - |2
99
+ public static void main(String[] args) {
100
+ try {
101
+ int encodeFlag = 0;
102
+ if (args[0].equals("-e")) {
103
+ encodeFlag = Base64.ENCODE;
104
+ } else if (args[0].equals("-d")) {
105
+ encodeFlag = Base64.DECODE;
106
+ }
107
+ String infile = args[1];
108
+ String outfile = args[2];
109
+ File fin = new File(infile);
110
+ FileInputStream fis = new FileInputStream(fin);
111
+ BufferedInputStream bis = new BufferedInputStream(fis);
112
+ Base64.InputStream b64in = new Base64.InputStream(bis, encodeFlag | Base64.DO_BREAK_LINES);
113
+ File fout = new File(outfile);
114
+ FileOutputStream fos = new FileOutputStream(fout);
115
+ BufferedOutputStream bos = new BufferedOutputStream(fos);
116
+ byte[] buff = new byte[1024];
117
+ int read = -1;
118
+ while ((read = b64in.read(buff)) >= 0) {
119
+ bos.write(buff, 0, read);
120
+ }
121
+ bos.close();
122
+ b64in.close();
123
+ } catch (Exception e) {
124
+ e.printStackTrace();
125
+ }
126
+ }
127
+ - |2
128
+ public static String md5(String str) {
129
+ StringBuffer buf = new StringBuffer();
130
+ try {
131
+ MessageDigest md = MessageDigest.getInstance("MD5");
132
+ byte[] data = new byte[32];
133
+ md.update(str.getBytes(md5Encoding), 0, str.length());
134
+ data = md.digest();
135
+ for (int i = 0; i < data.length; i++) {
136
+ int halfbyte = (data[i] >>> 4) & 0x0F;
137
+ int two_halfs = 0;
138
+ do {
139
+ if ((0 <= halfbyte) && (halfbyte <= 9)) buf.append((char) ('0' + halfbyte)); else buf.append((char) ('a' + (halfbyte - 10)));
140
+ halfbyte = data[i] & 0x0F;
141
+ } while (two_halfs++ < 1);
142
+ }
143
+ } catch (Exception e) {
144
+ errorLog("{Malgn.md5} " + e.getMessage());
145
+ }
146
+ return buf.toString();
147
+ }
148
+ - |2
149
+ public static String md5(String text, String charset) {
150
+ MessageDigest msgDigest = null;
151
+ try {
152
+ msgDigest = MessageDigest.getInstance("MD5");
153
+ } catch (NoSuchAlgorithmException e) {
154
+ throw new IllegalStateException("System doesn't support MD5 algorithm.");
155
+ }
156
+ msgDigest.update(text.getBytes());
157
+ byte[] bytes = msgDigest.digest();
158
+ byte tb;
159
+ char low;
160
+ char high;
161
+ char tmpChar;
162
+ String md5Str = new String();
163
+ for (int i = 0; i < bytes.length; i++) {
164
+ tb = bytes[i];
165
+ tmpChar = (char) ((tb >>> 4) & 0x000f);
166
+ if (tmpChar >= 10) {
167
+ high = (char) (('a' + tmpChar) - 10);
168
+ } else {
169
+ high = (char) ('0' + tmpChar);
170
+ }
171
+ md5Str += high;
172
+ tmpChar = (char) (tb & 0x000f);
173
+ if (tmpChar >= 10) {
174
+ low = (char) (('a' + tmpChar) - 10);
175
+ } else {
176
+ low = (char) ('0' + tmpChar);
177
+ }
178
+ md5Str += low;
179
+ }
180
+ return md5Str;
181
+ }
182
+ - source_sentence: |2
183
+ @Override
184
+ public void run() {
185
+ try {
186
+ IOUtils.copy(getSource(), processStdIn);
187
+ System.err.println("Copy done.");
188
+ close();
189
+ } catch (IOException e) {
190
+ e.printStackTrace();
191
+ IOUtils.closeQuietly(ExternalDecoder.this);
192
+ }
193
+ }
194
  sentences:
195
+ - |2
196
+ private String readJsonString() {
197
+ StringBuilder builder = new StringBuilder();
198
+ HttpClient client = new DefaultHttpClient();
199
+ HttpGet httpGet = new HttpGet(SERVER_URL);
200
+ try {
201
+ HttpResponse response = client.execute(httpGet);
202
+ StatusLine statusLine = response.getStatusLine();
203
+ int statusCode = statusLine.getStatusCode();
204
+ if (statusCode == 200) {
205
+ HttpEntity entity = response.getEntity();
206
+ InputStream content = entity.getContent();
207
+ BufferedReader reader = new BufferedReader(new InputStreamReader(content));
208
+ String line;
209
+ while ((line = reader.readLine()) != null) {
210
+ builder.append(line);
211
+ }
212
+ } else {
213
+ Log.e(TAG, "Failed to download file");
214
+ }
215
+ } catch (ClientProtocolException e) {
216
+ e.printStackTrace();
217
+ } catch (IOException e) {
218
+ e.printStackTrace();
219
+ }
220
+ return builder.toString();
221
+ }
222
+ - |2
223
+ public void run() {
224
+ LogPrinter.log(Level.FINEST, "Started Download at : {0, date, long}", new Date());
225
+ if (!PipeConnected) {
226
+ throw new IllegalStateException("You should connect the pipe before with getInputStream()");
227
+ }
228
+ InputStream ins = null;
229
+ if (IsAlreadyDownloaded) {
230
+ LogPrinter.log(Level.FINEST, "The file already Exists open and foward the byte");
231
+ try {
232
+ ContentLength = (int) TheAskedFile.length();
233
+ ContentType = URLConnection.getFileNameMap().getContentTypeFor(TheAskedFile.getName());
234
+ ins = new FileInputStream(TheAskedFile);
235
+ byte[] buffer = new byte[BUFFER_SIZE];
236
+ int read = ins.read(buffer);
237
+ while (read >= 0) {
238
+ Pipe.write(buffer, 0, read);
239
+ read = ins.read(buffer);
240
+ }
241
+ } catch (IOException e) {
242
+ e.printStackTrace();
243
+ } finally {
244
+ if (ins != null) {
245
+ try {
246
+ ins.close();
247
+ } catch (IOException e) {
248
+ }
249
+ }
250
+ }
251
+ } else {
252
+ LogPrinter.log(Level.FINEST, "the file does not exist locally so we try to download the thing");
253
+ File theDir = TheAskedFile.getParentFile();
254
+ if (!theDir.exists()) {
255
+ theDir.mkdirs();
256
+ }
257
+ for (URL url : ListFastest) {
258
+ FileOutputStream fout = null;
259
+ boolean OnError = false;
260
+ long timestart = System.currentTimeMillis();
261
+ long bytecount = 0;
262
+ try {
263
+ URL newUrl = new URL(url.toString() + RequestedFile);
264
+ LogPrinter.log(Level.FINEST, "the download URL = {0}", newUrl);
265
+ URLConnection conn = newUrl.openConnection();
266
+ ContentType = conn.getContentType();
267
+ ContentLength = conn.getContentLength();
268
+ ins = conn.getInputStream();
269
+ fout = new FileOutputStream(TheAskedFile);
270
+ byte[] buffer = new byte[BUFFER_SIZE];
271
+ int read = ins.read(buffer);
272
+ while (read >= 0) {
273
+ fout.write(buffer, 0, read);
274
+ Pipe.write(buffer, 0, read);
275
+ read = ins.read(buffer);
276
+ bytecount += read;
277
+ }
278
+ Pipe.flush();
279
+ } catch (IOException e) {
280
+ OnError = true;
281
+ } finally {
282
+ if (ins != null) {
283
+ try {
284
+ ins.close();
285
+ } catch (IOException e) {
286
+ }
287
+ }
288
+ if (fout != null) {
289
+ try {
290
+ fout.close();
291
+ } catch (IOException e) {
292
+ }
293
+ }
294
+ }
295
+ long timeend = System.currentTimeMillis();
296
+ if (OnError) {
297
+ continue;
298
+ } else {
299
+ long timetook = timeend - timestart;
300
+ BigDecimal speed = new BigDecimal(bytecount).multiply(new BigDecimal(1000)).divide(new BigDecimal(timetook), MathContext.DECIMAL32);
301
+ for (ReportCalculatedStatistique report : Listener) {
302
+ report.reportUrlStat(url, speed, timetook);
303
+ }
304
+ break;
305
+ }
306
+ }
307
+ }
308
+ LogPrinter.log(Level.FINEST, "download finished at {0,date,long}", new Date());
309
+ if (Pipe != null) {
310
+ try {
311
+ Pipe.close();
312
+ } catch (IOException e) {
313
+ e.printStackTrace();
314
+ }
315
+ }
316
+ }
317
+ - |2
318
+ public void run(String srcf, String dst) {
319
+ final Path srcPath = new Path("./" + srcf);
320
+ final Path desPath = new Path(dst);
321
+ try {
322
+ Path[] srcs = FileUtil.stat2Paths(hdfs.globStatus(srcPath), srcPath);
323
+ OutputStream out = FileSystem.getLocal(conf).create(desPath);
324
+ for (int i = 0; i < srcs.length; i++) {
325
+ System.out.println(srcs[i]);
326
+ InputStream in = hdfs.open(srcs[i]);
327
+ IOUtils.copyBytes(in, out, conf, false);
328
+ in.close();
329
+ }
330
+ out.close();
331
+ } catch (IOException ex) {
332
+ System.err.print(ex.getMessage());
333
+ }
334
+ }
335
+ - source_sentence: |2
336
+ private void readHomePage(ITestThread testThread) throws IOException {
337
+ if (null == testThread) {
338
+ throw new IllegalArgumentException("Test thread may not be null.");
339
+ }
340
+ final InputStream urlIn = new URL(testUrl).openStream();
341
+ final int availableBytes = urlIn.available();
342
+ if (0 == availableBytes) {
343
+ throw new IllegalStateException("Zero bytes on target host.");
344
+ }
345
+ in = new BufferedReader(new InputStreamReader(urlIn));
346
+ String line;
347
+ while (null != in && null != (line = in.readLine())) {
348
+ page.append(line);
349
+ page.append('\n');
350
+ if (0 != lineDelay) {
351
+ OS.sleep(lineDelay);
352
+ }
353
+ if (testThread.isActionStopped()) {
354
+ break;
355
+ }
356
+ }
357
+ }
358
  sentences:
359
+ - |2
360
+ @Override
361
+ public ReturnValue do_run() {
362
+ int bufLen = 500 * 1024;
363
+ ReturnValue ret = new ReturnValue();
364
+ ret.setExitStatus(ReturnValue.SUCCESS);
365
+ File output = null;
366
+ if (((String) options.valueOf("input-file")).startsWith("s3://")) {
367
+ Pattern p = Pattern.compile("s3://(\\S+):(\\S+)@(\\S+)");
368
+ Matcher m = p.matcher((String) options.valueOf("input-file"));
369
+ boolean result = m.find();
370
+ String accessKey = null;
371
+ String secretKey = null;
372
+ String URL = (String) options.valueOf("input-file");
373
+ if (result) {
374
+ accessKey = m.group(1);
375
+ secretKey = m.group(2);
376
+ URL = "s3://" + m.group(3);
377
+ } else {
378
+ try {
379
+ HashMap<String, String> settings = (HashMap<String, String>) ConfigTools.getSettings();
380
+ accessKey = settings.get("AWS_ACCESS_KEY");
381
+ secretKey = settings.get("AWS_SECRET_KEY");
382
+ } catch (Exception e) {
383
+ ret.setExitStatus(ReturnValue.SETTINGSFILENOTFOUND);
384
+ ret.setProcessExitStatus(ReturnValue.SETTINGSFILENOTFOUND);
385
+ return (ret);
386
+ }
387
+ }
388
+ if (accessKey == null || secretKey == null) {
389
+ ret.setExitStatus(ReturnValue.ENVVARNOTFOUND);
390
+ ret.setProcessExitStatus(ReturnValue.ENVVARNOTFOUND);
391
+ return (ret);
392
+ }
393
+ AmazonS3 s3 = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey));
394
+ p = Pattern.compile("s3://([^/]+)/(\\S+)");
395
+ m = p.matcher(URL);
396
+ result = m.find();
397
+ if (result) {
398
+ String bucket = m.group(1);
399
+ String key = m.group(2);
400
+ S3Object object = s3.getObject(new GetObjectRequest(bucket, key));
401
+ System.out.println("Content-Type: " + object.getObjectMetadata().getContentType());
402
+ output = new File((String) options.valueOf("output-dir") + File.separator + key);
403
+ output.getParentFile().mkdirs();
404
+ if (!output.exists() || output.length() != object.getObjectMetadata().getContentLength()) {
405
+ System.out.println("Downloading an S3 object from bucket: " + bucket + " with key: " + key);
406
+ BufferedInputStream reader = new BufferedInputStream(object.getObjectContent(), bufLen);
407
+ try {
408
+ BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(output), bufLen);
409
+ while (true) {
410
+ int data = reader.read();
411
+ if (data == -1) {
412
+ break;
413
+ }
414
+ writer.write(data);
415
+ }
416
+ reader.close();
417
+ writer.close();
418
+ } catch (FileNotFoundException e) {
419
+ System.err.println(e.getMessage());
420
+ } catch (IOException e) {
421
+ System.err.println(e.getMessage());
422
+ }
423
+ } else {
424
+ System.out.println("Skipping download of S3 object from bucket: " + bucket + " with key: " + key + " since local output exists: " + output.getAbsolutePath());
425
+ }
426
+ }
427
+ } else if (((String) options.valueOf("input-file")).startsWith("http://") || ((String) options.valueOf("input-file")).startsWith("https://")) {
428
+ Pattern p = Pattern.compile("(https*)://(\\S+):(\\S+)@(\\S+)");
429
+ Matcher m = p.matcher((String) options.valueOf("input-file"));
430
+ boolean result = m.find();
431
+ String protocol = null;
432
+ String user = null;
433
+ String pass = null;
434
+ String URL = (String) options.valueOf("input-file");
435
+ if (result) {
436
+ protocol = m.group(1);
437
+ user = m.group(2);
438
+ pass = m.group(3);
439
+ URL = protocol + "://" + m.group(4);
440
+ }
441
+ URL urlObj = null;
442
+ try {
443
+ urlObj = new URL(URL);
444
+ if (urlObj != null) {
445
+ URLConnection urlConn = urlObj.openConnection();
446
+ if (user != null && pass != null) {
447
+ String userPassword = user + ":" + pass;
448
+ String encoding = new Base64().encodeBase64String(userPassword.getBytes());
449
+ urlConn.setRequestProperty("Authorization", "Basic " + encoding);
450
+ }
451
+ p = Pattern.compile("://([^/]+)/(\\S+)");
452
+ m = p.matcher(URL);
453
+ result = m.find();
454
+ if (result) {
455
+ String host = m.group(1);
456
+ String path = m.group(2);
457
+ output = new File((String) options.valueOf("output-dir") + path);
458
+ output.getParentFile().mkdirs();
459
+ if (!output.exists() || output.length() != urlConn.getContentLength()) {
460
+ System.out.println("Downloading an http object from URL: " + URL);
461
+ BufferedInputStream reader = new BufferedInputStream(urlConn.getInputStream(), bufLen);
462
+ BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(output), bufLen);
463
+ while (true) {
464
+ int data = reader.read();
465
+ if (data == -1) {
466
+ break;
467
+ }
468
+ writer.write(data);
469
+ }
470
+ reader.close();
471
+ writer.close();
472
+ } else {
473
+ System.out.println("Skipping download of http object from URL: " + URL + " since local output exists: " + output.getAbsolutePath());
474
+ }
475
+ }
476
+ }
477
+ } catch (MalformedURLException e) {
478
+ System.err.println(e.getMessage());
479
+ } catch (IOException e) {
480
+ System.err.println(e.getMessage());
481
+ }
482
+ } else {
483
+ output = new File((String) options.valueOf("input-file"));
484
+ }
485
+ boolean result = FileTools.unzipFile(output, new File((String) options.valueOf("output-dir")));
486
+ if (!result) {
487
+ ret.setStderr("Can't unzip software bundle " + options.valueOf("input-file") + " to directory " + options.valueOf("output-dir"));
488
+ ret.setExitStatus(ReturnValue.RUNTIMEEXCEPTION);
489
+ }
490
+ return (ret);
491
+ }
492
+ - |2
493
+ public void writeConfigurationFile() throws IOException, ComponentException {
494
+ SystemConfig config = parent.getParentSystem().getConfiguration();
495
+ File original = config.getLocation();
496
+ File backup = new File(original.getParentFile(), original.getName() + "." + System.currentTimeMillis());
497
+ FileInputStream in = new FileInputStream(original);
498
+ FileOutputStream out = new FileOutputStream(backup);
499
+ byte[] buffer = new byte[2048];
500
+ try {
501
+ int bytesread = 0;
502
+ while ((bytesread = in.read(buffer)) > 0) {
503
+ out.write(buffer, 0, bytesread);
504
+ }
505
+ } catch (IOException e) {
506
+ logger.warn("Failed to copy backup of configuration file");
507
+ throw e;
508
+ } finally {
509
+ in.close();
510
+ out.close();
511
+ }
512
+ FileWriter replace = new FileWriter(original);
513
+ replace.write(config.toFileFormat());
514
+ replace.close();
515
+ logger.info("Re-wrote configuration file " + original.getPath());
516
+ }
517
+ - |2
518
+ @Override
519
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
520
+ resp.addHeader("Cache-Control", "max-age=" + Constants.HTTP_CACHE_SECONDS);
521
+ String uuid = req.getRequestURI().substring(req.getRequestURI().indexOf(Constants.SERVLET_FULL_PREFIX) + Constants.SERVLET_FULL_PREFIX.length() + 1);
522
+ boolean notScale = ClientUtils.toBoolean(req.getParameter(Constants.URL_PARAM_NOT_SCALE));
523
+ ServletOutputStream os = resp.getOutputStream();
524
+ if (uuid != null && !"".equals(uuid)) {
525
+ try {
526
+ String mimetype = fedoraAccess.getMimeTypeForStream(uuid, FedoraUtils.IMG_FULL_STREAM);
527
+ if (mimetype == null) {
528
+ mimetype = "image/jpeg";
529
+ }
530
+ ImageMimeType loadFromMimeType = ImageMimeType.loadFromMimeType(mimetype);
531
+ if (loadFromMimeType == ImageMimeType.JPEG || loadFromMimeType == ImageMimeType.PNG) {
532
+ StringBuffer sb = new StringBuffer();
533
+ sb.append(config.getFedoraHost()).append("/objects/").append(uuid).append("/datastreams/IMG_FULL/content");
534
+ InputStream is = RESTHelper.get(sb.toString(), config.getFedoraLogin(), config.getFedoraPassword(), false);
535
+ if (is == null) {
536
+ return;
537
+ }
538
+ try {
539
+ IOUtils.copyStreams(is, os);
540
+ } catch (IOException e) {
541
+ resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
542
+ LOGGER.error("Unable to open full image.", e);
543
+ } finally {
544
+ os.flush();
545
+ if (is != null) {
546
+ try {
547
+ is.close();
548
+ } catch (IOException e) {
549
+ resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
550
+ LOGGER.error("Unable to close stream.", e);
551
+ } finally {
552
+ is = null;
553
+ }
554
+ }
555
+ }
556
+ } else {
557
+ Image rawImg = KrameriusImageSupport.readImage(uuid, FedoraUtils.IMG_FULL_STREAM, this.fedoraAccess, 0, loadFromMimeType);
558
+ BufferedImage scaled = null;
559
+ if (!notScale) {
560
+ scaled = KrameriusImageSupport.getSmallerImage(rawImg, 1250, 1000);
561
+ } else {
562
+ scaled = KrameriusImageSupport.getSmallerImage(rawImg, 2500, 2000);
563
+ }
564
+ KrameriusImageSupport.writeImageToStream(scaled, "JPG", os);
565
+ resp.setContentType(ImageMimeType.JPEG.getValue());
566
+ resp.setStatus(HttpURLConnection.HTTP_OK);
567
+ }
568
+ } catch (IOException e) {
569
+ resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
570
+ LOGGER.error("Unable to open full image.", e);
571
+ } catch (XPathExpressionException e) {
572
+ resp.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
573
+ LOGGER.error("Unable to create XPath expression.", e);
574
+ } finally {
575
+ os.flush();
576
+ }
577
+ }
578
+ }
579
+ - source_sentence: |2
580
+ public static boolean insert(final Cargo cargo) {
581
+ int result = 0;
582
+ final Connection c = DBConnection.getConnection();
583
+ PreparedStatement pst = null;
584
+ if (c == null) {
585
+ return false;
586
+ }
587
+ try {
588
+ c.setAutoCommit(false);
589
+ final String sql = "insert into cargo (nome) values (?)";
590
+ pst = c.prepareStatement(sql);
591
+ pst.setString(1, cargo.getNome());
592
+ result = pst.executeUpdate();
593
+ c.commit();
594
+ } catch (final SQLException e) {
595
+ try {
596
+ c.rollback();
597
+ } catch (final SQLException e1) {
598
+ e1.printStackTrace();
599
+ }
600
+ System.out.println("[CargoDAO.insert] Erro ao inserir -> " + e.getMessage());
601
+ } finally {
602
+ DBConnection.closePreparedStatement(pst);
603
+ DBConnection.closeConnection(c);
604
+ }
605
+ if (result > 0) {
606
+ return true;
607
+ } else {
608
+ return false;
609
+ }
610
+ }
611
  sentences:
612
+ - |2
613
+ public String md5sum(String toCompute) throws Exception {
614
+ MessageDigest md = MessageDigest.getInstance("MD5");
615
+ md.update(toCompute.getBytes());
616
+ java.math.BigInteger hash = new java.math.BigInteger(1, md.digest());
617
+ return hash.toString(16);
618
+ }
619
+ - |2
620
+ protected void runTest(URL pBaseURL, String pName, String pHref) throws Exception {
621
+ URL url = new URL(pBaseURL, pHref);
622
+ XSParser parser = new XSParser();
623
+ parser.setValidating(false);
624
+ InputSource isource = new InputSource(url.openStream());
625
+ isource.setSystemId(url.toString());
626
+ String result;
627
+ try {
628
+ parser.parse(isource);
629
+ ++numOk;
630
+ result = "Ok";
631
+ } catch (Exception e) {
632
+ ++numFailed;
633
+ result = e.getMessage();
634
+ }
635
+ log("Running test " + pName + " with URL " + url + ": " + result);
636
+ }
637
+ - |2
638
+ public String generateMappackMD5(File mapPackFile) throws IOException, NoSuchAlgorithmException {
639
+ ZipFile zip = new ZipFile(mapPackFile);
640
+ try {
641
+ Enumeration<? extends ZipEntry> entries = zip.entries();
642
+ MessageDigest md5Total = MessageDigest.getInstance("MD5");
643
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
644
+ while (entries.hasMoreElements()) {
645
+ ZipEntry entry = entries.nextElement();
646
+ if (entry.isDirectory()) continue;
647
+ String name = entry.getName();
648
+ if (name.toUpperCase().startsWith("META-INF")) continue;
649
+ md5.reset();
650
+ InputStream in = zip.getInputStream(entry);
651
+ byte[] data = Utilities.getInputBytes(in);
652
+ in.close();
653
+ byte[] digest = md5.digest(data);
654
+ log.trace("Hashsum " + Hex.encodeHexString(digest) + " includes \"" + name + "\"");
655
+ md5Total.update(digest);
656
+ md5Total.update(name.getBytes());
657
+ }
658
+ String md5sum = Hex.encodeHexString(md5Total.digest());
659
+ log.trace("md5sum of " + mapPackFile.getName() + ": " + md5sum);
660
+ return md5sum;
661
+ } finally {
662
+ zip.close();
663
+ }
664
+ }
665
  pipeline_tag: sentence-similarity
666
  library_name: sentence-transformers
667
  metrics:
 
683
  - type: spearman_cosine
684
  value: 0.5635084463158045
685
  name: Spearman Cosine
686
+ license: c-uda
687
  ---
688
 
689
  # SentenceTransformer based on Shuu12121/CodeModernBERT-Owl