Scala does not have checked exceptions like Java, so you can't do soemthing like this to force a programmer to deal with an exception:
public void stringToInt(String str) throws NumberFormatException {
Integer.parseInt(str)
}
from tika import parser | |
import os | |
def extract_text_from_pdfs_recursively(dir): | |
for root, dirs, files in os.walk(dir): | |
for file in files: | |
path_to_pdf = os.path.join(root, file) | |
[stem, ext] = os.path.splitext(path_to_pdf) | |
if ext == '.pdf': |
#!/bin/bash | |
# CSV to JSON converter using BASH | |
# original script from http://blog.secaserver.com/2013/12/convert-csv-json-bash/ | |
# thanks SecaGuy! | |
# Usage ./csv2json.sh input.csv > output.json | |
input=$1 | |
[ -z $1 ] && echo "No CSV input file specified" && exit 1 | |
[ ! -e $input ] && echo "Unable to locate $1" && exit 1 |
/** | |
* Uses Tikas {@link AutoDetectParser} to extract the text of a file. | |
* | |
* @param document | |
* @return The text content of a file | |
*/ | |
@Override | |
public String extractTextOfDocument(File file) throws Exception { | |
InputStream fileStream = new FileInputStream(file); | |
Parser parser = new AutoDetectParser(); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>@comeetie : carte données carroyées</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> |
import java.io.{BufferedOutputStream, FileOutputStream, FileInputStream, BufferedInputStream} | |
import java.util.zip.{GZIPOutputStream, GZIPInputStream} | |
import scala.io.{Source, Codec} | |
import scala.language.{reflectiveCalls, implicitConversions} | |
object main extends App { | |
import utils._ | |
val inFile = "/Users/bytter/Documents/Development/shiftforward/spitz/coopeventsfiltered.log.gz" |
import org.codehaus.jackson.JsonNode; | |
import play.libs.WS; | |
import play.libs.F.Promise; | |
import play.libs.WS.WSRequestHolder; | |
/** | |
* Refer | |
* http://goo.gl/HXhJG | |
* Javadoc api/2.1.0/java/play/libs/WS.WSRequestHolder : http://goo.gl/AXmBY |
# ======================================== | |
# Testing n-gram analysis in ElasticSearch | |
# ======================================== | |
curl -X DELETE localhost:9200/test | |
curl -X PUT localhost:9200/test -d ' | |
{ | |
"settings" : { | |
"index" : { | |
"analysis" : { |
#!/bin/sh | |
exec scala -savecompiled "$0" "$@" | |
!# | |
import java.io._ | |
val docs = new File(".").listFiles | |
.filter(_.getName.endsWith(".textile")) // process only textile files | |
.map(new DocumentationFile(_)) |
#A simple Slideshow module wrapped in a Backbone View
Viewable in action in this jsfiddle